Page 1 of 1

Third-person camera pitch and yaw

Posted: Wed Jan 26, 2005 3:45 pm
by Dr Dave
I'm looking for some help with my third person camera that I'm implementing. I've built the camera system up as specified elsewhere in the forum:

R
|
A --- T
|
B --- C

Where R is RootNode, A and B are SceneNodes, T is the Target (Avatar) and C is the Camera.

The B can be yawed, so that the camera turns around the avatar, while still looking at it. Likewise it can be pitched up and down too. The trouble comes when doing both of these movements together. The camera moves unpredictably, and is difficult to control. The code is like this:

Code: Select all

mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13);
mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13);

mCamNode->pitch(mRotY,Node::TS_PARENT);
mCamNode->yaw(mRotX,Node::TS_PARENT);
what i end up with is this

Image

Any help would be greatly appreciated.
P.S. I'm using BSPs so the Z axis is vertical, not the Y.

Posted: Wed Jan 26, 2005 4:54 pm
by haffax
Apply pitch to B and yaw to A. This is probably what you want. At least it is, what I use in our project. :)

Edit: I'm not sure, if T and C are seperate nodes in your setup, or just movables attached to A and B. If not, make them seperate nodes. I found it nice to place A in height of the character head's centre.

Posted: Wed Jan 26, 2005 5:00 pm
by Cyberdigitus
Oh, that environment mockup looks dead cool. Inspired by hammer eh ?

Posted: Wed Jan 26, 2005 9:08 pm
by Dr Dave
Thanks for your suggestion. I've actually managed to fix the problem by changing the implementation of the SceneNodes a little, as described here. It now uses two seperate SceneNodes for pitching and yawing, and the camera then has its own node.

(I did take the idea for the environment mock-up from Hammer, thought it looked kind of cool myself)