A little Python tool I'm working on to draw poses for bendy characters in the APEX Scene Animate node.
APEX animate tool for drawing poses
5036 11 4-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
-
- Roy_Kristoffersen
- Member
- 2 posts
- Joined: 12月 2014
- オフライン
-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
Roy Ranheim Kristoffersen
Cool! Please tell a bit more on how you achived that.
Hi Roy! It's similar to creating a Python view state, the main difference is the custom code is loaded by the APEX Scene Animate node to act as a sort of sub-tool.
Then you can respond to mouse and keyboard input. I've done some processing of the input using SOP verbs, like comparing the current z-depths of the joints and aligning the transforms, to create the curve that then feeds back into the joint positions using the APEX api.
For the prototype I've also added some properties to the rig so joints know which curves they belong to, it might be possible to make it more general - for example if the tool looks at the joint heirarchy for the selected controls instead.
There's some starter support for multi-level controls in here, so broad controls are positioned first, with fine controls then positioned from the broad curve to give the final curve - this will be nice for manual pose tweaks when it's ready, but the code to go backwards from the drawn curve to the broad curve needs an overhaul when I next get a chance to look at the tool.
I hope that sheds some light on it, let me know if you have any thoughts!
-
- citizen
- Member
- 113 posts
- Joined: 8月 2020
- オフライン
-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
citizen
Looks good! Does it preserve "bone" length?
No, this version just controls the input transforms of a ControlSpline, so the lengths will change with the length of the spline - which is great for cartoony or stretchy limbs but not otherwise. It should be possible to do something directly with the skeleton heirarchy that preserves lengths, though I'd wonder how to fix the end point of the joints to the end of the drawn line, it could get frustrating if it's over/under shooting to preserve lengths. Maybe an internal FullBodyIK could fix the ends?
-
- citizen
- Member
- 113 posts
- Joined: 8月 2020
- オフライン
-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
citizen
The resulting pose should be a scaled up/down version of the drawn curve, with the start/end points on the same line determined by the drawn curve.
This would work to pin the end points, but not to preserve the lengths - to do both the joints in the middle of the heirarchy need to be free to deviate from the drawn curve, because that curve could be any length.
Also I just realised if the distance between the start and end points of the drawn curve is longer than the total rest length of the joints you can only solve one or the other, so drawing very straight stretched out limbs is a risk, but you could choose to prioritise lengths or end pinning depending on the type of animation you're working on.
-
- citizen
- Member
- 113 posts
- Joined: 8月 2020
- オフライン
-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
citizen
I was having in mind something like this:
ah I see! Yes that'd work for fixing to the start and preserving lengths, and it would keep the characteristics of the drawn curve if not the positions so there's definitely a use for this. I think there are situations where this could get frustrating (eg trying to get a character to scratch their own head, if we can't control the position of their hands at the other end of the joint chain), but maybe that's just where it would need an option to flip between preserving lengths or preserving positions.
-
- johnlilpy
- Member
- 52 posts
- Joined: 10月 2021
- オンライン
-
- danfitz82
- Member
- 52 posts
- Joined: 1月 2017
- オフライン
johnlilpy
May I ask how you load the custom code into APEX Scene Animate? Thanks.
It's been a while since I looked at it so I've had a quick dig to try and remember, sorry if I forget anything, here's how it works:
- The .py file for your custom tool has to be somewhere Houdini can load it (mine is in houdini_site\houdini20.5\python3.11libs\noadapextools\drawtool.py)
- The APEX Animate state will look for a "load" function in your Python module that returns your custom tool:That State class is just "class State(object):", I don't think you have to inherit anything, but the APEX Animate's Python state will pass "onMouseEvent" and "onKeyEvent" to your object and maybe some others, I don't think there's documentation anywhere but if you dig through the APEX Animate state you'll find the functions it passes on.
def load(viewer_state): return State(viewer_state)
- I have a shelf script with this code to load the tool while you're editing in the Apex Animate node (you could probably assign a shortcut to make it easier?):
import stateutils import apex.ui.statecommandutils as scu import hou viewer = scu.getSceneViewer() kwargs = {} viewer.runStateCommand("getState", kwargs) state = kwargs['state'] scu.startTool("noadapextools.drawtool", kwargs)
-
- JoshRizzo
- Member
- 10 posts
- Joined: 12月 2018
- オフライン
Great stuff!
Unfortunatly this breaks in 21.0 given this error:
If anyone has any clue, what might be additionally needed to get this to work OR maybe there is a template file somewhere or a dummy tool that should work.
Would be greatly appreciated
Unfortunatly this breaks in 21.0 given this error:
Traceback (most recent call last): File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/houdini/python3.11libs\viewerstate\utils.py", line 1079, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/houdini/python3.11libs\viewerstate\interface.py", line 391, in onCommand state.onCommand(kwargs["args"]) File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/packages/apex/viewer_states\apexanimate.py", line 5462, in onCommand self.loadAndSwitchToTool(module_name, args.get('on_activate_kwargs', None)) File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/packages/apex/viewer_states\apexanimate.py", line 5611, in loadAndSwitchToTool self.setActiveTool(toolname=toolmodulename, on_activate_kwargs=on_activate_kwargs) File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/packages/apex/viewer_states\apexanimate.py", line 2473, in setActiveTool self._loadToolHUDSettings() File "C:\PROGRA~2/SIDEEF~1/HOUDIN~1.512/packages/apex/viewer_states\apexanimate.py", line 2338, in _loadToolHUDSettings self.hud_parameter_panel.loadBakeParmsFromConfig(the_config, prefix) ^^^^^^^^^^ UnboundLocalError: cannot access local variable 'the_config' where it is not associated with a value
If anyone has any clue, what might be additionally needed to get this to work OR maybe there is a template file somewhere or a dummy tool that should work.
Would be greatly appreciated
-
- Quick Links



