Jump to content

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

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...