set/get Pitch, Yaw, Roll

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

set/get Pitch, Yaw, Roll

Post by KungFooMasta »

Currently I have a heirarchy of Nodes for my avatar's yaw, pitch, and roll.

My functional equivalent is calling

SceneNode::setOrientation( SceneNode::getInitialOrientation() );
SceneNode::yaw(...);

I'm not sure how efficient this is.. maybe a more experience Ogre can shed some light?

Also, since I already have a way to accomplish this, I don't need all of the *you can do a workaround by doing xyz..* comments. :wink: I just want to know if my current way is inefficient, is it's possible to implement a get/set yaw/pitch/roll, and how difficult it would be to implement this. Also, I'm not using quaternions.

Thanks for any information!

KungFooMasta
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Orientation ops like this are pretty efficient, and Ogre doesn't derive child updates until later anyway so making each change doesn't cascade. It really depends why you're doing it - the main opportunity for optimisation is not doing it so much, or at all, not in the implementation of it.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

I use "setYaw" all the time for my character controller. The WASD keys are checked if pressed and used to determine the avatar's direction.

I don't have the code with me, but it follows like this:

Ogre::Degree angle = 0;
(checking if two move keys are pressed)
W + D -> -45 degrees
W + A -> 45 degress
S + D -> -135 degrees
S + A -> 135 degrees
(checking if only 1 key is pressed)
W -> 0 degrees
S -> 180 degrees
D -> -90 degrees
A -> 90 degrees

After computing the direction I yaw the avatar
mEntityNode->setYaw(angle + camAngle);

The behavior changes the avatars direction based on the keys pressed (and translates forward after facing the correct direction). Pressing W will set avatar facing north (relative to camera). Pressing S will spin the avatar 180 degrees facing south, etc.

In addition to character movement, my editor allows the user to set the yaw/pitch/roll of objects in the scene. Note that this does not happen as often as the avatar movement, which happens every frame a WASD key is pressed down.
Post Reply