Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: MD2 Problems

  1. #1
    Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    264

    MD2 Problems

    Ive been having this problem with my MD2 class based off of NeHe's Lesson 4 Ive gone threw everything and I cannt see why its not displaying the MD2. Ive read threw everything on the net and have tryed a million ways of displaying it but none of them work. Can someone please take a look at my code.

    Thanks
    Nuke

    P.S: This code was developed on linux using kdevelop. This code is also alpha alpha code so I know there are some things wrongs with it(dont worry no errors or warnings)

    [This message has been edited by nukem (edited 10-19-2002).]

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: MD2 Problems

    Hehe, your interpolation percentage code is exactly like mine. I guess it can't very much if it ends up working.

    Did you try drawing a simple shape to make sure that all the OpenGL stuff is set up right?

    Did you step through your code with the debugger to make sure that the model was opened correctly?

    md2 character models have 198 frames, did 198 frame get loaded?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: MD2 Problems

    LOL, that alien model was so cool I decided to use my GDK to animate him fer ya!

    Alien Md2 -> s3d animation 1MB <IMG SRC=\"http://www.opengl.org/discussion_boards/ubb/eek.gif\">

    Spider3D saves the model as floating points so the animation is quit large :/. No matter what I did I couldn't preserve the normals when scaling down from float to char.

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    264

    Re: MD2 Problems

    Yes, I had other shapes on the screen and they still work, my bmp and tga loading code works because Ive tested both on a cube. According to my debuging code everything loaded perfectly. When I did
    cout << md2.Frames;

    Nothing came up, Im assuming that means it has 0 frames. If it dose what am I doing wrong?

    Heh you should make your project open source or at least port it to linux, had to run it threw wine

    [This message has been edited by nukem (edited 10-20-2002).]

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,537

    Re: MD2 Problems

    I used the MD2 tutorial on http://www.gametutorials.com to help me learn the MD2 format and it works great! The only problem I had at first was I forgot that john carmack likes the winding of his polys to be CW for front facing, whereas I use CCW so my model looked a bit wierd at first. I suggest taking a look at that tut on that site there. If all else fails just use the code he provides which works for sure.

    -SirKnight
    -SirKnight

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: MD2 Problems

    The alien md2 has 198 frames so something should come up when you call cout << md2.Frame;

    Try stepping through your code with the debugger and carefully match it up with the file format specs.

    I would LOVE to port Spider3D to Linux. That would be soooooo cool. However, I don't know how to use Linux and right now I don't have the time to .

    Hmmmmmm, I would have to fall back into console mode I think...I certainly don't know how to init a Linux window.

    For now it is Win32 only. One day it will be cross platform.

    [This message has been edited by WhatEver (edited 10-21-2002).]

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: MD2 Problems

    I looked at your code a bit right now. I can't really see your rendering code having a problem...you'll have to step through your code and see if everything loaded in correctly.

    I do have a suggestion. You should do the scale and translate once to your vertices when you load in the model. It would surely speed up rendering time...that is, when you get it to render .

    I noticed that Linux C/C++ uses the same headers as Win32 C/C++. That means whenever I do port Spider3D to Linux it'll be a cake walk .

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    767

    Re: MD2 Problems

    You need to change the following struct:-

    struct VERTEX
    {
    //unsigned char Vertex[3];
    float Vertex[3];
    unsigned char LightNormalIndex;
    };


    to this...

    struct VERTEX
    {
    unsigned char Vertex[3];
    unsigned char LightNormalIndex;
    };


    and then change line # 1266 (in your render loop) from...

    glVertex3fv(v1.vertex);

    to...

    glVertex3fv(&vertlist[loop].X);

    [Edit - add some bold...]

    [This message has been edited by rgpc (edited 10-22-2002).]

  9. #9
    Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    264

    Re: MD2 Problems

    Whatever: I dont think its in my loading that seems prefect, I do think it is in the rendering. For Spider3D look into QT they have some stuff so you can have OpenGL in a window with some other stuff, or you could always do it in glut Thanks for the suggestion about the vertices ill do it as soon as I get this thing working.

    rgpc: I did what you said and nothing happened. The compiler gave me a few warnings since I was doing

    Code :
    v1.Vertex[0] = vertlist[loop].X;
    //I changed it to
    v1.Vertex[0] = (char)vertlist[loop].X;
    I also noticed that you told me to do glVertex3fv(&vertlist[loop].X); but what about Y and Z? I put them in and still nothing happened. Can you please explain more?

    Thanks for all your help!

    Nuke

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    767

    Re: MD2 Problems

    Sorry, forgot the most important change of all...

    Line 1208 reads...

    currentframe = (FRAME*) ((char*)Frames + FrameSize * NumFrames);

    Change this to...

    currentframe = (FRAME*) ((char*)Frames + FrameSize * Frame);

    You can get rid of the following code...

    v1.Vertex[0] = vertlist[loop].X;
    v1.Vertex[1] = vertlist[loop].Y;
    v1.Vertex[2] = vertlist[loop].Z;


    as the call...

    glVertex3fv(&vertlist[loop].X);

    Passes the pointer to the "X" component of your vertex. The reason you don't need "Y" and "Z" is because you are passing a pointer to a 3 component vertex. So it assumes that (&vertlist[loop].X)[0] = "X" and (&vertlist[loop].X)[1] = "Y" and so on.

    [This message has been edited by rgpc (edited 10-22-2002).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •