rich_lord Posted November 9, 2017 Share Posted November 9, 2017 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 Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted November 9, 2017 Share Posted November 9, 2017 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. 2 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted November 9, 2017 Author Share Posted November 9, 2017 Thanks for writing all that out MrScienceOfficer. I haven't done any python in Houdini yet, so this gives me a good start. Quote Link to comment Share on other sites More sharing options...
rich_lord Posted November 9, 2017 Author Share Posted November 9, 2017 (edited) 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 November 9, 2017 by rich_lord 1 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted November 9, 2017 Author Share Posted November 9, 2017 Aha! The rotate order was set incorrectly in the Extract Transform VOP! Problem solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.