Original Post
I''ve gone all-out and began using a custom (ASCII) file format for my 3D models in my app, and I''ve built a good class for it, but now I''m at the step where I must convert it into a LPD3DXMesh for use. I know how to do it (CreateMeshFVF with VB/IB and all) but my question is more how to convert my data into data that D3D will like. As of now I''m storing everything in vectors like this:
typedef struct
{
DWORD vertcount; //Number of vertices in this face
DWORD* verts;
DWORD* texcoords;
DWORD texture; //index of texture to use for this face
} FACE;
vector<string*> textures; //string containing filenames to textures
vector<D3DXVECTOR3*> vertices;
vector<D3DXVECTOR3*> normals;
vector<D3DXVECTOR2*> texcoords;
vector<FACE*> faces; //see struct above
I have all of those vectors initialized perfectly but I''m having difficulty getting the data into the VB/IB. I imagine I just have to loop through each face (each face may have any number of vertices [integer >3] so that I could have pentagonal faces and the like) and add 3*(vertcount-2) vertices to the buffer (triangle lists). I have all of the data for the vertex (pos, normal, texcoords) but I haven''t a clue about how to use that. How can I determine the triangles that I must add from the vertices of each face, and how to I organize it so that the subsets and all will be proper to use the textures with?