How to force Parent-child transformation calculation

Hi all!
I have doubt. When the transformation of a child due to parent transformation is propagated?
If I move the parent and I check the child transformation (child.getTransform()) I don’t see the transformation due to the parent. To see it I need to wait for a new frame or force with base.graphicsEngine.renderFrane().

I have read that requesting the getTransform() would force this calculation (due to the Lazy characteristic of Panda3d), but it’s not the case. I have tried also with SyncFrame() without success.

So, anyone knows a way to force the transformation calculation of the children due to the parent without forcing a new frame draw?
Thanks!!!

Each nodepath stores its own transformation relative to its parent. If you want a node’s transformation relative to another node, e.g. the parent’s parent, give that other node as the first argument; E.g.: np.get_transform(other_np).

Hi Baribal,
Thanks for the info, but when the transofrmation is calculated for a child when the movement has been done in the parent?

Technically it happens during drawing, when all the transforms between object/camera and root node are multiplied up to yield the Model and View matrices that get passed to the vertex shader.

From an application developer’s perspective, however, it happens never. All nodes have transformations relative to their parents, so if a parent’s transform gets updated, there is no need to update any transforms of the children; They are meant to maintain their relative positions, after all. If you do want a child’s updated transform relative to another node, like the parent’s parent, that is available immediately after you have updated the parent’s transform, as I laid out earlier.

If that seems to be a problem, it may be a good idea to take a step back and ask: What is it that you are trying to achieve right now?

Hi!
I’m trying to set the rotation of all my bones depending in external sensors.
When I have the desired rotation read I set it to all my bones (controlled join).
To be able to set in the children bones referenced to render, I have my controlled children joints reparented to the parent _exposed joint (I have another chat where I commented this issue and the final solution).
My issue actually is that when I set the position on the parent and on the children (referenced to render), the children finish in the position I have defined + the rotation applied due to parent movement.
For example:

  • Initial parent and children rotation (0,0,0)
  • I set parent to (10,0,0) (parent.setHpr())
  • I set children to (5,0,0)
  • The next frame the parent is at (10,0,0), and the children at (15,0,0) from render.
    If I force the render between parent set and children set, I can set the children in my desired position, but it means that I have rendered one frame with the children at (10,0,0) and the next one at (5,0,0).
    I have tried to force the transform calculation of the children, to be able to modify before it’s applied to render, but I have not find a way to do it, so when I move the parent and I check the transformation of the children (referenced to render), it still don’t have the transformation due to parent movement.
    Not sure if now is more clear or I have mixed it more… sorry.
    Thanks!

So you have a rotation for each bone as your input data, but they are all, for lack of a better word, in world space, and you instead need them in each bone’s local space?

I would guess that the problem is that a node associated with an exposed joint is a bit unusual, in that I imagine that it receives explicit updates in order to reflect the state of the joint with which it’s associated.

I imagine that these updates are done once per engine-tick.

Looking at the Actor class, I see that it has an “update” function, which updates the joints of the Actor. Perhaps said updating includes the updating of any NodePaths associated with the joints via “exposeJoint”?

(If it doesn’t work initially, I’d suggest trying the optional “force” parameter. But try it without, first.)

If that doesn’t work, perhaps you could try re-exposing the joint after setting its rotation?