Jump to content

Null Moves Along Multiple Axis, Instead of One?


Atom

Recommended Posts

Hi All,

I have a NULL inside a RIG which controls the eyebrows. I have made a slider that allows me to raise the eyebrows. But when I change only the Y axis of the NULL, it moves along the Z axis as well. Is there some way to make that NOT happen?

I am using a .set() on the py parameter.

node.parm(parm_name).set(value) 

 

eyebrow_lift.gif

Edited by Atom
Link to comment
Share on other sites

The axes (ie. space) that the T/R/S values operate on an Object depends on its "parent" (ie. input) and any pre-transform it may have. So if your null has no parent, then you just need to reset (or "clear") the pre-transform that the null has to reset its space back to world. If it has a parent, then your pre-transform needs to be the inverse of the parent's world transform.

Link to comment
Share on other sites

Oohh, so how do I handle that in a rig? This NULL is at the end of a long chain. Is the last parent the only one I need to invert? It also looks like the NULL has it's own rotation as well...

Untitled-1.jpg

Edited by Atom
Link to comment
Share on other sites

I am basically returning to a problem I was not able to resolve back in August. All of my rig controls generate offsets from an original saved state. This way I can zero all the controls and return to the default pose. So internally I grab the original value from the saved state then alter it based upon the slider and store that as the new TSR on the control object which happens to be a NULL.

I was able to craft a function, from the help I received back in August, on projecting a distance along a vector but this does not take into account any parenting.

Also all I get back is a matrix which I am not sure how to apply to my saved matrix?

def projectAlongOrientation(node_path, node_name, distance, passedVector):
    n = hou.node('%s%s' % (node_path,node_name))
    if n:
        # Fetch the original starting value from saved parameters.
        try:
            rx =n.parm("r_%s_x" % node_name).eval()
            can_continue = True
        except:
            can_continue = False
        if can_continue:
            # If the first parameter exists we'll assume the others do as well. (assuming often leads to crash)
            ry =n.parm("r_%s_y" % node_name).eval()
            rz =n.parm("r_%s_z" % node_name).eval()
            tx =n.parm("t_%s_x" % node_name).eval()
            ty =n.parm("t_%s_y" % node_name).eval()
            tz =n.parm("t_%s_z" % node_name).eval()
            
            # Construct matrix parts.
            mtx_rot = hou.hmath.buildRotate((rx,ry,rz),"xyz")
            mtx_loc = hou.hmath.buildTranslate((tx,ty,tz))
            
            # Create world transform.
            mtx = mtx_rot * mtx_loc
            
            v = passedVector
            direction = v.normalized()
            vector = direction * distance
            translate_matrix = hou.hmath.buildTranslate(vector)
            mtx_result = translate_matrix * mtx
            #n.setWorldTransform(mtx_result)
            return mtx_result
        else:
            print "projectAlongOrientation: expected source parameter [r_%s_x] not found, you need to click the Capture Original Values button." % node_name

mtx_new = projectAlongOrientation(node_root, "oculi01_L", v, {0,1,0})     

So in this case for the eyebrow lift, I only need the Y translation value from the resulting projected matrix?

What does the python code look like to extract Y from a matrix? I already tried...

new_y = mtx_new.y

 

Edited by Atom
Link to comment
Share on other sites

Sorry, I don't have Houdini right now but the process is roughly:

parent = n.inputs()[0]
parent_rot_inverse = hou.hmath.buildRotate(parent.worldTransform().extractRotates()).inverted()
n.moveParmTransformIntoPreTransform() # easy way to clear local parms since we're going to overwrite the pretransform
n.setPreTransform(translate_matrix * parent_rot_inverse) # where translate_matrix is the local offset translation matrix

 

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...