Rendering Bones on an .X animated mesh

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 25, 2012 at 09:17

What would be the best way to render the bones for an animated mesh , there is 35 bones and bone names, also i think i have the correct matrix array for the bone offsets which i think needs converting to a vector3, can anyone help?

9 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Feb 25, 2012 at 17:45

A common way to do it is to draw a line from each joint’s origin to its parent’s origin. The world space origin of each joint can be extracted by multiplying the local-to-parent matrices all the way up the hierarchy to the world, and taking the translation part of the resulting matrix.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 25, 2012 at 19:22

This is the whole bones names and matrix for each bone data
what i want to know is when using CreateVertexBuffer, which part of the matrix floats do i pass?

Bip01_R_UpperArm
mFinalXForms._11-14 -0.643635 0.404301 -1.028463 0.000000
mFinalXForms
._21-24 0.965917 0.103859 -0.563664 0.000000
mFinalXForms._31-34 -0.123930 -1.388186 -0.468156 0.000000
mFinalXForms
._41-44 15.273911 194.281616 12.726992 1.000000
Bip01_Spine3
mFinalXForms._11-14 -1.267997 0.041719 -0.160957 0.000000
mFinalXForms
._21-24 0.028804 1.120991 0.063639 0.000000
mFinalXForms._31-34 0.187404 0.077850 -1.456163 0.000000
mFinalXForms
._41-44 -6.504746 124.190582 83.320129 1.000000
Bip01_Neck
mFinalXForms._11-14 -1.267997 0.041720 -0.160957 0.000000
mFinalXForms
._21-24 0.028804 1.120991 0.063639 0.000000
mFinalXForms._31-34 0.187404 0.077851 -1.456162 0.000000
mFinalXForms
._41-44 -6.504755 124.190552 83.320091 1.000000
Bip01_Spine2
mFinalXForms._11-14 -1.274926 0.027673 -0.096234 0.000000
mFinalXForms
._21-24 0.018866 1.120677 0.072306 0.000000
mFinalXForms._31-34 0.112438 0.092502 -1.463008 0.000000
mFinalXForms
._41-44 -3.095129 123.495026 83.755302 1.000000
Bip01_Spine1
mFinalXForms._11-14 -1.278391 0.014697 -0.031011 0.000000
mFinalXForms
._21-24 0.010899 1.120149 0.081540 0.000000
mFinalXForms._31-34 0.036783 0.106353 -1.465922 0.000000
mFinalXForms
._41-44 0.428690 122.775131 84.250092 1.000000
Bip01_R_Clavicle
mFinalXForms._11-14 -1.190122 0.449012 0.132136 0.000000
mFinalXForms
._21-24 0.399922 1.048871 0.037847 0.000000
mFinalXForms._31-34 -0.124468 0.100195 -1.461526 0.000000
mFinalXForms
._41-44 2.481809 126.735573 85.728043 1.000000
Bip01_Spine
mFinalXForms._11-14 -1.278391 0.014698 -0.031011 0.000000
mFinalXForms
._21-24 0.010900 1.120149 0.081541 0.000000
mFinalXForms._31-34 0.036783 0.106353 -1.465921 0.000000
mFinalXForms
._41-44 0.428728 122.775085 84.250084 1.000000
Bip01_L_UpperArm
mFinalXForms._11-14 -1.123068 -0.602576 0.105285 0.000000
mFinalXForms
._21-24 -0.480251 0.781918 -0.647659 0.000000
mFinalXForms._31-34 0.315201 -0.796273 -1.195068 0.000000
mFinalXForms
._41-44 -10.850828 181.084183 62.682671 1.000000
Bip01_L_Clavicle
mFinalXForms._11-14 -1.204342 -0.031143 -0.429017 0.000000
mFinalXForms
._21-24 -0.041366 1.121867 0.034686 0.000000
mFinalXForms._31-34 0.491544 0.060924 -1.384290 0.000000
mFinalXForms
._41-44 -18.665379 125.363419 82.472275 1.000000
Bip01_Pelvis
mFinalXForms._11-14 -1.248541 -0.004004 0.276749 0.000000
mFinalXForms
._21-24 0.024254 1.115861 0.125566 0.000000
mFinalXForms._31-34 -0.316611 0.167341 -1.425953 0.000000
mFinalXForms
._41-44 20.582413 119.108849 85.961700 1.000000
Bip01_R_Thigh
mFinalXForms._11-14 -1.216052 0.175225 -0.354925 0.000000
mFinalXForms
._21-24 0.026528 1.040260 0.422680 0.000000
mFinalXForms._31-34 0.453731 0.516485 -1.299600 0.000000
mFinalXForms
._41-44 -15.376446 98.058327 98.468010 1.000000
Bip01_L_Thigh
mFinalXForms._11-14 -1.275089 -0.085803 0.047406 0.000000
mFinalXForms
._21-24 -0.084781 1.059756 -0.362254 0.000000
mFinalXForms._31-34 -0.019608 -0.476914 -1.390597 0.000000
mFinalXForms
._41-44 -5.323092 145.664352 34.783356 1.000000
Bip01_R_Calf
mFinalXForms._11-14 -1.219215 0.170253 -0.346393 0.000000
mFinalXForms
._21-24 -0.003229 1.003449 0.504562 0.000000
mFinalXForms._31-34 0.443713 0.630822 -1.251707 0.000000
mFinalXForms
._41-44 -21.476070 84.178741 114.236572 1.000000
Bip01_R_Foot
mFinalXForms._11-14 -1.205291 0.000902 -0.427473 0.000000
mFinalXForms
._21-24 -0.218514 0.912018 0.618042 0.000000
mFinalXForms._31-34 0.399627 0.858100 -1.124967 0.000000
mFinalXForms
._41-44 -88.635696 37.497635 141.997513 1.000000
Bip01_R_Toe0
mFinalXForms._11-14 -1.205291 0.000902 -0.427473 0.000000
mFinalXForms
._21-24 -0.218514 0.912019 0.618043 0.000000
mFinalXForms._31-34 0.399627 0.858100 -1.124967 0.000000
mFinalXForms
._41-44 -88.635689 37.497635 141.997482 1.000000
Bip01_L_Calf
mFinalXForms._11-14 -1.274357 -0.074875 0.076600 0.000000
mFinalXForms
._21-24 -0.091968 0.933869 -0.617194 0.000000
mFinalXForms._31-34 -0.025920 -0.812286 -1.225197 0.000000
mFinalXForms
._41-44 -6.602040 134.500885 -30.037868 1.000000
Bip01_L_Foot
mFinalXForms._11-14 -1.275818 -0.071704 0.051073 0.000000
mFinalXForms
._21-24 -0.064991 1.120126 -0.050893 0.000000
mFinalXForms._31-34 -0.054822 -0.069860 -1.467550 0.000000
mFinalXForms
._41-44 3.474703 161.703156 165.103699 1.000000
Bip01_L_Toe0
mFinalXForms._11-14 -1.275818 -0.071704 0.051073 0.000000
mFinalXForms
._21-24 -0.064991 1.120126 -0.050893 0.000000
mFinalXForms._31-34 -0.054822 -0.069860 -1.467549 0.000000
mFinalXForms
._41-44 3.474716 161.703140 165.103607 1.000000
Bip01_L_Forearm
mFinalXForms._11-14 -0.665404 -0.547188 -0.945139 0.000000
mFinalXForms
._21-24 -0.582020 0.950283 -0.140407 0.000000
mFinalXForms._31-34 0.997970 0.467431 -0.973218 0.000000
mFinalXForms
._41-44 -104.444687 77.410133 137.622864 1.000000
Bip01_L_Hand
mFinalXForms._11-14 -0.629359 -0.562714 -0.960585 0.000000
mFinalXForms
._21-24 -0.608117 0.932638 -0.147915 0.000000
mFinalXForms._31-34 1.002203 0.502637 -0.951071 0.000000
mFinalXForms
._41-44 -109.728157 74.911644 136.797607 1.000000
Bip01_L_Finger1
mFinalXForms._11-14 -0.629359 -0.562713 -0.960585 0.000000
mFinalXForms
._21-24 -0.608117 0.932638 -0.147915 0.000000
mFinalXForms._31-34 1.002203 0.502637 -0.951071 0.000000
mFinalXForms
._41-44 -109.728180 74.911636 136.797607 1.000000
Bip01_L_Finger11
mFinalXForms._11-14 -0.629359 -0.562713 -0.960585 0.000000
mFinalXForms
._21-24 -0.608117 0.932638 -0.147915 0.000000
mFinalXForms._31-34 1.002203 0.502637 -0.951071 0.000000
mFinalXForms
._41-44 -109.728172 74.911629 136.797607 1.000000
Bip01_L_Finger0
mFinalXForms._11-14 -0.629359 -0.562714 -0.960585 0.000000
mFinalXForms
._21-24 -0.608116 0.932638 -0.147916 0.000000
mFinalXForms._31-34 1.002202 0.502635 -0.951070 0.000000
mFinalXForms
._41-44 -109.728088 74.911728 136.797516 1.000000
Bip01_L_Finger01
mFinalXForms._11-14 -0.355535 -0.246453 -1.203460 0.000000
mFinalXForms
._21-24 -0.740960 0.842812 0.046302 0.000000
mFinalXForms._31-34 1.026531 0.929595 -0.493634 0.000000
mFinalXForms
._41-44 -148.178955 -18.585403 111.950829 1.000000
Bip01_L_Finger02
mFinalXForms._11-14 -0.519571 -0.452188 -1.077513 0.000000
mFinalXForms
._21-24 -0.658421 0.907720 -0.063447 0.000000
mFinalXForms._31-34 1.030512 0.692443 -0.787497 0.000000
mFinalXForms
._41-44 -127.057045 38.559002 132.546478 1.000000
Bip01_L_Finger12
mFinalXForms._11-14 -0.629359 -0.562713 -0.960585 0.000000
mFinalXForms
._21-24 -0.608117 0.932638 -0.147915 0.000000
mFinalXForms._31-34 1.002203 0.502637 -0.951071 0.000000
mFinalXForms
._41-44 -109.728165 74.911621 136.797607 1.000000
Bip01_R_Forearm
mFinalXForms._11-14 -0.681851 0.842419 -0.678876 0.000000
mFinalXForms
._21-24 0.940418 0.360594 -0.497077 0.000000
mFinalXForms._31-34 -0.178050 -1.000407 -1.062578 0.000000
mFinalXForms
._41-44 16.156601 202.355438 89.840164 1.000000
Bip01_R_Hand
mFinalXForms._11-14 -0.656191 0.860448 -0.681546 0.000000
mFinalXForms
._21-24 0.954743 0.350797 -0.476345 0.000000
mFinalXForms._31-34 -0.174814 -0.985991 -1.076499 0.000000
mFinalXForms
._41-44 19.122261 202.607864 91.580429 1.000000
Bip01_R_Finger1
mFinalXForms._11-14 -0.656192 0.860448 -0.681546 0.000000
mFinalXForms
._21-24 0.954743 0.350797 -0.476346 0.000000
mFinalXForms._31-34 -0.174815 -0.985991 -1.076499 0.000000
mFinalXForms
._41-44 19.122276 202.607849 91.580444 1.000000
Bip01_R_Finger11
mFinalXForms._11-14 -0.656192 0.860448 -0.681546 0.000000
mFinalXForms
._21-24 0.954743 0.350797 -0.476346 0.000000
mFinalXForms._31-34 -0.174815 -0.985991 -1.076499 0.000000
mFinalXForms
._41-44 19.122276 202.607864 91.580460 1.000000
Bip01_R_Finger0
mFinalXForms._11-14 -0.656191 0.860448 -0.681546 0.000000
mFinalXForms
._21-24 0.954743 0.350797 -0.476346 0.000000
mFinalXForms._31-34 -0.174814 -0.985991 -1.076498 0.000000
mFinalXForms
._41-44 19.122257 202.607788 91.580284 1.000000
Bip01_R_Finger01
mFinalXForms._11-14 -0.679915 1.056242 -0.239856 0.000000
mFinalXForms
._21-24 0.939066 0.535130 -0.305431 0.000000
mFinalXForms._31-34 -0.198836 -0.443116 -1.387696 0.000000
mFinalXForms
._41-44 19.011827 161.105911 186.974182 1.000000
Bip01_R_Finger02
mFinalXForms._11-14 -0.666769 0.961815 -0.515552 0.000000
mFinalXForms
._21-24 0.948210 0.433376 -0.417828 0.000000
mFinalXForms._31-34 -0.182654 -0.785543 -1.229286 0.000000
mFinalXForms
._41-44 18.693529 192.026108 130.635651 1.000000
Bip01_R_Finger12
mFinalXForms._11-14 -0.656192 0.860448 -0.681546 0.000000
mFinalXForms
._21-24 0.954743 0.350797 -0.476346 0.000000
mFinalXForms._31-34 -0.174815 -0.985991 -1.076499 0.000000
mFinalXForms
._41-44 19.122272 202.607910 91.580452 1.000000
Bip01_Head
mFinalXForms._11-14 -1.273085 0.121279 -0.003060 0.000000
mFinalXForms
._21-24 0.105862 1.113752 0.099242 0.000000
mFinalXForms._31-34 0.015808 0.128992 -1.464479 0.000000
mFinalXForms
._41-44 -1.935864 122.082230 82.028542 1.000000
************************************************

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Feb 25, 2012 at 20:24

