Jump to content
  • Advertisement
Sign in to follow this  
Anddos

Trying to make the headbone follow a position

This topic is 1824 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 want my animated meshs head to follow a postion,this is the code I have but it dosent seem to be working as expected sad.png

can anyone help?

 

// Start by transforming to local space

D3DXMATRIX Local;

D3DXMatrixInverse(&Local, NULL, &m_pHeadBone->CombinedTransformationMatrix);

 

 

static float PosZ = 5.0f; PosZ += 10.1f;

D3DXVECTOR3 Pos(0.0f,0.0f,PosZ);

 

//angle we want to look at

D3DXVECTOR3 boneVec3;

D3DXVECTOR3 boneSrc(Local._41,Local._42,Local._43);

D3DXVec3TransformCoord(&boneVec3,&boneSrc,&m_pHeadBone->CombinedTransformationMatrix);

D3DXVECTOR3 LookVec = Pos - boneVec3;

D3DXVec3Normalize(&LookVec,&LookVec);

D3DXMatrixRotationX(&Yaw,atan2(LookVec.x,LookVec.z));

m_pHeadBone->CombinedTransformationMatrix = Yaw * m_pHeadBone->CombinedTransformationMatrix;

Edited by Anddos

Share this post


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