Hello guys
Firstly,
The model I am using has the front facing the positive x,
with the local and world axis aligned which are also pointing positively to +x
For the code snippet below,
the direction obtained from the cpf_path is correct only when
I don't use spherical interpolation for the Quaternions
Say on reaching the goal, the agent is facing 1.57 in DirectX convention.
When I did the following, the agent is sliding sideways.
So the dirs are correct even though the code snippet below isn't.
Please help me fixing this code...
Trying it for a couple of hours without success....
Thanks
Jack
float startDir = m_cpf_path.at(pathIndex).dir;
float endDir = m_cpf_path.at(pathIndex + 1).dir;
D3DXQUATERNION startQuat;
D3DXQUATERNION endQuat;
D3DXQuaternionRotationAxis(&startQuat, &D3DXVECTOR3(0, 1, 0), startDir);
D3DXQuaternionRotationAxis(&endQuat, &D3DXVECTOR3(0, 1, 0), endDir);
D3DXQUATERNION instantQuat;
D3DXQuaternionSlerp(&instantQuat, &startQuat, &endQuat, m_fS);
D3DXMATRIX instantMat;
D3DXMatrixRotationQuaternion(&instantMat, &instantQuat);
D3DXVECTOR3 instantVec = GetLookVector(instantMat);
xRot = instantVec.x;
D3DXVECTOR3 GetLookVector(const D3DXMATRIX& matWorld) // Also called Forward vector or Direction vector, this is the vector from the object's world matrix
{
return D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);
}