Acid_Gambit
21-03-2007 12:49:20
It's probably a very simple question to answer but I can't seem to figure it out.
I have a character and a camera tracking it. The scene node has auto tracking enabled and it works fine. But now I have it attached to an ogre newt body and I want to make it look at the character again.
How do I get the right quaternion value when I know the camera's current position and that of the target?
nikhil
22-03-2007 06:55:49
Acid_Gambit
22-03-2007 08:17:58
Well, the camera is attached to the body. But that's not really an issue. I want to use setPositionOrientation() on the ogrenewt body. I have the position of the object it is supposed to look at (a normal ogre scene node). But now I want to calculate the right quaternion value (for the ogrenewt body that is tracking the target) using the ogrenewt body vector and the target object vector.
It's for a 3rd person camera system by the way.
In short: how to get a quaternion value using two vectors (if that's even possible).
nikhil
22-03-2007 20:57:06
Oh!, I think I get it now. You lost the 'setAutoTrack' functionality with newton body around your camera or atleast you don't want to autoTrack coz that will leave the newton body for the camera behind. Right?
So one way you can've your camera follow is to look up the kinds of joints available and try and see if one will suit your purpose (probably 2D rigid joint of some kind from prebuilt custom joints in ogrenewt).
or just get the orientation of the your player. Assuming you want the camera to be Y units above player head and Z units behind the player. do this
camPos = playerOrient* Vector3(0,Y,Z);
camBody->setPosOrient(camPos, Quat::Identity);
//Now to make cam look at the player?
cam->lookAt(playerPos);
I've not tried it, but i think it might work for you. Usually Y and Z will b +ve.
regards
well, I'm using AutoTracking with a node that is inside a newton body, And it's working, but my camera is not attached to the node of the body I'm tracking of, try not to attach it too.