Sign in to follow this  

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

This topic is 1911 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

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.

Share this post


Link to post
Share on other sites
I recently got my skinned model importer working. To load the models I used the [url="http://assimp.sourceforge.net/"]Assimp[/url] 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 [url="http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/"]this[/url]. 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.

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

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

[CODE]
cbuffer cbSkinned
{
float4x4 gBoneTransforms[96];
};

...

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

Good luck! Edited by simpler

Share this post


Link to post
Share on other sites

This topic is 1911 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this