I'm using this code in the game loop to rotate the camera horizontally around my character node:
Code: Select all
if(rotateCamera == true)
{
if(touchPoint.x > 0.0f) {Rotation = core::vector3df(0.0f, GetIrrlichtManager()->GetScene()->getActiveCamera()->getRotation().Y, 0.0f);}
else if(touchPoint.x < 0.0f) {Rotation = core::vector3df(0.0f, GetIrrlichtManager()->GetScene()->getActiveCamera()->getRotation().Y*-1.0f, 0.0f);}
//touchPoint is the 2D coordinates of the player's touch on the display (this is a mobile game)
Rotation.normalize();
matrix4 mat;
mat.setRotationDegrees(Rotation);
mat.rotateVect(CameraOffset);
}
// later in the loop
GetIrrlichtManager()->GetScene()->getActiveCamera()->setTarget(Node->getPosition());
GetIrrlichtManager()->GetScene()->getActiveCamera()->setPosition(Node->getPosition() + CameraOffset);
However, I'm having trouble adapting the same code to rotate the camera vertically taking into account the angle at which the camera is looking at the character node.
I assume the X and Z values of the rotation vector must have different values depending on the camera angle?
Help please!