We had to parse 5 kind of information:
- vertex: e.g. v 15.424347 17.551886 -10.248134
- normals: e.g. vn -1.000000 0.000000 0.000000
- textures: e.g. vt 0.503197 0.007948
- faces: e.g. f 6/340/1 2/337/2 7/339/3
- f v/vt/vn v/vt/vn v/vt/vn
vector<> > vertexes;
vector<> > normals;
vector<> > textures;
In a scripting language this would be rather trivial, but in C++ it's rather complex. For example, to split after " " you would do this in Python:
- str.split(" ")
- vector<> split_vec;
split( split_vec, line, is_any_of(" ") );
- vector
OBJResource::parseLine(string line, int dims)
- parseLine("v 15.424347 17.551886 -10.248134", 3) -> [15.424347, 17.551886, -10.248134]
- vector
vec = parseLine(string(buf), 3);
vertexes.push_back( Vector<3,>( vec[0], vec[1], vec[2] ) );
- sscanf(split_inner[1].c_str(), "%d", &inner_in);
face->texc[i-1] = textures[inner_in-1];
- int a = Integer.parseInt("5");
Other than that we also had to dig a little into Open Engine, some of the things that we didn't understand at first was:
- Face class didn't have a "smart" constructor, so we had to modify public field variables directly
- We had to call face->CalcHardNorm() and face->CalcTangentSpace() explicitly
- We didn't really understand why FacePtr was smart, but that's probably because we don't have that much experience with C++ programming
1 comment:
Why boost pointers are smart can be found on Open Engine documentation: Smart Pointers
Post a Comment