COG Transform

   2495   22   1
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
I'm wondering how to quickly scale an imported object that's randomly positioned in the scene, and not centered to the world 0,0,0 axis about its COG.

Using the transform SOP I can center the object to the world 0,0,0 axis which is the opposite of what I need, but I've not been able to figure how to center the Pivot to the center of the object so I can scale it about its COG so it just scales and doesn't move from the current position.

So far it looks like the only way is to manually eyeball transform the Pivot to the COG before scaling, but I'm sure there must be some secret trickery that works better.

In SI one just had to set the action center to COG, but it smells like it's not that easy in Houdini.

Anyone knows a solution ?

Thanks.
Edited by toonafish - 2023年1月12日 14:29:27
User Avatar
Member
7758 posts
Joined: 9月 2011
Online
toonafish
Using the transform SOP I can center the object to the world 0,0,0 axis which is the opposite of what I need, but I've not been able to figure how to center the Pivot to the center of the object so I can scale it about its COG so it just scales and doesn't move from the current position.

do that, but then 0 out the transform
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
ah, of course thanks !

But why not simplify that with a "center pivot" button ???
User Avatar
Member
7758 posts
Joined: 9月 2011
Online
toonafish
ah, of course thanks !

But why not simplify that with a "center pivot" button ???

I dunno, it's something everyone adds as a preset and doesn't think to request a change from the devs

feel free to submit a feature request for anything you find lacking or unintuitive
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
toonafish
ah, of course thanks !

But why not simplify that with a "center pivot" button ???

If you wish and you give me a simple file and some clear step by step procedure I could check if it is possible to make a shelf button for that using Python. That is if I'd manage to get the proper syntax and access the API in that regard.
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
jsmack
[I dunno, it's something everyone adds as a preset and doesn't think to request a change from the devs

Yeah, but it's stuff like this that slows one down and distracts from the current task involved all the time. Before you know it you're customizing Houdini to streamline the workflow or concentrating on the node tree instead of what you're currently working on.

It's one of the main flaws of Houdini, workflow is one of its biggest weaknesses I think, especially in the modeling department. It feels like eating soup with a screwdriver ;-)

Time for another feature request I guess :-)

@SWest : Nice, would be great. Here's a simple scene with a curve of which I translated and and rotated the points so it's COG no longer located at the center : https://www.dropbox.com/s/p659hwz0bwdj87e/COG_Transform_01.hiplc?dl=0 [www.dropbox.com]
Edited by toonafish - 2023年1月12日 15:59:14
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
toonafish
Here's a simple scene with a curve of which I translated and and rotated the points so it's COG no longer located at the center : https://www.dropbox.com/s/p659hwz0bwdj87e/COG_Transform_01.hiplc?dl=0 [www.dropbox.com]

Just to confirm that I've understood this right: You have the actual object which is the parent node and this determine the actual position of the object, no?

Then you have the contents of this node that you have been moving. However, the object position is still where it was. This is the pivot.

So, what you would like to see is that the object position is moved to the new center of the circle, but the points that define the circle are more or less "inversed" so you do not see any change.

Is this correct?

Or do you want to keep the parent node's "zeroed" position and only move the transform node's "Pivot Translate" so it finds the middle of the circle?

I've attached a video showing what I guess you want, no?
Edited by SWest - 2023年1月12日 16:53:32

Attachments:
swest_screen_capture_20230112_2251.mp4 (2.0 MB)

Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
SWest
Is this correct?

Great, yep, what I'd like is to automate the process of clicking "Move Centroid to Origin" and then reverting the adjusted Transform values to the "Default" 0,0,0.

Would even be better if that would be a toggle to automate the whole process, even when the point transform is animated, for instance with a blendshape. But maybe that's a bit much :-)
Edited by toonafish - 2023年1月12日 16:50:49
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
Please check the video. There are at least two "pivots". First the parent node position. Then the transform node pivot.

Only the parent node transforms can accept "Clean Transforms", so it is the parent node you want to move, right?

Tomorrow, or maybe a bit later, I could check if it is easy to get hold of the API for this. Otherwise we could at least clarify this a bit and see how far we get.

Please show a picture or describe exactly what this is: "then reverting the adjusted Transform values to the "Default" 0,0,0.". Is it the parent node or the Transform node? For the transform node you will need to show me how you do this manually first please.
Edited by SWest - 2023年1月12日 17:03:52
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
Great, thanks.

Maybe this scene is more clear on the idea : https://www.dropbox.com/s/wawu9gsc9z27t82/COG_Transform_02.hiplc?dl=0 [www.dropbox.com]

I froze the deformed geo, so it's like an imported curve.

What I'd like is to remove the need to have to manually adjust the Pivot to the COG all the time when adjusting geometry while modeling, but have that somehow automated as it can be in Softimage ?
User Avatar
Member
179 posts
Joined: 8月 2018
Online
Maybe I'm misunderstanding here, but can't you just enter:
$CEX | $CEY | $CEZ
in the three 'Pivot Transform' > 'Pivot Translate' fields.

You can then hit the 'gear wheel' icon in the parameter manager and set: 'Save Preset' - it will then appear at the bottom of that menu for quick recall on new instances of the transform node. Or even set it as 'Save as permanent defaults' if you prefer.
Edited by Mike_A - 2023年1月12日 18:33:54
User Avatar
Member
7758 posts
Joined: 9月 2011
Online
Mike_A
Maybe I'm misunderstanding here, but can't you just enter:
$CEX | $CEY | $CEZ
in the three 'Pivot Transform' > 'Pivot Translate' fields.

