Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Cannot get it animated using custom controller

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


// Move fork here
if (m_bMoveFork)
{

HRESULT hr = D3DXCreateKeyframedAnimationSet("CBSet1", 500, D3DXPLAY_LOOP, 1, 0, NULL, &m_pAnimSet);

D3DXMATRIX mat2;
D3DXMatrixIdentity(&mat2);
FrameEx *f = (FrameEx*) D3DXFrameFind(cm_CBMesh.GetFrameRoot(), "ET_YELL02");
//D3DXMatrixTranslation(&mat2, 0.0f, 50.0f, 0.0f);
//D3DXMatrixMultiply(&f->TransformationMatrix, &f->TransformationMatrix, &mat2);

D3DXMatrixTransformation(&mat2, NULL, NULL, NULL, NULL,NULL, &m_position);
D3DXMatrixMultiply (&f->TransformationMatrix, &f->TransformationMatrix, &mat2);


D3DXVECTOR3 vFork(f->TransformationMatrix._41, f->TransformationMatrix._42, f->TransformationMatrix._43);
D3DXKEY_VECTOR3 pos[2];
pos[0].Time = 0.0f;
pos[0].Value = vFork;

pos[1].Time = 1000.0f;
pos[1].Value = D3DXVECTOR3(vFork.x, vFork.y+50.0f, vFork.z);

DWORD idx;
hr = m_pAnimSet->RegisterAnimationSRTKeys(f->Name, 0, 0, 2, NULL, NULL, pos, &idx);

hr = m_pAnimController->RegisterAnimationSet(m_pAnimSet);

m_pAnimController->SetTrackAnimationSet(1, m_pAnimSet);


D3DXTRACK_DESC td;
td.Enable = TRUE;
td.Speed = 10.0f;
td.Position = 0.0f;
td.Weight = 1.0f;
td.Priority = D3DXPRIORITY_HIGH;

m_pAnimController->SetTrackDesc(1, &td);





m_bMoveFork = false;
}




//Update animation
if (m_pAnimController)
m_pAnimController->AdvanceTime(deltaTime, NULL);


This piece of code won't animate the fork that I am after. If I use the commented code, it works
But why is that?
Thanks
Jack

Share this post


Link to post
Share on other sites
Advertisement
Hidden


// Move fork here
if (m_bMoveFork)
{

HRESULT hr = D3DXCreateKeyframedAnimationSet("CBSet1", 500, D3DXPLAY_LOOP, 1, 0, NULL, &m_pAnimSet);

D3DXMATRIX mat2;
D3DXMatrixIdentity(&mat2);
FrameEx *f = (FrameEx*) D3DXFrameFind(cm_CBMesh.GetFrameRoot(), "ET_YELL02");
//D3DXMatrixTranslation(&mat2, 0.0f, 50.0f, 0.0f);
//D3DXMatrixMultiply(&f->TransformationMatrix, &f->TransformationMatrix, &mat2);

D3DXMatrixTransformation(&mat2, NULL, NULL, NULL, NULL,NULL, &m_position);
D3DXMatrixMultiply (&f->TransformationMatrix, &f->TransformationMatrix, &mat2);


D3DXVECTOR3 vFork(f->TransformationMatrix._41, f->TransformationMatrix._42, f->TransformationMatrix._43);
D3DXKEY_VECTOR3 pos[2];
pos[0].Time = 0.0f;
pos[0].Value = vFork;

pos[1].Time = 1000.0f;
pos[1].Value = D3DXVECTOR3(vFork.x, vFork.y+50.0f, vFork.z);

DWORD idx;
hr = m_pAnimSet->RegisterAnimationSRTKeys(f->Name, 0, 0, 2, NULL, NULL, pos, &idx);

hr = m_pAnimController->RegisterAnimationSet(m_pAnimSet);

m_pAnimController->SetTrackAnimationSet(1, m_pAnimSet);


D3DXTRACK_DESC td;
td.Enable = TRUE;
td.Speed = 10.0f;
td.Position = 0.0f;
td.Weight = 1.0f;
td.Priority = D3DXPRIORITY_HIGH;

m_pAnimController->SetTrackDesc(1, &td);





m_bMoveFork = false;
}




//Update animation
if (m_pAnimController)
m_pAnimController->AdvanceTime(deltaTime, NULL);


This piece of code won't animate the fork that I am after. If I use the commented code, it works
But why is that?
Thanks
Jack

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!