Getting the absolute position and rotation from inside the scene graph?

So, I came across this problem several times:

I have some kind of object in my 3D scene graphic that is a child of some other object. Lets call them c (Child) and p (Parent).

c position is relative to p. Thus, c may have a position (1,0,0), but, of course, due to the fact that p has some other position, say (1,2,3), it does not actually appear in the original of our world, but at (2, 2,3).

Now let's say, for some reason, we want to know the absolute position in world coordinates (or rotation, the problem is the same), as is usually done?

Should c be aware of this parent and be able to request this position and add it to its own, finally returning the absolute position?

+1
source share
2 answers

Converting coordinates into a child coordinate system into a global coordinate system is one of the things that are needed to actually display a scene graph, so this is a reasonable thing.

How you do this will depend on the graphics library used. Often each node in the scene graph will contain a matrix that converts this node coordinate system to global coordinates. This matrix is ​​calculated by multiplying the matrix by the parent node by the transformation matrix from the original coordinates to child coordinates, or vice versa, depending on how things are defined.

, , node. , .

+4

, , . , , , - , .

, , , . , . , 3D- , (4x4) , , .

+1
source

All Articles