Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


3D Model Skeletons

This topic is 5967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just downloaded Milkshape 3D and I''m playing around with making humanoid models. Soon I want to learn how to set up a skelton so I can easily animate the model when I put it into my under-construction 3-D engine. I''m using D3D 8.0 w/ VC++. Is implemententing skeltons pretty easy, or will I have to write the entire thing myself?

Share this post

Link to post
Share on other sites
Skeletonanimation is hard, especially the math...

I took the time to encapsule the skinned mesh example in the dsk8.1, rewriting it line by line. Took about two days writing the 1800 lines of code. The example is hard becouse it supports alot of different "meshtypes"...

Philip Taylors (MS) next article on msdn will be in the area of this. Check it out... Should be out in a couple of weeks.

If there''s anything I can help you with, (beginner to though) dont hesitate to ask me!


Share this post

Link to post
Share on other sites
Is the implementation of the actual skelton the hard part, or is the majority of the work done with loading and rendering the mesh?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
All of it is hard, I don''t have a 100% grip on this yet so, but I''ll get back to you later on...

Share this post

Link to post
Share on other sites
Agree with all previous comments.

My suggestions:
1) Learn how to use D3D vertex buffers and index buffers with normal (non-skeletal, single matrix per mesh) objects first.
2) Once you understand #1 really well, take the time to learn how skeletal meshes work, completely independent of D3D8.1. I suggest looking at brett porter's stuff: rsn.gamedev.net. Unfortunately, his sample code is designed for OpenGL -- fortunately, his sample code uses milkshape3d file formats (additional ms3d file format stuff can be found on milkshape's home page.) I suggest using the ms3d ascii format -- its a bit unweildly but you can read the files using notepad and figure out what's going on.
2a) Also learn how ms3d file format works within the conceptual framework of skinned meshes in general.
3) Once you understand skinned meshes conceptually and understand how the ms3d file format works, you can try to implement them in directx -- this is where things get tricky. As johanK points out, there are many different mesh types and differing ways of rendering skinned meshes in d3d. The sample (skinnedmesh) is very confusing because of this. After much expirementation, i discovered that the easiest method of doing skinned meshes in d3d is:
a) Using Matrix Palette. this feature is documented in directx help.
b) Software vertex computation (cause most graphics cards, including geForce3 don't support matrix palettes in hardware)
c) the following state settings before rendering (if you don't understand this code yet, do step #1 again. =) ):

{success=false;} //this maximizes compatability at expense of speed
if (FAILED(m_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS))) //this says each vertex is only influenced by its own bone matrix (two matrices cannot affect the same bone which is fine cause ms3d doesn't allow it anyway)
{success=false;} //says we are using a matrix palette.
if (FAILED (m_pD3DDevice->SetVertexShader( D3DFVF_SKINVERTEX ) ) ) //use the fvf we define

And this as your FVF:
struct SSkinVertex
D3DXVECTOR3 v; //vertex
DWORD matrixIndices; //low byte is the only one used. says which bone in the matrix palette to use
D3DXVECTOR3 n; //normal
float tu, tv; //tex coordinates

With this as the FVF declaration:

This will allow you to have a matrix palette of 255 bones/matrices. If you need more matrices (doubt that you will) you can swap the palette halfway through.

4) What you might want to do is write something that loads the milkshape file in native form, then converts the data into D3D vertex and index buffers (this is quite easy if you understand what's going on -- it is a little tricky cause you have to deal with the different vertex and index formats). Once loaded render everything with identity matrices to make sure your IB and VB are right -- all of the meshes for each bone will render on top of each other (like a sick pile of limbs). However, each distinct bone should look correct (ie the arm will look like an arm, but it will look like the arms are all stacked on top of each other.) Then, you can start to try to get the matrices right.

Good luck, it's no easy task!


[edited by - DmGoober on March 19, 2002 2:02:13 PM]

[edited by - DmGoober on March 19, 2002 2:03:10 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!