Basic Scene Node Rotation?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Basic Scene Node Rotation?

Post by thesmileman »

Havent got a clue how to rotate an object in small increments around the objects center in one dimension aka a person turing in place.

I thought the code below would work but I am not sure what point it is rotating about it is certainly not (0,0,0)

Code: Select all

if(keys[KEY_KEY_U]){
   core::vector3df v = paddle1Node->getRotation();
   v.Z += 1.0f;
   paddle1Node->setRotation(v);
} 
So is there a way to set this point of rotation? I would assume so.

I know there are some other post dealing with rotation but they did not seem to apply. Thanks!
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Anyone out there that can help me?
Guest

Re: Basic Scene Node Rotation?

Post by Guest »

Hi,

rotation: is alway about the center of origin of the scenenode. that is, if you load a mesh , lets say cube that is placed in the positive half of all axis, then a rotation will look like you are rotating around a side and not around the center of the cube. so you'l have to translate the cube to have the center at the origin (0,0,0) before rotating? hm.. never tried that... but this should be correct.

the orientation of things: if you use a standard camera scenenode (FPS- Maya- etc.) then a rotation around the upward axis of a model will be the rotation in XZ plane and the parameter you'l want to adjust is the Y-component of the rotation.

setting the axis of rotation: hmmmm... should be easy with the quaternion class in the new release (0.5) I don't know if there is a method for it so here's the code from my class:

Code: Select all

void Quaternion::FromAngleAxis (const Real& rfAngle,const Vector3& rkAxis)
{
	// assert:  axis[] is unit length
	//
	// The quaternion representing the rotation is
	//   q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k)

	Real fHalfAngle = 0.5*rfAngle;
	Real fSin = Math::Sin(fHalfAngle);
	W = Math::Cos(fHalfAngle);
	X = fSin*rkAxis.X;
	Y = fSin*rkAxis.Y;
	Z = fSin*rkAxis.Z;
}
If you don't know about quaternions here's an introduction to it
http://www.magic-software.com the doc title to search for is 'Quaternion Algebra and Calculus' by David Eberly.

good luck
42
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Thanks 42 for the help but I am a little confused about how to use what you have said. Could you explain how to use Queaternion or another method in Irrlicht?
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Re: Basic Scene Node Rotation?

Post by rt »

thesmileman wrote: I thought the code below would work but I am not sure what point it is rotating about it is certainly not (0,0,0)

Code: Select all

if(keys[KEY_KEY_U]){
   core::vector3df v = paddle1Node->getRotation();
   v.Z += 1.0f;
   paddle1Node->setRotation(v);
} 
it's not rotation about a point, it's rotation about an axis. in your example code you are rotating the object around the z-axis.
Post Reply