That’s not how it works, these are the matrices for each bone, not a point in space.

For handling animation data in direct x files start by looking at

http://www.gamedev.net/page/resources/_/technical/game-programming/working-with-the-directx-x-file-format-and-animation-in-directx-90-r2079

And look at example code like this

http://www.toymaker.info/Games/html/3d_models.html

Once you understand these, then you should be able to add some code to just draw the bones themselves.

You need a bone length, which is not stored in the final transforms.

These will probably not be stored in the x file, they will have to be extracted from your original skeleton.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 26, 2012 at 13:55

So what are these matrices for exactly?

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Feb 27, 2012 at 09:41

You walk the array.

So start at the root bone, which is usually in the small of the back.

This is connected to two thighs and spine1, they are connected to the next bones until you have a fully connected skeleton.

You start with a world matrix which puts the whole character in the correct attitude and location for the game.

Then you recursively walk the skeleton.

In pseudo code

function ApplyMatrix(Bone B)
{
       push current matrix
       apply bone matrix 
       draw bone
       foreach (Bone child in b.children)
       {
             ApplyMatrix(child);
       }
       pop current matrix
} 

You really need to read the tutorials to get an idea of how it all works

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 27, 2012 at 10:32

There is no tutoirals on this subject mate, i think i am the first on the internet to even attempt it in public

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Feb 27, 2012 at 15:32

There are hundreds of them, skinned animation is the single most common form of 3d animations.

The two links above detail a lot of this, or you can look at XNA skinned animation sample, or search for asf_amc_viewer for full source code (opengl)

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 27, 2012 at 17:42

The 2 links above only show the d3d structure and members mate, i dont want to look at opengl tutorials as thats not what i am coding in.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Feb 27, 2012 at 18:23

Skinning works the same way whether you’re doing OpenGL or D3D. It’s not something the API helps you out with but something you implement yourself, so it doesn’t matter which API you use as long as you get the matrix conventions right and so forth.

(And on a more general note, as a coder you’ll need to be able to read, understand, and learn from code that doesn’t match exactly what you’re doing…so this might be a good time to give that a try. :))