Page 1 of 1

Pivot point for 3D rotation

Posted: Fri Nov 06, 2009 2:14 am
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

Posted: Fri Nov 06, 2009 2:34 am
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?