Rotating camera vertically around point?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dark chazz
Posts: 26
Joined: Tue Nov 11, 2008 5:20 pm

Rotating camera vertically around point?

Post by dark chazz »

Hi.

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);
 
Which works fine.
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!
Post Reply