Third-person camera pitch and yaw

Problems building or running the engine, queries about how to use features etc.
Dr Dave
Gnoblar
Posts: 9
Joined: Wed Jan 26, 2005 3:28 pm

Third-person camera pitch and yaw

Post 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.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8

Post 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.
Last edited by haffax on Wed Jan 26, 2005 5:10 pm, edited 1 time in total.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
Cyberdigitus
Halfling
Posts: 55
Joined: Thu Mar 04, 2004 7:08 pm
Location: Belgium

Post by Cyberdigitus »

Oh, that environment mockup looks dead cool. Inspired by hammer eh ?
. . .
Dr Dave
Gnoblar
Posts: 9
Joined: Wed Jan 26, 2005 3:28 pm

Post 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)