How to group several objects in order to rotate them as a unit?

I need some pointers to a better approach for the rotation problem in OpenGL. I know how to rotate objects in 3D using quaternions, I can translate them, all is well and good.

But I want to know how best to consider a collection of different objects as a single entity for the purpose of rotation. For example, suppose there is a table with objects on it. Each of them has its own translation and rotation, but now I want to rotate the entire table and everything on it, leaving other objects in the room in place. This means that the objects on the outer edge of the table will rotate, as well as move around the center of the table, while the objects in the center can simply rotate, but otherwise remain in place or simply do not translate as much, depending on their distance from the axis rotation.

It seems that a rather inelegant way to do this is to individually rotate and translate each object onto the table, as well as the table itself, knowing where the axis of rotation is. This may be the only good way to do this, but is there a way to “group” disparate objects for this purpose?

+5
source share
2 answers

What you are looking for are hierarchies. The objects on your table are located relative to the table or, in other words, in the coordinate system of the table. Therefore, let us denote it M_Deskas a transformation that determines the location of the table and the local coordinate system. Then let the M_Pencilboxpencil stand on the table in relation to the table. And the pencil in the pencil box will be placed relative to the pencil box.

, . , , OpenGL, "" ( ).

, M_Desk, 4 × 4, : , , ..

, ,

… · M_Desk · M_Pencilbox · v_Pencil

, - , . . , .

OpenGL , ​​ ( ), , .

, .

+3

- , .

, , node , . node.

, .

. , " " GL . node, node, , .

+3

All Articles