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

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
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

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

Post 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.
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post 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.
Ein knowledge seeker
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post 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.
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

Post 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.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post 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.
Post Reply