[font="arial, sans-serif"]
[font="arial, sans-serif"]So:
[font="arial, sans-serif"]
void SKINNEDMESH::UpdateMatrices(bool bones, BONE* bone, D3DXMATRIX *parentMatrix)
{
if(bones)
{
if(parentMatrix != NULL)
{
if(bone->Name != NULL && strcmp(bone->Name,"Bip01_L_UpperArm")==0)
{
D3DXMATRIX ident;
D3DXMatrixIdentity(&ident);
D3DXMATRIX final = bone->TransformationMatrix*(*parentMatrix);
D3DXVECTOR3 boneLocation(final._41,final._42,final._43);
D3DXVec3Project(&boneLocation,&boneLocation,&m_vp,&m_pm,&m_vm,&ident); // use YOUR viewport, projection and view matrices in this call
D3DXVECTOR3 dir = mouseLocation - boneLocation;
if(mouseLocation.x > m_Width/2)
{
float offset = D3DX_PI/2.0f;
float angle = offset - atan2(dir.y,dir.x); // change this when you rotate the model
D3DXMATRIX rot;
D3DXMatrixRotationY(&rot,angle);
bone->CombinedTransformationMatrix = rot*final;
}
else
{
float offset = -D3DX_PI/2.0f;
float angle = offset + atan2(dir.y,dir.x); // change this when you rotate the model
D3DXMATRIX rot;
D3DXMatrixRotationY(&rot,angle);
bone->CombinedTransformationMatrix = rot*final;
}
}
else
{
D3DXMatrixMultiply(&bone->CombinedTransformationMatrix,
&bone->TransformationMatrix,
parentMatrix);
}
}
else
bone->CombinedTransformationMatrix = bone->TransformationMatrix;
if(bone->pFrameSibling)
{
UpdateMatrices(bones, (BONE*)bone->pFrameSibling, parentMatrix);
}
if(bone->pFrameFirstChild)
{
UpdateMatrices(bones, (BONE*)bone->pFrameFirstChild, &bone->CombinedTransformationMatrix);
}
}
else
{
if(bone != NULL)
D3DXMatrixMultiply(&bone->CombinedTransformationMatrix,
&bone->TransformationMatrix,
parentMatrix);
else
bone->CombinedTransformationMatrix = bone->TransformationMatrix;
if(bone->pFrameSibling)
UpdateMatrices(bones, (BONE*)bone->pFrameSibling, parentMatrix);
if(bone->pFrameFirstChild)
UpdateMatrices(bones, (BONE*)bone->pFrameFirstChild, &bone->CombinedTransformationMatrix);
}}
[font="arial, sans-serif"]
[font="arial, sans-serif"]But he does not move properly in the direction that the mouse cursor is, why?
[font="arial, sans-serif"]as, I move the mouse, it moves very little, but in reverse (back)
[font="arial, sans-serif"]
[font="arial, sans-serif"]Thanks
[font="arial, sans-serif"]
[font="arial, sans-serif"]I'm sending a video to youtube with my problem, wait