Jump to content
  • Advertisement
Sign in to follow this  

AnimationController Question

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

I have a peculiar controller problem.
Having just cloned the animation controller, I found my individual objects start and stop animating altogether. The mesh is loaded from a single source and dished out to individual character objects... Just don't know what to do. Here is some source code:

In my create submodule

for (int i = 0; i < 5; i++)
pos.x = m_operatorLoc.mat._41;
pos.y = m_operatorLoc.mat._43;
pos.z = m_operatorLoc.mat._42;
m_CharInfo.vStartPos = pos;
m_CharInfo.fSpeed = fRandomSpeed.GetRandomNumber();

OperatorObj.Create(m_pDevice, &OperatorMesh);


Each instances:

bool CObjects::Create(LPDIRECT3DDEVICE9 pDevice, CMesh *pMesh, float fAnimSpeed)
if(pMesh == NULL)
return false;

m_pDevice = pDevice;
m_pMesh = pMesh;

if(m_pMesh->GetAnimController() != NULL)
DWORD dwNumAnimSet = m_pMesh->GetAnimController()->GetMaxNumAnimationSets();

// create a copy of the animation controller
// use max animation sets instead
dwNumAnimSet > 1 ? dwNumAnimSet : 2,
return false;

/////..... blah blah

Updating individual objects

for(int i = 0; i < 5; i++)
// move point light with player
m_CharInfo.fDist = paths.size();
static int P = 0;
if(P < paths.size()-1 && m_bFinishedPathFind || m_CharInfo.fS < 1.0f)//m_CharInfo.fDist && m_bFinishedPathFind)
m_CharInfo.fS += ((m_CharInfo.fSpeed / m_CharInfo.fDist) * m_fElapsedTime);

vecPosMan.x = paths[(int)P].x;
vecPosMan.y = m_CharInfo.vStartPos.y;
//vecPosMan.z = paths[paths.size()-1].y;
vecPosMan.z = paths[(int)P++].y;

float xT = OperatorObj[i+1].GetPos().x - OperatorObj.GetPos().x;
float zT = OperatorObj[i+1].GetPos().z - OperatorObj.GetPos().z;
float fDir = atan2f(-xT,-zT);


then update transformations

if(m_vRot.x != 0.0f || m_vRot.y != 0.0f || m_vRot.z != 0.0f)
D3DXQuaternionRotationYawPitchRoll(&m_quatRot, m_vRot.x, m_vRot.y, m_vRot.z);
D3DXMatrixTransformation(&m_matWorld, &m_vScaleCenter, NULL, &m_vScale,
&m_vRotCenter, &m_quatRot, &m_vPos);
D3DXMatrixTransformation(&m_matWorld, &m_vScaleCenter, NULL, &m_vScale,
NULL, NULL, &m_vPos);

// check if current object is attach to other object
if(m_pCombineFrameMatrix != NULL)
m_matWorld *= *m_pCombineFrameMatrix;

if(m_pAnimController != NULL && m_bWalking)
// check if loop animation is enable and queue is empty
if(m_pTrackArray[m_dwCurrentTrack].bLoop && m_TrackQueue.empty())
m_pAnimController->SetTime(m_pAnimController->GetTime() + dt);

else // execute first the track waiting on the queue
double dTime = m_pAnimController->GetTime() + dt;
// if the current track is not yet done
if(m_pTrackArray[m_dwCurrentTrack].dPeriod > dTime * m_pTrackArray[m_dwCurrentTrack].TrackDesc.Speed)
m_pAnimController->SetTime(m_pAnimController->GetTime() + dt);

else // the track is done, check the queue
// if there's animation waiting in the queue
m_dwLastTrack = m_dwCurrentTrack;
//m_dwCurrentTrack = m_TrackQueue.front();
m_pTrackArray[m_dwCurrentTrack].bLoop = false;
else // there's none left


UpdateFrame(m_pMesh->GetFrameRoot(), &m_matWorld);


and render

for (int i = 0; i < 5; i++)


Does anyone spot any bugs in my code?
The thing that baffles me is I initially set m_bWalking to false to all instances, then set it to true when pathfinding finishes, I can see
each m_bWalking for each object is different, but when the animation controller is not updating, that character is still moving. While I set m_bWalking to false
5 objects stop instantly.

Share this post

Link to post
Share on other sites
It appears you're using a very old version of DirectX (pre-2005?) so there may not be anyone who can help you. There is some documentation on the web for some of the old calls you have in your code but there may not be anyone that knows much about them. You should consider upgrading to a newer version of DirectX and looking at the multi-animation instancing example there.

Share this post

Link to post
Share on other sites
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!