What is the way to make all the objects that are not aligned with the origin center (vector3(0.0f,0.0f,0.0f)) , rotate about its own central axis?
the problem in pse
if you want to rotate object locally to its own coordinate system then do this:
M=inverse(inverse(M)*rotation_matrix);
M
is your object transform matrixrotation_matrix
is any rotation (glRotate()
)inverse
is function that computes the inverse matrix you can use mine inverse matrix computation or this rotation around LCS x (lrotx) implementation in C++ (at the bottom of the answer)[edit1] more about relation between M and object which coordinate system it represents
look here: transform matrix anatomy
M
origin is usually the middle of object (or point which is center of rotation movements). Axises of M
are usually aligned with object for example in airplanes the X
axis is usually the fly direction. I am more used to:
+z
axis as forward direction movement+x
as right, -x as left+y
as up and -y as downpith,yaw,roll
are then object local rotations around x,y,z