You can then hit the 'gear wheel' icon in the parameter manager and set: 'Save Preset' - it will then appear at the bottom of that menu for quick recall on new instances of the transform node. Or even set it as 'Save as permanent defaults' if you prefer.

That's more of a 'live' pivot. If the input geometry changes, the pivot will move, which would change the transformation.

toonafish
What I'd like is to remove the need to have to manually adjust the Pivot to the COG all the time when adjusting geometry while modeling, but have that somehow automated as it can be in Softimage ?

Although it doesn't set the pivot, you can interactively move the handle with:
Right click the transform handle -> Snap To -> Centroid
This will change the behavior of the handle as if the pivot were moved, but it doesn't change the pivot on the xform node.
Edited by jsmack - 2023年1月12日 19:26:59
User Avatar
Member
179 posts
Joined: 8月 2018
Online
Are you aware of the difference between hitting tab in the Scene view vs doing so over the Network view?

Eg: With cursor over the Scene View...
First job: With the selection tool active - check the 'Select' drop down menu in the 'operation toolbar' at the top is set to '3D connected geometry'.
Tab > Transform
Click on the circle file to select it and hit enter.

The transform node should now be centred on that geo.

Does that work for what you want?
Edited by Mike_A - 2023年1月13日 07:08:39
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
Please place the following Python code in your modeling shelf.

You could call it "Transform pivot"

If there is any error or bug please let me know.

Kindly keep the credits line.

Thank you!

# code for moving a Transform node's pivot to the center of its geometry
# By SWest


# code for getting the (last) selected node
inputs_validated=True
selected_nodes = []
selected_nodes = hou.selectedNodes()

if len(selected_nodes) == 0:
    inputs_validated=False

if inputs_validated:
    node = selected_nodes[-1:][0]
    node_path = node.path()


# code for validating that the selected node is a SOP transform node
if inputs_validated:
    node_type = str(node.type().name())
    if node_type == 'xform':
        pass
    else:
        inputs_validated=False


# code for user feedback
if not inputs_validated:
    message='please select a SOP Transform node and try again. '
    hou.ui.displayMessage(message)


# code for applying movecentroid
if(inputs_validated):
    parm_path = node_path+'/movecentroid'
    hou.parm(parm_path).pressButton()

    # get the t parm
    parm_t_path = node_path+'/t'
    
    # set the parms
    hou.parmTuple(parm_t_path).revertToDefaults()

Please note, after the initial communication this was thrown together during my (extended) lunch break so if there is any minor inconsistency that is probably the cause.

Edit: I guess you wanted the transforms to be zeroed out, so if the Transform node has been moved initially this will destroy that data. To retain such a thing I would need to do an update. Please let me know if that is needed.
Edited by SWest - 2023年1月13日 07:25:14
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
Mike_A
Are you aware of the difference between hitting tab in the Scene view vs doing so over the Network view?

Ha !! I did not know that, seems it automagically centers the Pivot. Makes me wonder why that feature is not also a button in the transform panel. Just to make things more intuitive ?

The strange logic of Houdini.

Muchas gracias señor.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
SWest
Please place the following Python code in your modeling shelf.


Brilliant ! Just installed it, and it works like a charm, thanks a lot !
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
If you manage to add the Transform node using the node editor the script might be useful.

However, there is already a sop_xform shelf tool available. You could also add this to your shelf. If you apply that, then select your mesh, your Transform pivot will be centered by default.

Edit: After testing a little with a series of Transform nodes using different selections it seems obvious that the script might be necessary. Also there might be a need to fix the positioning for cases when you have actually moved the contents and simply want to center the pivot. As it is now the Transform node's position will always be zeroed.

One more issue is that if the geo is scaled before centering it, the script will not be able to retain the position.

However, please let me know after some testing time if there is a need for updates.
Edited by SWest - 2023年1月13日 14:40:14

Attachments:
sop_xform.png (138.0 KB)

Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
Update for Transform pivot script so it retains an original translation. It simply centers the pivot using features already available in the API.

As mentioned previously, please place the following Python code in your modeling shelf.

You could call it "Transform pivot"

If there is any error/bug or enhancement request please let me know.

Kindly keep the credits line.

Thank you!

#'''Code for moving a Transform node's pivot to the center of its geometry.'''
# By SWest


# code for getting the (last) selected node
inputs_validated=True
selected_nodes = []
selected_nodes = hou.selectedNodes()

if len(selected_nodes) == 0:
    inputs_validated=False

if inputs_validated:
    node = selected_nodes[-1:][0]
    node_path = node.path()


# code for validating that the selected node is a SOP transform node
if inputs_validated:
    node_type = str(node.type().name())
    if node_type == 'xform':
        pass
    else:
        inputs_validated=False


# code for user feedback
if not inputs_validated:
    message='please select a SOP Transform node and try again. '
    hou.ui.displayMessage(message)


# code for storing the original translation
if(inputs_validated):

    # get the t parm
    parm_t_path = node_path+'/t'
    original_t = hou.parmTuple(parm_t_path).eval()


# code for applying movecentroid
if(inputs_validated):
    parm_path = node_path+'/movecentroid'
    hou.parm(parm_path).pressButton()

    # get the t parm
    parm_t_path = node_path+'/t'
    
    # set the parms
    # hou.parmTuple(parm_t_path).revertToDefaults()
    hou.parmTuple(parm_t_path).set(original_t)
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
407 posts
Joined: 3月 2014
Offline
Splendid, 10 bonus points for you ;-)

Thanks.
User Avatar
Member
76 posts
Joined: 8月 2020
Offline
Would be nice to be able to snap to centroids, for when you need to snap something exactly at the center of that circle, interactively.
  • Quick Links