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).]
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.
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).]
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.
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 .
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
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?
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).]
Talking about the md2 format. Has anyone ever tried to read the GL command list instead of the triangle list and use that for rendering? Either there’s a massive bug in my reader that I can’t find (very likely or a lot of md2 models store the GL command list incorrectly. It seems that some triangles are missing and for some vertices the texture co-ordinates are incorrect, when I read the info out of the GL command list. Reading the regular triangle list and the texture co-ordinates list from the same model file gives the expected results.
Take a look at the Quake 2 engine source about loading the GL commands. I didn’t have a thorough look at it but I do remember seeing the GL command loading code.
Originally posted by Asgard: Talking about the md2 format. Has anyone ever tried to read the GL command list instead of the triangle list and use that for rendering? Either there’s a massive bug in my reader that I can’t find (very likely or a lot of md2 models store the GL command list incorrectly. It seems that some triangles are missing and for some vertices the texture co-ordinates are incorrect, when I read the info out of the GL command list. Reading the regular triangle list and the texture co-ordinates list from the same model file gives the expected results.
yes ive written a parser which seems to handle all md2 models ive thrown at it, i can post the source code if u wish?
Originally posted by zed: i can post the source code if u wish?
I’d be very grateful if you do, so I can find the bug in my reader. Cheers.
BTW can anyone tell me why it’s possible to have multiple textures (skins as they call them) in an md2 file? I mean, in the format there’s no way of specifying which texture to use for which triangles, so what are they for?
Well, I’m not familiar with the MD2 format and the use of the glCommands but I would guess the problem is in their somewhere.
You don’t use the NumTextcoords or OffSetTexCoords components of the Header record at all. You are trying to get your TexCoords out of the glCommands list (which seems wrong to me). In an example of an MD2 loader I have, they read the TexCoords using the above two variables and don’t seem to read the glCommands at all (not that I can see at any rate).
You are correct. I just looked at a specification and found that the TexCoords are not used at all (which is odd because they are used by the example I gave the link too…
Anyway…
If you change your Texture creation to use…
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, x, y, GL_RGB, GL_UNSIGNED_BYTE, data);
it should work.
It’s either a MipMapping problem or you’re using the same rotten version of MS-OpenGL my Laptop runs.
[This message has been edited by rgpc (edited 10-23-2002).]
i ripped this out of one of my old programs (hopefully its all the info u need) if not ill email more code
struct Tri_group
{
enum { STRIP, FAN };
int type;
int num_indices;
int *indices;
TEXCOORD *texcoords;
int *tri_indices;
int num_tri_indices;
int feed_data ( int *data );
void convert_to_tris ( void );
};
// returns number of data, zero if thats all folks
int Tri_group::feed_data( int *data )
{
num_indices = abs( data[0] );
// printf("%d ", num_indices );
if ( num_indices )
{
if ( data[0] < 0 )
type = FAN;
else
type = STRIP;