Jump to content
rich_lord

Making Joints Follow Points

Recommended Posts

I've got a bunch of points that animate, and have an orient attribute. I'd like to make one joint per point, and have it follow the position and orientation of the points. Eventually I'm going to export them, so I need them to be Obj level joints.

Are there any good ways of doing this proceduraly? I can think of ways to iterate through the points at SOP level, but I assume these joints will need to be at Obj level.

The attached file is just an example. There's a bunch of points moving around with an orient attrubute.

Any thoughts much appreciated!

point_to_joint.hiplc

Share this post


Link to post
Share on other sites

As long as the number of bones is static, you can write a python script to set up parameter expressions to drive translation and rotation from the points.

geo = sop_node.geometry()
net = hou.node('/obj')

# this needs to be sorted into lists of lists based on hiearachy
bone_heirachy = hierachy_sort(geo.points())

def build_chain(bone_list, parent) :
  for bone in bone_list :
      if type(bone) == list :
        build_chain(bone, parent)
      ptnum = bone.point_number()
      bone = net.createNode('bone')
      bone.parm('tx').setExpression("point({0}, {1}, 'parent_t', 0)".format(sop_node.path(), ptnum))
      bone.parm('ty').setExpression("point({0}, {1}, 'parent_t', 1)".format(sop_node.path(), ptnum))
      bone.parm('tz').setExpression("point({0}, {1}, 'parent_t', 2)".format(sop_node.path(), ptnum))
      bone.parm('rx').setExpression("point({0}, {1}, 'parent_euler_orient', 0)".format(sop_node.path(), ptnum))
      bone.parm('ry').setExpression("point({0}, {1}, 'parent_euler_orient', 1)".format(sop_node.path(), ptnum))
      bone.parm('rz').setExpression("point({0}, {1}, 'parent_euler_orient', 2)".format(sop_node.path(), ptnum))
      if parent :
          bone.setNextInput(parent)
          parent = bone
    
for bone_list in bone_heirachy :
  build_chain(bone_list)

 

This is just psuedo-code going over how to set up something like that up.

 

You can use a list of lists of point objects and other lists to describe the hierarchy(if need be).  Then you need to create attributes that can be plugged into the parameters for the bones.  The best practice in my opinion, is to use VEX to transform the P and orient attributes into relative position and euler angle form, so they can just be plugged directly into the parms.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for writing all that out MrScienceOfficer. I haven't done any python in Houdini yet, so this gives me a good start.

 

 

 

Share this post


Link to post
Share on other sites

Ok, so I have the joints following the position of the points, but I can't get the orient converted into the correct Euler angles.

I followed this thread here to get the maths for the conversion, but none of the tips work. The orientation is always off somewhat.

Anyone know how to properly convert the Quaternion Orient attribute into Euler angles?

 

 

point_to_joint.hiplc

Edited by rich_lord
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×