OK I’m a little confused right now.It’s 2:00am,I’m hungry,my code keeps crashing and I’m not getting any love from my woman so bear with me while I try to explain my problem.Here goes.
I’ve recently finished writing an exporter plugin for 3DS MAX and it exports the mesh data in the following format:
//-------------------------------------------------------------------
typedef struct
{
int v1,v2,v3; //the indices to the 3 vertices}BMF_Face;
//-------------------------------------------------------------------
typedef struct
{
float u,v; //Texture coordinates
float nx,ny,nz; //normals
float x,y,z; //position}HeavyVertex;
//-------------------------------------------------------------------
typedef struct
{
DWORD ID; //The magic number of our BMF file format.Should be (0x8A8A)
int Animated; //This file also includes animation info.(1=yes,0=no)WORD numVertices;//The number of vertices in our mesh
WORD numFaces; //The number of faces in our meshHeavyVertex *Vertices; //Pointer to the vertices
BMF_Face *Faces; //Pointer to the list of faces}BMFMesh;
//-------------------------------------------------------------------
Basically,my file format has a magic id number,a flag to indicate whether animations are included,the number of vertices and faces in the file and finally,a pointer to the actual vertices and the faces.
So,now that we know what’s in the file,here’s my question:
For static data (ie there are no animations included.All I will be doing with the mesh is rotating and translating it) like a house or a spaceship,what is the best and fastest way to actually draw the damn thing?
What I did was create an interleaved array with a format of GL_T2F_N3F_V3F for the vertices with 0 bytes for the stride.So my Interleaved array statement would look like this:
glInterleavedArrays(GL_T2F_C4F_N3F_V3F,0,mesh->Vertices);
Right after that,I would create a display list like this:
glNewList(Model,GL_COMPILE);
glDrawElements(GL_TRIANGLES,mesh->numFaces*3,GL_UNSIGNED_INT,mesh->Faces);glEndList();
The I would simply call this display list whenever I want to render it.
Now am I doing something really stupid or inefficient?This code actually renders my object,but I just want to know if there is a better way of doing it (I heard of CVA’s but one look at those and my life just got alot more complicated due to this whole locking/unlocking thing) So,before I go totally insane,what are the methods pros use (or nVidia engineers recommend) to do just this.(do remember that I will be translating,rotating and scaling this model in my world)
phew! Now where’s my Mountain Deeeewwww…zzzzzzz…