Recommended Posts

Is there a way to get the original TransformationMatrix of the skinned mesh after a unknown period of animation?
This is because, as my mesh instance shares the same resources, if one of the instance is not animating, but another is animated, it will cause all instance to move as the transformation matrix is shared across all instance.
Is there a way to solve this problem?
E.g MeshOne is not animated, MeshTwo is being animated each frame. However as the mesh shares the same resources since they are instances, MeshOne gets animated since it get the same resource from MeshTwo.

0

Share this post

Link to post

Share on other sites

You can have one mesh, but you will initially only have one animation controller and one D3DXFRAME hierarchy. You would need to create a new animation controller for each instance of the mesh to animate. You can get this by just cloning the current one to a new one. Then each one could have its own animation track(s) active at a time and its own events and such.

However, each controller would still be pointing to that one D3DXFRAME.

For each instance of the mesh:{1) Call that instance's AnimationController->AdvanceTime() function to set the TransformationMatrix's in the D3DXFRAME hierarcy.

2) Call your function to recurse through the D3DXFRAME and calculate the to-root-matrix for each frame.

3) Build the final array of matrices that are to be passed to your shader (offset * to-root)}

So, each instance would also need its own array of matrices for the shader too.

Then you can do the drawing calls, sending those matrix array for each instance to the shader and pMesh->DrawSubset(0).

You could create a class for each instance that has its own animationController and final matrix array and loop through them to do the animation and draw them. You would also need some logic to move the mesh around the world and create the world matrix for that instance.