Plot crowd agent animation back to bones

   314   2   2
User Avatar
Member
19 posts
Joined: Feb. 2014
Offline
Hi all

Would it be possible to bake out the agent animation, generated by the crowd solver, back to bones? Or even fbx-joints?
User Avatar
Staff
237 posts
Joined: Oct. 2012
Online
There's an open RFE to have an easy way to bring an agent's joint transforms into CHOPs (such as a new mode on the Agent CHOP), but it could probably also be done with the new wrangle CHOP and the agentlocaltransform() VEX function.
You'd have to be careful about the rotation order (bones use ZYX) and the presence of any pretransforms on the objects.

If you're not trying to transfer it back onto the original rig, the following snippet may be a useful starting point - it builds a joint hierarchy and sets their transforms to match the agent's current pose.

# 'agent' is a hou.Agent instance, such as geo.iterPrims()[0]
root = hou.node("/obj")
subnet = root.createNode("subnet", "import_from_agent")
rig = agent.definition().rig()
# Create joints.
joints = []
for xform_idx in range(0, rig.transformCount()):
    xform_name = rig.transformName(xform_idx)
    joint = subnet.createNode("null", xform_name)
    joint.setParmTransform(agent.localTransform(xform_idx))
    joints.append(joint) 
    
# Wire up the nodes.
for xform_idx, joint in enumerate(joints):
    parent_idx = rig.parentIndex(xform_idx)
    if parent_idx >= 0:
        joint.setNextInput(joints[parent_idx])
subnet.layoutChildren()
User Avatar
Member
230 posts
Joined:
Offline
maybe a sample file of such workflow would be handy…this can pottentially have alot of use… maybe for attaching cloths ?
  • Quick Links