Importing "Static" 3D objects and playing their various animations in Directx 11

Started by
1 comment, last by CoOlDud3 11 years, 6 months ago
Hi Guys,
I have followed many tutorials that are from "www.directxtutorial.com", "www.rastertek.com". I haved learnt much from these tutorials. I am able to load a 3D model. But i want to play my model's animation. I used 3DS Max 2013 to make my model and animation. but how do i use it's animation part in my code to make my object move? I am working on DirectX 11. Help would be appreciated.

Regards,

Rayyan Tahir.
Advertisement
I recently got my skinned model importer working. To load the models I used the Assimp library which have been working great. It can load many different formats both for static models and animated ones and the only job you have to do for yourself is to extract the data you need from the aiScene object. To extract the skeleton and animation data I used this. I first tried extracting the skeletion hierarchy myself but that was above my head so I was really happy finding that animation extractor. Even if you won't use Assimp you can take a look at the source code for the animation extractor to see how it works.

To do the animation you send the array of bone transforms to the shader. You should have a vertex structure containing indexes to which bone the vertex gets affected by and also weights deciding how much it's affected.


struct SkinnedVertexIn
{
float3 PosL : POSITION;
float3 NormalL : NORMAL;
float2 Tex : TEXCOORD;
float3 Weights : WEIGHTS;
uint4 BoneIndices : BONEINDICES; // Indices into the bone transform array
};


And then you do something like this to calculate the position for a vertex after applying the bone transforms:


cbuffer cbSkinned
{
float4x4 gBoneTransforms[96];
};

...

for(int i = 0; i < 4; ++i)
{
posL += weights*mul(float4(vin.PosL, 1.0f), gBoneTransforms[vin.BoneIndices]).xyz;
normalL += weights*mul(vin.NormalL, (float3x3)gBoneTransforms[vin.BoneIndices]);
}


Good luck!
Thanks I Will Try That Out

This topic is closed to new replies.

Advertisement