Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 CoOlDud3   Members   -  Reputation: 151

Like
0Likes
Like

Posted 17 October 2012 - 10:50 AM

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.

Sponsor:

#2 simpler   Members   -  Reputation: 912

Like
1Likes
Like

Posted 19 October 2012 - 01:25 PM

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[i]*mul(float4(vin.PosL, 1.0f), gBoneTransforms[vin.BoneIndices[i]]).xyz;
   normalL  += weights[i]*mul(vin.NormalL, (float3x3)gBoneTransforms[vin.BoneIndices[i]]);
}

Good luck!

Edited by simpler, 19 October 2012 - 01:28 PM.


#3 CoOlDud3   Members   -  Reputation: 151

Like
0Likes
Like

Posted 23 October 2012 - 02:31 AM

Thanks I Will Try That Out




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS