Saving/loading poses for objects with off-zero center point not working

Issue #1714 resolved
Rakete created an issue

In node.updateMatrices you calculate the object transform and as far as I can tell the code correctly takes center_point into account. The result is that an imported node with an off-zero center point ends up at the correct location in blender, with the origin of the object at the location within the object where center_point is in Daz.

However in Daz the center point and the transformation of the object are independent of each other, meaning I can have an object at 0,100,0 with a center at 0,50,0 which then results in an object at 0,0,1.5 in blender. That is visually the correct location, but it is problematic for the code that saves and imports poses, since you don’t take the center_point into account there.

Meaning if I have that object at 0,100,0 and I save a pose, I get a pose preset that moves it to 0,0,1 in blender, which is wrong. Same for the other direction, if I save a pose for the blender object at 0,0,1.5 and use it in Daz, it moves the object to 0,150,0.

Comments (14)

  1. Rakete reporter

    Actually, testing this in a simple scene it turns out that I am wrong, but I have an object where this problem is occuring, I will need to investigate more what is actually the problem it seems.

  2. Rakete reporter

    Alright, the problem is real, and not just imagined. When I just add a primitive to the scene, and put the origin at the center of the object, then Diffeo actually takes that into account correctly (EDIT: tested it again to try and find out where diffeo takes it into account, and it didn’t work then, so no idea why I thought it was working). But when I manually edit the center_point in Daz, and import that into Blender, then I get the problem I described above. I attached a simple scene with a test pose. If you import that scene into Blender and apply the pose, it moves the object down so the origin is at 0,0,0 (the pose simply zeros the location). It should just stay where it is though.

  3. Alessandro Padovani

    That is something very odd.

    If you load your test scene in daz studio you see that the pivot is changed, that you probably did with the joint editor. But daz studio is not reporting the new pivot coordinates, they are zero even if the pivot is about one meter above the ground.

    In blender when you change the pivot the new pivot coordinates are reported in the transformations. This is also the same in daz studio that correctly reports the pivot coordinates for any object. Apart your example. Probably there is another step to do to set the pivot in daz studio apart changing it in the joint editor. Otherwise daz studio doesn’t register the new pivot coordinates.

    I don’t think this is a bug in the addon, but rather something you miss to do in daz studio to set the pivot. Even if the scene in this “intermediate state“ is not correctly read by the importer. That is, you need to set the pivot in daz studio so that daz studio correctly reads the new pivot coordinates. That you didn't.

  4. Rakete reporter

    I tried things like setting the center_point in Daz as default, which you can do via Daz script with: node.setOrigin(new DzVec3(0, 100, 0), makeDefault=true); and it didn’t really help. I don’t really now what else to do and I’ve run into this problem while trying to import scenes from the Daz store that change the center_point in this way, so it is something that the addon should ideally deal with.

    I think in Daz just uses that center_point differently then blender uses the origin, in Daz the center_point is only used for the rotation, but not the translation maybe? It’s as if there is an implicit bone in the object that you can edit with the joint editor, where center_point is head and end_point is tail.

    EDIT: Yeah, that Daz shows the transform as 0,0,0 is pretty much the problem, Blender uses center_point as offset, Daz does not, so no poses work.

  5. Alessandro Padovani

    Ok, but it is clear daz studio itself can’t read the pivot coordinates this way, that’s not good. May be Thomas can figure out something, personally I believe this is a mess.

  6. Alessandro Padovani

    update.

    Below it’s the bowl object from “shaded haven“ included in the G2 pack. I see this is quite common, the bowl has a displaced pivot but daz studio is reporting zero coordinates. There must be some property specifying the object coordinates apart the pivot I guess.

    The bowl imported in blender correctly reports the pivot coordinates in the transformations.

    possible solution for @Thomas. One way could be to add a “translation“ empty at zero coordinates when we load a object, then parent the object to the empty. When we rotate we rotate the object, when we translate we translate the empty. This should work to correctly handle the object transformations, but requires one empty per object, unlesss the object pivot is at zero coordinates.

  7. Thomas Larsson repo owner

    This is probably related to #1636. In Blender, translations, rotations and scales are all evaluated in the bone’s local space. In DS, rotations and scales are too, but translations are evaluated in the parent’s local space.

  8. Thomas Larsson repo owner

    Forget about my previous comment; it has nothing to do with it. The last commit fixes the issue, in three places:

    1. The center_point is stored as an object property when the file is imported.
    2. It is subtracted from the translation when the pose preset is saved.
    3. It is added to the translation when the preset is loaded.

  9. Alessandro Padovani

    I tested a simple bowl animation and commit 1f99db3 works fine here. Adding a custom property instead of the empty is clean, thank you for the fix.

  10. Log in to comment