[Solved] Rotating scenenode issues

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

[Solved] Rotating scenenode issues

Post by kubatp »

Hi,
I really hope that someone will help me with this, because I simply cannot figure it out and it is getting a bit desperate :(

I am trying to develop bird's flight.
I use SceneNode.Yaw to rotate the bird around Y axis
yaw.png
I use SceneNode.Pitch to rotate the bird around X axis
pitch.png
I use SceneNode.Roll to rotate the bird around Z axis
roll.png
I should point out that I am using degrees when dealing with the rotations, the most important rotations around Y should work like this

Image

I should also point out that I am using my own method for rotation

Code: Select all

public static void Rotate(this SceneNode node, Vector3 rotationVector)
{
	if (rotationVector.x != 0)
	{
		node.Pitch(new Degree(rotationVector.x).ValueRadians, Node.TransformSpace.TS_LOCAL);
	}

	if (rotationVector.y != 0)
	{
		node.Yaw(new Degree(rotationVector.y).ValueRadians, Node.TransformSpace.TS_PARENT);
	}

	if (rotationVector.z != 0)
	{
		node.Roll(new Degree(rotationVector.z).ValueRadians, Node.TransformSpace.TS_LOCAL);
	}
}
What I want to achieve is to pass to the Rotate method the vector of rotations, which would independently roll, pitch and yaw the bird.

Unfortunately there are few issues I am having with the rotations:
  1. It seems like roll, pitch and yaw somehow relate to each other. When I call Yaw with specific number and the other two (pitch and roll) are both 0, it works fine. Once they (pitch or roll) are changed it doesnt correctly yaw the scenenode.
  2. Is there a way how to get the rotation on Y axis? I thought that this would - sceneNode.Orientation.Yaw.ValueDegrees - is it, but it doesnt work correctly. For example, when there are no changes in pitch and roll, current rotation on Yaw is 29 degrees and I call Rotate function with 152 degrees in Y, it should return -179 degrees, but it returns -1. Why?
  3. What should I do to get the functionality that whatever the pitch and roll is, when I call Rotate(0,30,0) it will change the rotation on Y axis about 30 degrees?
Thank you very much for your help. I was really trying to find an answer in other threads but without luck :-/
Last edited by kubatp on Mon Jan 30, 2017 5:43 pm, edited 1 time in total.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Rotating scenenode issues

Post by frostbyte »

just improvising an answer( i did'nt mess much with this helper function )
1) maybe try NODE->_update() after doing any transform( e.g yaw, update, pitch update,roll update)
2)why do you use TS_PARENT on y-axis while TS_LOCAL on x,z axis? they should be all the same, no?
3)29+152=?( hint...its not 179 :wink: )
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Rotating scenenode issues

Post by kubatp »

Hi Frostbyte, thank you for the answer.
frostbyte wrote:1) maybe try NODE->_update() after doing any transform( e.g yaw, update, pitch update,roll update)
I am using Mogre (Ogre 1.7.4), so there is no need to call update functions.
frostbyte wrote:2)why do you use TS_PARENT on y-axis while TS_LOCAL on x,z axis? they should be all the same, no?
When I use TS_PARENT for pitch and roll the bird doesnt do the rotations I described in pictures.
frostbyte wrote:3)29+152=?( hint...its not 179 :wink: )
Yes, that is the point. It is 181, which is -179, but it returns -1
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Rotating scenenode issues

Post by kubatp »

What I need is basically this http://www.ogre3d.org/forums/viewtopic.php?f=2&t=77710 but for all three axis together (not just for Y rotation)
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Rotating scenenode issues

Post by kubatp »

Maybe one more thing to add to explain, what I mean by independent rotations.
I need to find a way how to call this:

Code: Select all

Rotate(new Vector(0,45,0));
Rotate(new Vector(0,0,45));
Rotate(new Vector(45,0,0));

Rotate(new Vector(0,-45,0));
Rotate(new Vector(-45,0,0));
Rotate(new Vector(0,0,-45));
and get the same orientation as there was at the beginning. Please notice different order of the vectors.
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: Rotating scenenode issues

Post by Zonder »

This should make things easier for you http://www.ogre3d.org/tikiwiki/Euler+Angle+Class
There are 10 types of people in the world: Those who understand binary, and those who don't...
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Rotating scenenode issues

Post by kubatp »

Zonder wrote:This should make things easier for you http://www.ogre3d.org/tikiwiki/Euler+Angle+Class
Zonder, thank you very much!
This is exactly what I needed.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Rotating scenenode issues

Post by Kojack »

Your code looks like c#, in which case there's http://www.ogre3d.org/tikiwiki/tiki-ind ... lass+Mogre
It's a c# version of the http://www.ogre3d.org/tikiwiki/Euler+Angle+Class c++ class.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Rotating scenenode issues

Post by kubatp »

Kojack wrote:Your code looks like c#, in which case there's http://www.ogre3d.org/tikiwiki/tiki-ind ... lass+Mogre
It's a c# version of the http://www.ogre3d.org/tikiwiki/Euler+Angle+Class c++ class.
Hi Kojack, it is C# indeed. I already found that page, it was a nice surprise which saved me some time. I was ready to transform it to C#, but it wasnt necessary:)

Anyway, I have noticed that you are one of the authors. I want to say big thank you!
Post Reply