Sign in to follow this  
Anddos

Trying to make the headbone follow a position

Recommended Posts

Anddos    588

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

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