Rotation around specified centre

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
Abraxas
Posts: 57
Joined: Mon Nov 07, 2005 3:56 pm

Rotation around specified centre

Post by Abraxas »

Hello,

well, possibly for you easy to answer, in spite of me: :wink:

I want to let meshes rotate around a specified centre, which will be defined (another mesh, e.g.)and will have to change this centre point sometimes.
Also I should have to define the radius and the angle of the rotation.

Is there any pre-defined action in irrlicht to do that?
Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

thingpos = pivotpos + (thingPos - pivotPos).rotateXYBy(whatever)
or whatever
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Not that I know of. I would just use some polar coords and some angle math.

I dont think its too complicated.

But that coming from a guy who loves math doesnt help ^_^
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

The fastest way is to subtract the point that represents the center of rotation from the position of the node. Then, do normal rotation and then add back the position of the rotation point. For example :

Code: Select all

core::vector3df pivotPoint( 100, 100, 100 );
core::vector3df tempPos = node->getPosition();
tempPos -= pivotPoint;
core::matrix4 rotMat;
rotMat.setRotationDegrees( core::vector3df( 45, 45, 45 ) );
rotMat.rotateVect( tempPos );
node->setPosition( tempPos + pivotPoint );
Note: you may have to call setInverseRotationDegrees, instead of setRotationDegrees.

I don't know what you mean by radius. What does the radius have to do with rotation? I guess, the radius of the rotation is the distance from the pivotPoint to the position of the node. But it's not needed in this case.
Image
bearSoft
Posts: 165
Joined: Fri Apr 01, 2005 9:55 pm
Location: Denmark

Post by bearSoft »

the radius imply that Abraxas want an -orbit- around an instance (pivotpoint)
i know the formula -but there is also the rotationAnimator..
Wouldent it be the simplest way?
The gfx tut has an orbitting light source..
but change it in game loop..
hmm.. :shock:
Regards.
Tech: win98se| 320mb ram| abitbe6| 433mhzceleron| atiRadeon7000.64mb| soundblaster125| dx9.0b | devCPP | IRR 0.12.0 |
genesisrage
Posts: 93
Joined: Tue Feb 08, 2005 12:19 pm

Post by genesisrage »

i havent tried this with irrlicht, but some other engines ive used will actually rotate an object around the stored pivot point (that can be moved in max). does irrlicht use that info, or does it just set the pivot point at the center of the model?
Post Reply