Extract world positon matrix from SOP node (via Python)?

   512   4   0
User Avatar
Member
7 posts
Joined: 12月 2017
Offline
Is there a way to way extract the transform matrix of a SOP node? On a object level node there is
node.worldTransformAtTime(t)
, but this is not available for SOP nodes.

For example consider the following node tree:

1. Grid node.
2. Transform node.
3. <whatever node>
4. Transform node.

- Can I extract the combined transform matrix (pos/rot/scale) for node 4? Do I need to walk the node tree and manually create matrices for each (supported) node?

- Is things like this normally handled via attributes instead? Like creating custom attributes after node 1 and then extracting them later?

- I see there's a "Extract transform" node. Can I get the transform matrix from that node somehow?

Thanks!
Edited by sbjork - 2024年10月6日 15:33:08
User Avatar
Member
4729 posts
Joined: 2月 2012
Offline
Nodes like the Transform node can save out their transformation as a matrix, so you can combine those matrices. However, there's no built-in way to directly extract the transformation from arbitrary SOP nodes because it’s impossible to know what kind of transformation a node is performing without using something like Extract Transform SOP. For example, the Edit node allows you to rotate or modify geometry in arbitrary ways that aren't explicitly stored as a transform.

In terms of SOP-level geometry, there's no inherent "transform" to speak of, since all the transformations are essentially modifications to the point, edge, or primitive data. For example, if you have some geometry that's cached as rotating around the origin, that doesn’t mean Houdini actually knows or stores this transformation itself. It’s just the final arrangement of points, so Houdini doesn’t inherently track or retain the transform information unless explicitly told to.

The specific transformation you'd like to capture (like position, rotation, scale) can only be inferred if the transformation is explicitly applied or recorded using a node like Transform.

That's why I'd recommend using the Extract Transform SOP. You provide the source geometry (your Grid node) and the final geometry, and it will compute the transformation required to transform the source geometry to the final geometry.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
8833 posts
Joined: 7月 2007
Offline
What you can do is Pack your geometry first

Then whatever transform you do on it with subsequent transfoem nodes or deformers or any SOPs will be always accessible as "packedfulltransform" intrinsic attribute
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
7 posts
Joined: 12月 2017
Offline
Thanks a lot (to both of you) for the replies, very appreciated! I'm quite new to Houdini as you might guess.

Regarding the Extract Transform SOP, how can I use the computed matrix? I see no way of using python to get it. Can I link say a object level null to such matrix and extract it from there? Also, does the Extract Transform work with animation?

/Simon
User Avatar
Member
7 posts
Joined: 12月 2017
Offline
This seems to work well. Thanks again!

import hou

node = hou.node("/obj/geo1/extracttransform1")

for frame in range(1,24):
    geo = node.geometryAtFrame(frame)
    m = geo.pointFloatAttribValues('transform')
    print(m)
Edited by sbjork - 2024年10月7日 04:49:59
  • Quick Links