Results 1 to 2 of 2

Thread: rendering md2 model

  1. #1

    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 )
    int i,j;

    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[0].Verts[i].x;
    verts[vc2] = model->Frames[0].Verts[i].y;
    verts[vc3] = model->Frames[0].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;

    return true;


  2. #2
    Junior Member Newbie
    Join Date
    Feb 2000
    england, uk

    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.


Similar Threads

  1. Load a .vtk model and rendering it with OpenGL
    By anto.gallarello in forum OpenGL: Linux
    Replies: 1
    Last Post: 12-15-2016, 06:12 AM
  2. What order to use for rendering? Drawable -> Texture -> Model?
    By agnfolie in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-06-2013, 06:24 AM
  3. Model Rendering problem...
    By MolmasEpic in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-24-2011, 08:07 PM
  4. Some advice for model animation/rendering
    By Xarragon in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-10-2004, 07:06 AM
  5. why is the rendering 3D model so slow
    By Spaceboy in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-28-2002, 02:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean