import pose/action doesn't work for props

Issue #1304 resolved
Alessandro Padovani created an issue

daz studio 4.21.0.5, blender 3.3.2, diffeomorphic 1.7.0.1312

Don’t know if this is a bug or an intended limitation, but I noticed that animations can’t be imported for props. That is, after importing the scene and selecting the prop, the posing tab is empty and tools don’t show up.

Test scene and animation included cube.duf and cube-anim.duf, it’s a cube and its animation.

Comments (38)

  1. Thomas Larsson repo owner

    Yes I know, the pose tools should work for props and other objects as well (cameras and lights). However, the assumption that the active object is an armature is rather hard-coded and would require quite a bit of work to relax. I will keep this in mind but it does not feel very urgent.

  2. Alessandro Padovani reporter

    Ok, will keep this open then if this is an intended limitation, and change from bug to enhancement.

  3. Alessandro Padovani reporter

    @Thomas Larsson Could you import at least cameras and lights, not including hierarchies ? This would allow to import the relative daz animations in blender. If updating the current code is troublesome may be you can write a separate code for that.

    Not to push in any way, this is more a reminder. It would be useful to complete some of the animation section.

    p.s. On a second thought we can probably use fbx to export/import cameras and lights, so this is not urgent. But would be nice to complete the importer.

  4. Rakete

    I actually have changes in my fork that makes this work. I use it pretty often and the change was actually quite minimal iirc. If you want I can look through my changes and just quote what I did?

  5. Alessandro Padovani reporter

    Yes please that would help. I am also curious what your fork does and if you may consider to add your extensions to the official diffeomorphic. I mean if you think it can be useful to others then it is likely that Thomas can be interested.

  6. Thomas Larsson repo owner

    I made an attempt to make the posing panel work for objects other than armatures. Hopefully things will work, but it changes several things and there might be new bugs.

  7. Alessandro Padovani reporter

    Thank you I hope nothing is broken. Will do some tests and let you know if I find something that doesn’t work.

  8. Alessandro Padovani reporter

    Commit e9ebed0.

    There’s some confusion in the import action panel that needs to be sorted out.

    Now we have objects and figures, both can import animation. If there’s a hierarchy of objects and/or figures in daz studio we have to save the animation separately for each item because it is not possible to save a hierarchy animation afaik. So in blender we have to load back the animations for each item separately, that’s lucky because this way the animation will only be either an object or a figure but never both. Unless I miss something.

    Please note that for geografts we will load the animation on the merged rig and only the geograft bones/morphs will be affected.

    bug. action options. So if the selected item is an object the import action panel should provide options for objects. If the selected item is a figure options for figures. While working at the action panel you may also consider #1567. Or you may split it into “Import Object Action“ and “Import Figure Action“.

    bug. affect bones. Actually if we uncheck “affect bones“ the action will not load plus there’s no way to get “affect bones“ back.

    bug. affect scale. If we import a object animation and check “affect scale“ we get an error.

    steps:

    1. import the test scene anim.duf and merge rigs, the scene is g8f parented to a cube, that could be for example a vehicle prop
    2. select the cube and import the animation cube-anim.duf, including scale
    3. select g8f and import the animation g8f-anim.duf, including scale

    p.s. Please note that in daz studio we can save either a pose animation or a shape animation, or both with “properties preset“ that will include pose and shape. But it will refer to a single object or figure, so again a hierarchy of objects/figures will require to save separate animations. For example for geografts we need to save the geograft animation separately from the figure animation.

  9. Rakete

    I just tried this out and it works, but I ran into two problems that I fixed in my repo:

    This fixes saving poses for objects for me:

    https://bitbucket.org/rakete/import_daz/commits/bb26bb9854aaa7b3171fff29e78ec2a331323dd4

    And this is because I just call the diffeo operators programmatically:

    https://bitbucket.org/rakete/import_daz/commits/cf5c7cee16d9d11bc7332980988fea901989b6d2

    basicly because onlyObject is set in invoke it is impossible to use StandardAnimation.run without an operator calling invoke first.

    @Alessandro Padovani I pretty much use only Properties Presets and import them through ImportPose, don’t think I had to do any changes for that. I always wondered if Hierachical Pose Presets would be something that would make sense to be implemented. It would be nice to be able to apply a pose to an armature without everything merged.

    I’ve also gone through my older code and tried to find all commits where I made changes for posing non-armature objects:

    https://bitbucket.org/rakete/import_daz/commits/693a45481be8205fda72fa9df78bc6a2ec893088

    https://bitbucket.org/rakete/import_daz/commits/247fe76e6f88f8be93853c0fcf1ec359e966b48c

    https://bitbucket.org/rakete/import_daz/commits/aaee971341e7e096d1b8ecae8102f6414f184868

    https://bitbucket.org/rakete/import_daz/commits/a710f1e3430aa40c2f131e58d0d8e5f032e2e488

    https://bitbucket.org/rakete/import_daz/commits/d19431fc0558afa7059e8c9968c53124be4a7a70

    Those should be most of them. Sadly, it is of course difficult to get any good information from just those alone, but I guess I wanted to just try myself and see what changes I actually made. In particular this one makes me wonder again, because I one thing I just tried again is applying a pose to a piece of furniture that has some bones to open a drawer, and while the morph is seemingly imported, the bone does not move. I remember working on that and coming up with a plan but then got distracted but other things.

    The little table with the drawer open in Daz is moved to the correct position in blender, the morph is also imported and shows up, but the drawer is not opened.

  10. Thomas Larsson repo owner

    The last commit should fix Alessandro’s bug. I will look into Rakete’s issues later.

  11. Alessandro Padovani reporter

    Commit bef70dd.

    bug. object scale. The object scale animation is not imported.

    bug. figure scale. The figure scale animation is imported but doesn’t work fine. In the test scene G8F is scaled up then down but the importer only scales up. Please compare the animation with daz studio to see the difference.

    bug. action options. The master bone option should not be exposed for objects. Then “subtract rest pose“ should only be available for “daz orientation“ as #1567.

    suggestion. better defaults. I’d suggest to uncheck “clear pose“ “new action“ and “integer frames“ by default. That’s because we usually want to add the animation to the current pose and action, and daz studio uses fractional frames at different fps. Also check “affect scale“ since we usually want to import the scale too. And if you don’t want to fix #1567 for some reason, at lest uncheck “subtract rest pose“.

    I updated the test scene with some more scaling for better testing.

    steps:

    1. import the test scene anim.duf as dbz and merge rigs
    2. select the cube and import the animation cube-anim.duf, including scale
    3. select g8f and import the animation g8f-anim.duf, including scale

  12. Alessandro Padovani reporter

    @Rakete To edit you have to click inside the box after pressing “edit“.

    about your fork and license. I am not sure how Bitbucket works so may be I’m wrong here. I understand you cloned the project for better handling to be free of doing your own changes. But I’m not sure the license you’re distributing is correct since you are attributing your code to Thomas. I guess you should reference the original project and add your copyright. Or use pull requests to branch the main project by Thomas. Also I am curious what your fork does and which features you added, there’s actually no documentation in your repository.

    properties preset. As for “properties preset“, I understand there’s some confusion in daz studio and among PAs between pose and shape. Ideally we should only use “pose”, then reserve “shape“ to shape-shifting actions which requires ERC morphs in blender.

    https://diffeomorphic.blogspot.com/2021/09/morphing-armatures.html

    hierarchical pose preset. This seems to only work for figures and not for objects. But yes it allows to save conformed figures as outfits and geografts together with the main figure in a single animation, and also supports objects parented to bones as tools or weapons for example. @Thomas Larsson We may want to look at this as a second step, if you are interested to support this. As I understand it, this may already work or partially work since we can import geograft animations in the merged rig and they work fine.

  13. Alessandro Padovani reporter

    Commit 86de02a seems to work fine as for the reported bugs. Apart #1567.

    possible bug. morphing objects. I believe there should be a “affect morphs“ option for the object too. But actually I’d have to prepare a test scene for that, since I’m not sure if I have in my library a morphing object that is not a figure.

    p.s. If I understand correctly, since in this case there’s no armature to link the driver, the morph animation could be loaded directly as shapekeys keyframes.

  14. Alessandro Padovani reporter

    update. Suzanne morphing object.

    Ok, I managed to create a little daz studio asset with the morph loader, importing Suzanne with a couple morphs for the ears. Installation as usual, unzip and copy into the content library. This is a morphing object and we should be able to import an animation with morphs.

    asset content:

    • suzanne.duf morphing object in the Figures folder
    • suzanne-anim.duf animation in the Presets folder
    • suzanne.duf scene in the Scenes folder

    steps:

    1. install the Suzanne.zip package as usual, unzip and copy in the daz content library
    2. import the suzanne.duf scene in blender
    3. import the suzanne-anim.duf animation in blender, including scale and morphs

  15. Thomas Larsson repo owner

    Save pose preset should work for all objects now. Also, the scripting issue should be gone, because onlyObject is set in invoke and only used by the draw function, not in the execution of the operator.

  16. Alessandro Padovani reporter

    Commit bb5d464 works great.

    I can import the daz favorites for the morphing suzanne, as well as the suzanne morphing animation. I’m not sure if @Rakete has anything to add, please let us know if we can close as resolved.

    Thank you Thomas for the nice improvement.

  17. Rakete

    Seems to work, I noticed the same problem as before when I used it through my wrapper, the isFigure attribute is set in invoke, and so I get a raise when I call the operators programmatically.

    When I applied a pose to a non-figure object with an armature it worked, but I noticed it actually already worked before, but the problem is (in this particular case) that the limits are applied the wrong way around. Meaning the bone movement tries to reach -0.16 but the limit is set to 0 - 0.16, so it can’t. Once I disable the limit the pose control works fine in blender (and so a pose is applied correctly).

    I tried a mesh with only shape keys, and it seems loading morphs there is a little tricky but works. As @Alessandro Padovani said importing the Daz favorites works fine, and then loading a pose with those sliders set correctly applies the pose. But what did not really seem to work is loading those morphs automatically like I can do when I pass useLoadMissing=True to bpy.ops.daz.import_pose. Loading the morph through Import Custom Morphs worked too.

    For morphs on mesh objects there are only shape keys, and no properties. So nothing shows up in the Morphs section of the UI, but also the morph is not saved when a saving a pose.

    Saving a poses for objects with armatures works fine.

  18. Thomas Larsson repo owner

    isFigure has been removed from the last place outside of the invoke and draw functions, so scripting should not crash. Shapekey animations are now also save in the pose preset.

  19. Rakete

    Tried out the latest changes and now saving the shape keys as pose works, but loading missing morphs on armature objects stopped working for some reason.

    EDIT: Easy solution actually:

    def handleMissingMorphs(self, context, rig):
        if rig.type == 'ARMATURE' or self.useShapekeys or not self.useLoadMissing:
            return False
    

    I just removed the rig.type == 'ARMATURE' check there so that handleMissingMorphs actually runs for armatures.

    EDIT2: This commit: https://bitbucket.org/rakete/import_daz/commits/f2e55e24f36be5a5e51f5660d4fa74bf5353d6a1

    fixes both loading missing morphs on armatures and meshes for me.

    EDIT3: Last commit was not working correctly, always needed to apply pose twice for it first loadMissing and then use the shapekey the second time. Fixed it by making sure the shapekeys are re-assigned before running prepareAnimations again: https://bitbucket.org/rakete/import_daz/commits/be9bc004254e5b91c5595a7d7f192ec2594e0cc1

  20. Rakete

    Would it be possible to add sliders to the UI for the shape keys? I assume a prop + driver would work, but I am wondering if it is possible to just add the shapekey without adding another driver.

  21. Thomas Larsson repo owner

    I implemented your patches in the last commit.

    As for displaying the shapekey sliders in the UI, the Import Custom morphs tool has an option called Use Mesh Categories. It is only visible if Use Rig Property Drivers is disabled. Unfortunately it seems like it has not yet been documented in https://bitbucket.org/Diffeomorphic/import_daz/wiki/Setup/Morphs/Import Custom Morphs.

    If you now load morphs, the shapekeys sliders now appear directly in a panel called Mesh Shape Keys. It has a UI which works the same way as for custom morphs. Or should work, because I now notice that there is a crash.

  22. Alessandro Padovani reporter

    @Thomas Larsson could you do “use mesh categories” automatic for “daz favorites“ in easy import ? I mean “daz favorites“ may use “property drivers“ for figures and “mesh categories“ for objects. This way easy import will do sliders both for figures and morphing objects. If I understand correctly.

    Reason it is much easier to animate with sliders since we can keyframe them all, while shapekeys are to be keyframed one by one. Unless we get a extra addon to better handle shapekeys.

    edit. Nope there’s no need. I see we can keyframe multiple shapekeys with the shapekey editor in the dope sheet. So blender can handle shapekey animations quite well even without extra addons. Nonetheless having sliders would be better consistent with the importer interface I guess. You may consider the idea and do as you like it better.

  23. Alessandro Padovani reporter

    Yes I know, I was suggesting to make it automatic for easy import. But I guess your answer states you prefer not that’s ok for me.

  24. Rakete

    I am using the “use mesh categories” thing now, but needed to make a change in getSingleAnimation so it is called for meshes with new shapekeys. This way I can make use of it when I call the import_pose operator with useLoadMissing=True. So I now have PropDrivers in the classes that AnimatorBase inherits from: https://bitbucket.org/rakete/import_daz/commits/e83cf00464a9819af6762ad00866e90fd8c916bc

    One other thing I changed that I think is relevant here is to make it so I can save poses with morphs that are set to 0. By default these are excluded by diffeo when saving a pose, and that makes sense and I wanted to preserve that behaviour because otherwise I save a lot of stuff I don’t care about. There is a property useUnusedMorphs in the save_pose operator, but that just saves everything then, and I didn’t really want that. What I wanted is something that only saves morphs where all values are zero if a) the morph has at least one keyframe and b) I am saving a pose (so a single frame) and not an animation. So I implemented a variant of useUnusedMorphs called useUnusedMorphsSingleFrame: https://bitbucket.org/rakete/import_daz/commits/026e3581ece841fd739ea79fc1c413c86f977563

    which I believe should do what I want.

    So this leaves only one problem, the flipped limit constraints. I have no idea what to do about them but I believe those are related to the functionality that tries to “flip bones” that you have implemented. No idea about that either, but I did actually come up with something similar myself at some point:

    https://bitbucket.org/rakete/import_daz/commits/e75cfe799e4e43164354ff0fd0f4c51fcde6a685

    https://bitbucket.org/rakete/import_daz/commits/cbb83f9b6639d9e5e89482b9606f7389190215d5

    iirc I simply noticed that saved poses just didn’t work for certain genital rigs, and using those “flipped translations” there fixed the problem for the time being. But I do not really understand why tbh. My question would be: do you have an explanation for why this “flipping” functionality is needed? You seem to simply hardcode which bones are flipped and which aren’t, is there maybe a way to detect that? Maybe on the Daz side?

    I believe the flipped limit constraint in my test rig is caused by the fact that I should mark the bone as flipped, but since it is a custom rig it doesn’t make a lot of sense to try to hardcode all possible bone names, there would need to be a way to detect if a bone needs to be flipped or not.

  25. Alessandro Padovani reporter

    I am not into coding, but as I understand it flipping is heuristic so needs to be hardcoded per figure. A more general solution would need to store the daz axes per bone in order to correctly load daz poses, because daz studio can use any axis for bending and twisting while blender always use y for twisting and x for bending.

    I was proposing a possible general conversion in #1445, but as I understand it Thomas replied it is too much work.

    # daz to blender bone axis conversion
    blender y = daz roll axis
    blender x = daz axis where label = "Bend"
    blender z = remaining daz axis
    

  26. Alessandro Padovani reporter

    @Rakete May you please look at #1523. We’re not able to understand why “scale all“ for futalicious doesn’t work in blender. It would be nice to fix it if you think you can help.

  27. Rakete

    @Alessandro Padovani I can try to think about what I did back when I had problems with the XY genital, and then I’ll try to describe it. It does seem like in #1523 there are some problems similar to what I already solved (more like, worked around).

    One particular thing I remember: the XY genital also had sliders that didn’t work at all, and seemed to cause tons of problems when trying to exchange poses between blender and daz while they were applied. Because of how the sliders and bones were setup, it was impossible to properly zero the armature. And since diffeo essentially bakes everything and then all poses saved in diffeo assume that every value has its rest pose at 0 (instead of the actual zero value), being unable to zero the armature was problematic (this problem has been solved with these pseudo values for baked attributes, at least somewhat I assume).

    My solution for that problem was to simply delete all .dsf files for sliders that were causing problems, and then relying only on manual bone movement, and making my own sliders that worked from the bones “proper” rest pose (everything at 0).

    That was only one problem I had though, the other one involved fiddling with the code in animation.py and figuring out how to change the math so it would end up working, which is where I started using those “flippers” that I mentioned (basicly just properties where I could specify that certain axis should be flipped in the calculation, and that then fixed my problems). I also remember avoiding scaling, and at some point basicly going “ok, you can’t scale these at all, so just don’t do that”, cause I couldn’t really figure out how to combine my “flippers” and scaling matrices. I kind of hope that is fixed now actually and wanted to try it out again without all my old changes if it now works properly.

  28. Log in to comment