Sign in to follow this  
lucky6969b

Cannot get it animated using custom controller

Recommended Posts

[code]
// 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);

[/code]
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
Hidden
[quote name='lucky6969b' timestamp='1318025200' post='4870280']
[code]
// 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);

[/code]
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
[/quote]

Share this post


Link to post

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