I figured the major parts of it out. The way the vertex data gets loaded is by loading the scale/translate/frame name information, then looping through the rest of the frame size (in bytes) to get the vertex points for each frame. For future reference and anyone who might care it looks something like this...
Code:
fseek(md2file,md2header.FrameOffset,SEEK_SET); //move to frame offset
for(int i = 0; i < md2header.nFrames; i++){ //loop through equal to number of frames
fread(&frame,sizeof(frame),1,md2file); //read the scale, translate, name info
for(int n = 0; n < (md2header.FrameSize - sizeof(MD2FRAME)) / 4; n++){
fread(&verts,sizeof(MD2VERTEX),1,md2file); //read in all the vertex points for the rest of the frame
//every time it loops through it will erase the verts struct
//(i plan on assigning verts to something else, this is why)
}
}
I will edit this post with whatever other useful things I find out that I did not find anywhere else (like gpwiki, google, so on).
EDIT: I guess I need some help on the rendering part. As you can see in the attached picture something weird happened with the rendering of my torus. Spheres, people, birds.... dwarfs... they all look weird like that too. My render code is below also. Do I need to load the GLCommands from the MD2 file, or is is ok to assume they are always triangles? I also already decompressed the vertex data with the scale and translations from the frame.
Code:
bool MD2::RenderMD2Objects(int frame)
{
MD2MODEL mdl = mdls.front();
/*render all objects to the screen*/
glPolygonMode( GL_BACK, GL_FILL ); //draw back face
glPolygonMode( GL_FRONT, GL_FILL ); //draw front face
glEnable(GL_NORMALIZE);
glBegin(GL_TRIANGLES);
for(int i = 0; i < mdl.nFaces; i++){
//the vertexes are stored in vectors, to render each frame the vector index needs to be multiplied by the frame number
glVertex3f( mdl.v_x[ mdl.vi_x[i]*frame ],
mdl.v_y[ mdl.vi_y[i]*frame ],
mdl.v_z[ mdl.vi_z[i]*frame ]);
}
glEnd();
return true;
}
EDIT #2: Ok so I fixed it. I looped through the triangle making loops with respect to each face, but did not make the other 2 vertex points in order to make the complete face. Here is the working render code for future people. Also, just from my experience, the code out there can vary and be so specific to one person that it can be hard to try and make someone's code work for you, but never hurts to try.
Code:
glBegin(GL_TRIANGLES);
for(int i = 0; i < mdl.nFaces; i++){
glVertex3f( mdl.v_x[ mdl.vi_x[i]*frame ],
mdl.v_y[ mdl.vi_x[i]*frame ],
mdl.v_z[ mdl.vi_x[i]*frame ]);
glVertex3f( mdl.v_x[ mdl.vi_y[i]*frame ],
mdl.v_y[ mdl.vi_y[i]*frame ],
mdl.v_z[ mdl.vi_y[i]*frame ]);
glVertex3f( mdl.v_x[ mdl.vi_z[i]*frame ],
mdl.v_y[ mdl.vi_z[i]*frame ],
mdl.v_z[ mdl.vi_z[i]*frame ]);
}
glEnd();