geohoffman49431

06-21-2004, 12:23 AM

I want to learn more about the md2 file format. I have seen many descriptions and specifications but some things are still unclear.

1). Only triangles are used. But opengl comands can be used to specify that some of the triangles are part of a triangle strip or fan. Lets say we are drawing two triangles with a triangle strip. In the md2 file would there be 4 or 6 vertices for these 2 triangles? If there are 4 verts then you have to draw the triangles as a strip. If there are 6 verts then you would draw the first triangle (3 verts) then skip the next two verts and then draw the last. This way you would also have the option of drawing each triangle without using triangle strips right?

2). When I load an md2 file should I convert the verts to float values or is this generaly going to take up to much memory? I imagine something like this to hold all the frame data:

float vertex_x[number_of_vertices];

float vertex_y[number_of_vertices];

float vertex_z[number_of_vertices];

float texture_x[number_of_vertices];

float texture_y[number_of_vertices];

float normal_x[number_of_vertices];

float normal_y[number_of_vertices];

float normal_z[number_of_vertices];

this seems like the fastest way but it would most likely take up way to much memory. I could precompute everything and have a render function with very little logic. I could even scale the vertices when I load the file. All I would have to do is interpolate from one frame to the next. Any thoughts on this?

3). ID has a list o precalculated lighting normals in an array. You can access them by specifying an index (therefore compressing your normal from 3 float to one unsigned byte). How is it possible to precompute all normals or are they just aproximations?

1). Only triangles are used. But opengl comands can be used to specify that some of the triangles are part of a triangle strip or fan. Lets say we are drawing two triangles with a triangle strip. In the md2 file would there be 4 or 6 vertices for these 2 triangles? If there are 4 verts then you have to draw the triangles as a strip. If there are 6 verts then you would draw the first triangle (3 verts) then skip the next two verts and then draw the last. This way you would also have the option of drawing each triangle without using triangle strips right?

2). When I load an md2 file should I convert the verts to float values or is this generaly going to take up to much memory? I imagine something like this to hold all the frame data:

float vertex_x[number_of_vertices];

float vertex_y[number_of_vertices];

float vertex_z[number_of_vertices];

float texture_x[number_of_vertices];

float texture_y[number_of_vertices];

float normal_x[number_of_vertices];

float normal_y[number_of_vertices];

float normal_z[number_of_vertices];

this seems like the fastest way but it would most likely take up way to much memory. I could precompute everything and have a render function with very little logic. I could even scale the vertices when I load the file. All I would have to do is interpolate from one frame to the next. Any thoughts on this?

3). ID has a list o precalculated lighting normals in an array. You can access them by specifying an index (therefore compressing your normal from 3 float to one unsigned byte). How is it possible to precompute all normals or are they just aproximations?