View Full Version : Centering the pivot of a GL obj that has already been transformed with GLM?

07-26-2014, 07:57 PM
I have an object at (0,0,0) whose pivot point I moved to an arbitrary location. I then rotated or scaled it to an arbitrary value. My initial modelMatrix is:

rotationM = glm::toMat4(glm::quat(glm::radians(r->val_3)));
pivAxis1M = glm::translate(glm::mat4(), -pivot->val_3);
pivAxis2M = glm::translate(glm::mat4(), pivot->val_3);

modelM = translationM * pivOffset1M * rotationM * scaleM * pivOffset1M;

I want to center the pivot of the object so the pivot point is at the logical spot aka transformed bounding box center while keeping every attribute on the object that's visible to the user the same AND keeping the object in the same place / rotation / scale - like they do in every 3d app. I have only been successful when my rotation and scale values are zero, but that is unacceptable.

07-27-2014, 05:17 PM
I'm specifically talking about something called the "Rotate Pivot Translation" like they talk about in the Maya Api. Any help on how this works in OpenGL?

Rotate pivot translation translation introduced to preserve exisitng rotate transformations when moving pivot. This is used to prevent the object from moving when the objects pivot point is not at the origin and the pivot is moved. [Rt]