how to rotate all objects by their own centers and then translate them to the real position (it isn't working)

前端 未结 1 361
感情败类
感情败类 2020-12-11 12:26

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

相关标签:
1条回答
  • 2020-12-11 13:19

    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 matrix
    • rotation_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 down

    pith,yaw,roll are then object local rotations around x,y,z

    0 讨论(0)
提交回复
热议问题