Page 1 of 1

Getting the 3rd person's camera's direction.

Posted: Tue Mar 24, 2009 8:31 am
by Linaxys
Hello,
I would like to rotate my character automatically at the coordinates that the camera is facing at, only in the Y axis, like this :

- Before, I have just rotated my camera (Circle = character, Square = Camera) :

Image

- After, I want to move forward :

Image

Sooo, what can I do please ?

Thanks.

Posted: Tue Mar 24, 2009 10:07 am
by Ein
you might need to use something like camera->getTarget and then change the position of your circle to that with a delay maybe.

Posted: Tue Mar 24, 2009 10:35 am
by Nox
Hi, how experienced are you with c++? A "easy" and correct way is to implement this as a IAnimator and attache it to the circle.

Posted: Tue Mar 24, 2009 5:11 pm
by Linaxys
Hey guys, thanks for your replies.

Hmm I currently want that cube rotates it's Y axis to the camera's Y axis only when I press the mouse's right button, I am updating the camera's position to get it around the character like this, with the famous sphericalXYZ function :

Code: Select all

vector3df sphericalXYZ(float compassAngle, float elevationAngle, float radius){

   compassAngle = compassAngle * -1;
   elevationAngle = elevationAngle * -1;

   elevationAngle = elevationAngle + 90;

   float x = radius * cos(compassAngle * PI/180.0f ) * sin(elevationAngle * PI/180.0f );
   float z = radius * sin(compassAngle * PI/180.0f ) * sin(elevationAngle * PI/180.0f );
   float y = radius * cos(elevationAngle * PI/180.0f );

   vector3df result;
   result.X = x;
   result.Y = y;
   result.Z = z;
   return result;
} 
But I don't really have any idea to get the Camera's Y rotation value to transmit it inside the cube, maybe with the target, I've already tried with getHorizontalAngle, I don't really understand how to use it...

Thanks for your help.

Posted: Tue Mar 24, 2009 5:16 pm
by Nox
Err well. Get the rotation of the cam and set it to the node. If your node and your camera are not children of any transformed node it should work fine. AND if you use a "normal" camera you may have to call bindTargetAndRotation.