I'm looking for the best way to center and offset a rotation pivot on an object using openGL shaders. There are differences in 3d apps in how they handle this.
I have an object which I set translation to (0,2,2), rotation to (90,0,0) and move the pivot to (5,2,0) and then rotate (or not) arbitrarily. Then I want to "center the pivot" on the object to the translated bb center
I've tried variations of this modelMatrix without success in all scenarios where pivRT is the difference to the BBcenter:
modelM = translationM * pivRT * glm::inverse(pivotM) * rotationM * scaleM * pivotM;
In Maya
I "center the pivot" on the object and no values visible to the user change. In other apps such as blender the translation changes when you center the pivot - in fact your objects translation becomes the pivots translation. Reading up on how this works, in the xform command or MTransformationMatrix class, Maya has the transformation matrix as
[Sp]x[S]x[Sh]x[Sp]x[St]x[Rp]x[Ro]x[R]x[Rp]x[Rt]x[T]
with Rt being the "Rotate pivot translation" matrix which is translation introduced to preserve exisiting 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]
I believe this rotate pivot translation matrix works and is more intuitive than in blender where the translation values change but I have trouble implementing either.