Skip to main content
gamedev.net
🔒 Locked

Md2 model

Started by Hermes Dec 28, 2004 at 9:26 AM 4 replies 600+ views
Original Post
Hermes
Hermes
In a Md2 file is the number of texture coordinates equal to the number of vertices. I want to use an interleaved structure like struct vertex { float u,v; //for textures float x,y,z; // for vertex coord }; I know that in a 3ds file they are not equal so....in this case i just have to change my struct options ThankX for your answers.
Hermes
Hermes
Well it seems the number is different so i can't count on my method .
davidx9
davidx9
it is, and its very difficult to compensate for it in d3d. you get banding artefacts.
No bombs, No guns, just an army of game creators...
Kwizatz
Kwizatz
May I sugest:

struct vertex{float x,y,z;}struct uv{float u,v;}struct triangle{vertex *v1;uv *uv1;vertex *v2;uv *uv2;vertex *v3;uv *uv3;}


Then build a std::vector or simple array of both vertices and uv coords and use the pointers on the triangle struct to reference them durring drawing time, this will eliminate redundancy.
Hermes
Hermes

The number is not equal .Here's the output of the md2 header:
NumTex:376NumTriangle:704NumVertex:369

This is for blade.md2 which i downloaded from planetquake

The only way arround this is an interleave struct
struct vertex
{
float s,t;
byte vertexIndex;
}


In fact this structure exists in the file at the GLCommands section for fast rendering with vertexArrays i guess .It's frustrating that i have to make my own structs for rendering when i could only read the file and issue some commands using that existing group of structs ,don't you think?
hplus0603
hplus0603
MD2 is a very old file format, from before vertex array rendering and batching was important (i e, from the software-only-and-no-SSE-streaming days).

The best you can do is convert from the MD2 buffers to actual vertex arrays in a pre-conversion step when you build your game. If that won't work, then the second best is to convert to vertex arrays when you load the file into the game, say as part of level load.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.