Page 1 of 1

How to realize rotation in two steps

Posted: Mon Nov 06, 2006 6:04 pm
by Magnet
How to realize rotation in two steps?

I need to rotate object as presented on scheme.
Image

Posted: Mon Nov 06, 2006 6:13 pm
by JP
I think this is basically what i've been trying to do today.

What i wanted to do was to rotate my node backwards, on the x axis, and also at the same time rotate it on the y axis so it spins around. But the result i got was for it to spin around wildly, not how i wanted it to. I think i realise why it does this. it firstly rotated on one axis and then rotated on the next without "resetting" the axis so the next rotation would not be affected by the previous one... I'm not sure if that will make sense to anyone :lol:

I'm not sure if i've got some code that i've done before which would take care of this problem or not but it's just confusing me quite a lot :lol:

Posted: Mon Nov 06, 2006 6:41 pm
by vitek
First off, the images show a rotation along Y and then a translation along Y. I don't see two rotations.

If you want to do multiple rotations, you should be able to create a matrix for each, and then apply them to a final composite matrix...

Code: Select all

core::matrix4 m;
m.makeIdentity();

// later
core::matrix4 r1;
r1.setRotationDegrees(core::vector3df(0, 135, 0));

// later
core::matrix4 r2;
r2.setRotationDegrees(core::vector3df(90, 0, 0));

m *= r1;
m *= r2;

Posted: Mon Nov 06, 2006 6:45 pm
by JP
Do you then apply the matrix to the node by applying it to getAbsoluteTransformation() ?

Posted: Mon Nov 06, 2006 7:07 pm
by bitplane
you can just use node->setRotation(m->getRotationDegrees())

Posted: Tue Nov 07, 2006 9:23 am
by Magnet
Hm. Senks.
I realize this task with another "funny" method ^-)
I am create one more scenenode and put my node there.
After I am rotate parent scenode and my scenenode :-)

I am find scenenode matrix but not found it :-) I am not guess to create new matrix :-)

Thanks!

Posted: Fri Nov 17, 2006 7:51 pm
by itzjac
Hi to all!!!

Are you toalking about a similar GoogleEarth interface? because I'm looking for that kind of movement only for one of the nodes on my scene, there are lots of other nodes on my scene but only one has to do that behavior :shock:

Posted: Thu Nov 30, 2006 7:11 pm
by Warren
Hi!

I have a problem using this stuff:

Code: Select all

     core::matrix4 m;
     m.makeIdentity();
     
     // later
     core::matrix4 r1;
     r1.setRotationDegrees(core::vector3df(0
                            , node->getRotation().Y+roll_inc)
                            , 0));

     // later
     core::matrix4 r2;
     r2.setRotationDegrees(core::vector3df(0, 0, 30));
     
     m *= r2; 
     m *= r1;
     
     node->setRotation( m.getRotationDegrees() ); 
I want to rotate the direction of my node using the keyboard, so I plus the roll_inc variable to the Y angle. And then, keep a constant inclination at the Z angle.
This code make a rare behavior,
the r1 matrix´s Y component ranges between [272,271,....,0,1,....82] and do not exceeds that limits (272-82)

Besides it I do not obtain the result of doing a rotation in two steps,
the results are the same that making the common rotation

node->setRotation( vector3df( 0, node->getRotation().Y+roll_inc, 30) );


I hope that i explain myself,
Tnx in advance!!