• Advertisement
Sign in to follow this  

ID3DXAnimationController problems again

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

Hello Im having some problem with skinned mesh animations. I have loaded a mesh hierarchy and cloned two new ID3DXAnimationController to use. The problem is that the animation i set for one controller affectes the other, for instance if i set controller nr1 to start playing the run animation, both instance's start playing it.(Or atleast it appears that way). I think this has to do with that the controllers are sharing the same mesh hierarchy, but i cannot figure out what my problem is. I cant find anything that i am doing diffrently from the samples. My code is based on the SkinnedMesh and MultiAnim samples. Every frame i do this: 1. controller->AdvanceTime(); 2. Update the frame matrices (this is what i think messes things up) 3. Draw the mesh hierarchy. I have tried to update all frame's TransformationMatrix to a identity matrix before i call advance time on every controller. This *almost* works, the animations gets independant of each other but instead the entire mesh gets distorted in small intervalls when all the bodyparts are placed on origo. If anyone know a solution to this i would be very greatful, im running out if ideas.. :-( Thanks in advance. Here is my code: the function that updates the frames matrices every tick, the first parent matrix is an identity matrix:
void animation_instance_t::update_frame_matrices(D3DXFRAME* pFrameBase, D3DXMATRIX* pParentMatrix)
		D3DXFRAME_EX *pFrame = (D3DXFRAME_EX*)pFrameBase;

			D3DXMatrixMultiply(&pFrame->CombinedTransformationMatrix, &pFrame->TransformationMatrix, pParentMatrix);
			pFrame->CombinedTransformationMatrix = pFrame->TransformationMatrix;
			update_frame_matrices(pFrame->pFrameSibling, pParentMatrix);
			update_frame_matrices(pFrame->pFrameFirstChild, &pFrame->CombinedTransformationMatrix);

The skinning, called for every mesh container when the hierarchy is drawn, dont think this could be the problem but i post it anyway, u never know:
UINT cBone = pMeshContainer->pSkinInfo->GetNumBones();

			// set up bone transforms
			for(UINT iBone = 0; iBone < cBone; ++iBone)
			PBYTE       pbVerticesSrc;
			PBYTE       pbVerticesDest;
			pMeshContainer->pOrigMesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&pbVerticesSrc);
			pMeshContainer->MeshData.pMesh->LockVertexBuffer(0, (LPVOID*)&pbVerticesDest);

			// generate skinned mesh
			pMeshContainer->pSkinInfo->UpdateSkinnedMesh(m_multi_animation->m_pBoneMatrices, NULL, pbVerticesSrc, pbVerticesDest);


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement