I'm able to rotate any model with any angle I want, where I can not rotate my model around a given point.

e.g: My model rotates from the origin assigned in its .fpx file. I want it to rotate related to a point of its bottom plane, so that it is animated as falling


Here is a way to rotate a Matrix (model) around a specific point :

Vector3 pointToRotateAround = modelWorldTransform.Translation +
                              modelWorldTransform.Down * modelHalfHeight; // modelHalfHeight is meant to represent distance from fbx origin to feet plane

modelWorldTransform.Translation -= pointToRotateAbout;
modelWorldTransform *= Matrix.CreateFromAxisAngle(axis, angle);//angle is the angle to rotate just this frame only
modelWorldTransforms.Translation += pointToRotateAround;

pointToRotateAround can be any Vector3 representing a point in 3d space. Make certain that the axis in the Create Method is unit length or your matrix will distort.

|improve this answer|||||
  • \$\begingroup\$ thanks, i've logined to write the answer (i'm quiting to home back), where i see the answer :) same logic works for a single point, too. \$\endgroup\$ – icaptan Nov 22 '11 at 15:43

You can use CreateFromAxisAngle method from Matrix class. This method will create a rotation matrix about a specific axis for a given angle.


|improve this answer|||||
  • \$\begingroup\$ I could not use it, i've tried and still trying to handle it, but it does not work. is there any sample using that ? it rotates already from its origin does not matter around a point or axis. \$\endgroup\$ – icaptan Nov 22 '11 at 9:41
  • \$\begingroup\$ Finally CreateFromAxisAngle isn't the solution to your problem, I responded too quickly. If you want to rotate around a specific point p, first translate the view matrix of your model to -p, do the rotation and then translate to p. \$\endgroup\$ – Julien Pires Nov 22 '11 at 12:02
  • \$\begingroup\$ Thanks Takumi :) It helped me already, i've learned CreateFromAxisAngle and after all i've solved it same with the Steve H's answer. \$\endgroup\$ – icaptan Nov 22 '11 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.