rendering md2 model
I'm trying to make a program that loads and renders an md2 model. I'm getting a blank screen however when everything should look good. I can't see a problem but maybe you guys can. Here's my function to render it, which gets called by my main render function. Also my arrays in the function contain valid data, as my friend gave me the model data to help me debug(he rendered it w/ DX), and i tested the array values against his data print off. here it is:
bool RenderMD2Model( MD2MODEL *model )
GLfloat *verts = new GLfloat[model->NumVerts*3];
// array to hold entire model vertices
int vc1=0, vc2=1, vc3=2;
for(i=0; i < model->NumVerts; i++)
verts[vc1] = model->Frames.Verts[i].x;
verts[vc2] = model->Frames.Verts[i].y;
verts[vc3] = model->Frames.Verts[i].z;
int nTotalNumIndices = 0;
for(i =0; i < model->NumPrimitives; i++)
nTotalNumIndices += model->Primitives[i].NumFaceIndices;
GLubyte *indices = new GLubyte[nTotalNumIndices];
// big array to hold all the indices
int ic1 = 0;
for(i=0; i < model->NumPrimitives; i++)
for(j=0; j < model->Primitives[i].NumFaceIndices; j++)
indices[ic1] = model->Primitives[i].FaceIndices[j].index;
// draw it!
// Enable the vertex array
glVertexPointer(3, GL_FLOAT, 0, verts);
glDrawElements(GL_TRIANGLE_STRIP, nTotalNumIndices, GL_UNSIGNED_BYTE, indices);
delete  verts; verts = NULL;
delete  indices; indices = NULL;
Re: rendering md2 model
I wrote a program to draw an md2model a while ago, and unfortunately I don't have the source to hand. But one thing I remember is that there is a series of gl_cmds which dictate whether a number of vertices are to be interpreted as a fan or a strip.
It went something along the lines of: if the gl_cmd has a value -n then the next n indices make a fan, if the gl_cmd has value +n then the next n indices make a strip. Or vice-versa, or something along those lines?
Sorry I can't be more helpful.