Original Post
I'm trying to create a chase camera. For this i created a structure to get orientation of character.
and i'm updating my camera in my loop like below.
now my problem is im trying to rotate my character around y axis and if i do this as below it works
but if i use tmatrix.Look() in UpdateCamera function it rotates reverse. By the way my character's first direction is (0, 0, 1)
and lastly i tried to give angle pi/2 so my transform matrix become
[0 0 -1 0]
[0 1 0 0]
[1 0 0 0]
[0 0 0 0]
and when i transform my direction vector which is (0, 0, 1) with this i get (1, 0, 0, 1). But shouldn't multiplying (0, 0, 1) with this matrix give me (-1, 0, 0, 1)?
Sorry if this is a little messy message and thanks for the answers.
struct TransformMatrix
{
D3DXMATRIX transform;
D3DXVECTOR3 Right()
{
return D3DXVECTOR3(transform._11, transform._21, transform._31);
}
D3DXVECTOR3 Up()
{
return D3DXVECTOR3(transform._12, transform._22, transform._32);
}
D3DXVECTOR3 Look()
{
return D3DXVECTOR3(transform._13, transform._23, transform._33);
}
void SetTransform(D3DXVECTOR3 Right, D3DXVECTOR3 Up, D3DXVECTOR3 Look)
{
D3DXMatrixIdentity(&transform);
transform._11 = Right.x; transform._21 = Right.y; transform._31 = Right.z;
transform._12 = Up.x; transform._22 = Up.y; transform._32 = Up.z;
transform._13 = Look.x; transform._23 = Look.y; transform._33 = Look.z;
}
};
and i'm updating my camera in my loop like below.
void Camera::UpdateCamera(D3DXVECTOR3 targetDirection, D3DXVECTOR3 targetUp)
{
position = target - (targetDirection * offset);
D3DXMatrixLookAtLH(&view, &position, ⌖, &targetUp);
}
now my problem is im trying to rotate my character around y axis and if i do this as below it works
angle += 0.01f;
D3DXMatrixRotationY(&tmatrix.transform, angle);
D3DXVECTOR4 vecT;
D3DXVec3Transform(&vecT, &direction, &tmatrix.transform);
camera->UpdateCamera(D3DXVECTOR3(vecT.x, vecT.y, vecT.z), D3DXVECTOR3(0, 1, 0));
dxdevice->GetDevice()->SetTransform(D3DTS_VIEW, &camera->GetView());
dxdevice->GetDevice()->SetTransform(D3DTS_WORLD, &tmatrix.transform);
but if i use tmatrix.Look() in UpdateCamera function it rotates reverse. By the way my character's first direction is (0, 0, 1)
and lastly i tried to give angle pi/2 so my transform matrix become
[0 0 -1 0]
[0 1 0 0]
[1 0 0 0]
[0 0 0 0]
and when i transform my direction vector which is (0, 0, 1) with this i get (1, 0, 0, 1). But shouldn't multiplying (0, 0, 1) with this matrix give me (-1, 0, 0, 1)?
Sorry if this is a little messy message and thanks for the answers.