Jump to content
  • Advertisement
Sign in to follow this  
scwizzo

OpenGL opengl commands for MD2 format

This topic is 3634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is the GLCommand in the MD2 file format absolutely needed? I am trying to render different MD2 files with the loader I created, and I am getting some weird outputs. I get the rough shape of what I am trying to load, and I am not quite sure if I absolutely need the GLCommands to make it look correct. I figured since all MD2 files are saved as triangles it would be ok to use GL_TRIANGLES when rendering. Here is an image of what the rendered object looks like, and the code I am using to render it. http://img.photobucket.com/albums/v482/salem2022/Untitled2.jpg
bool MD2::RenderMD2Objects(int frame)
{
    MD2MODEL mdl = mdls.front();
    
    /*render all objects to the screen*/
    glPolygonMode( GL_BACK, GL_FILL );                  //draw back face with lines
    glPolygonMode( GL_FRONT, GL_FILL );                 //draw front face with lines
    
    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*frame ],
                    mdl.v_y[ mdl.vi_y*frame ],
                    mdl.v_z[ mdl.vi_z*frame ]);
    }
    glEnd();
    
    return true;
}

Share this post


Link to post
Share on other sites
Advertisement
Yea that's where the GLCommand offset comes in, and it helps render more frames per second, but it also works drawing just triangles (it's just really slow sometimes). I got it working now, and it can load/animate the md2 files. Looking back on the code I posted i was pretty dumb. I'm drawing one point for every face, so that definitely wasn't going to work :p Instead I draw 3 points for every face now, and 3 texture coords for every face. My only problem now is converting UV coordinates to texture coordinates since I get values larger than 1 and also negatives when I divide U by the texture width and V by texture height. So if anyone knows/has an idea it would be greatly appreciated

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!