Read MD5MESH to model?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Read MD5MESH to model?

Post by Netwatcher »

hi guys, long time no C, mostly Haskell and LISP(R5RS scheme actually).
at any ratio...
I've made a little MD5MESH loader(to a data structure for now), and I've been wondering how I should go about getting each vertex of the model in place:
A.) there are vertices and weights(I don't get what these are), they should go together somehow, but I'm not sure how really...
B.) there is probably a certain order in which the vertices should be drawn, is it that the one they are already ordered in the file as, or is there a special index for that?


here are the MD5MESH file specifications.
http://www.modwiki.net/wiki/MD5MESH_%28file_format%29
I might be missing something there...

Thankz for your helpz in advancez,
Adar. ;)
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
zeid
Chaos Rift Junior
Chaos Rift Junior
Posts: 201
Joined: Fri Apr 24, 2009 11:58 pm

Re: Read MD5MESH to model?

Post by zeid »

I personally haven't made an .MD5 model loader, but have scratch written an .OBJ loader, which is considerably easier.

A.) Weights refer to the amount that a 'joint' associated with a vertex influences it. It is related to animation, as .MD5 uses skeletal animation. Each of the vertices can have multiple weights associated with different joints (e.g. A vertex close to the forearm and the hand might have a weighting of 40% towards the wrist bone and 60% towards the forearm bone, thus when the bones move it's new position is calculated by the changes and the weights it has).

B.) Triangles are used to index the order in which the vertices are drawn in. The reasoning is that you don't want to repeat vertices (with the same x,y,z) in order to draw correctly. You can either reformat the data using the 'triangles' and 'vertices' data provided so that repeated vertices exist and it is all ordered by which vertex will be drawn first to last, or use API functions to help in the drawing (the second option is no doubt more optimized).
Axolotl Pop!
Image
Or, try it for free.

For many more free games online visit www.sam-zeid.com
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Re: Read MD5MESH to model?

Post by Netwatcher »

yea the weights are pretty self-explanatory...
I was mostly wondering why doesn't the vertices has an XYZ and only tex coords, and weighs has an XYZ?
the first thing that pops to my head when I think of a vertex is a location and texcords, can someone explain why they are separated to these two different terms(weights and vertices).

Thanks zeid, you cleared a lot of things up :)

P.S.
There is the function DrawIndexedPrimitive(D3D) for that, so the API helps me there :)
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: Read MD5MESH to model?

Post by M_D_K »

here's the spec also there is also sample code; it's for GL though.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
Post Reply