Pivot point for 3D rotation

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kparamas
Posts: 17
Joined: Fri Jun 26, 2009 10:00 pm

Pivot point for 3D rotation

Post by kparamas »

Hi,

I want to rotate an object about a pivot point.
Basically I want to set a point based on which the object needs to be rotated.

But,
node->setRotation rotates an object which is not expected.

Please let me know how to do it.

regards,
Kguru
squisher
Competition winner
Posts: 91
Joined: Sat May 17, 2008 2:23 am
Contact:

Post by squisher »

Code: Select all

ISceneNode* pivot;  // the object youre pivoting around
ISceneNode* object;   // the object youre moving

vector3df pos(0, 0, 100);   // starting point, pre-rotation. determines distance from pivot.
matrix4 m;
m.setRotationDegrees(vector3df(12,34,56)); // the desired rotation around the pivot
m.rotateVect(pos);
object->setPosition(pivot->getAbsolutePosition() + pos); // (or, if object is a child of pivot, just setPosition(pos)
Hope this helps?
Post Reply