[Closed] node.objecttransform
Hiya,
I’s just wondering if there’s any way of changing the ‘objecttransform’ property in a node.
I know the helpfile says there isn’t but say I’d have two boxes with different objecttransform values. Then I could attach the second one to the first and then detach it. This effectively means the second objecttransform has become equal to the first one.
Question is, do you know of any other way to accomplisch this change in a node’s objecttransform property?
thnx,
Obi
The .objecttransform matrix is the combined matrix of the node transform and the objectoffset (which contains the offset of the Pivot point from the geometry).
This is why you cannot change it directly. But you can change the two matrices that lead to its calculation, esp. the objecttransform components – .objectOffsetPos, .objectOffsetRot and .objectOffsetScale. Setting them in the second object to match those in the first one, and having the same node transform for both will result in identical .objecttransform matrices…
Here is a shot overview:
Let’s say you are creating a sphere.
A sphere is a primitive object where the sphere creation code calculates a bunch of vertices at an equal distance from the center. The plug-in that does this always calculates the vertices relatively to the origin [0,0,0]. The result would be a cloud of vertices at equal distances from the object space origin which at this point is identical to the world origin.
Then this geometry incl. faces, texture coords etc. is passed by the Sphere base object up the stack and reaches the node transform. At this point, the .objectoffsetPos, Rot and Scale are combined into a matrix which defines how the OBJECT origin relates to the Pivot point. In the default case, the objectOffset transform is the identity matrix, meaning that the pivot point is identical to the object space origin [0,0,0]. If you have moved, rotated or scaled the pivot point only or the object only (using the controls in the Hierarchy>Pivot panel), then that matrix will not be the identity matrix and the pivot will not be centered at the center of the sphere anymore. The pivot point would still be at the world origin, but the sphere would be transformed away from it.
Then the node transform is multiplied with the objectoffset thus moving the pivot itself AND the already offset geometry away from the world origin (if the node transform is not the identity matrix), resulting in the final location of the sphere’s vertices before the Space Warps come in and move them once again…
Hope this helps.
Bobo,
of course you are right.
However, I am facing a different challenge.
suppose I made a box length:10 width:100 height:10. Then I’d copy the box on the spot and change it’s width to 10 and height to 100 units. these boxes have the same objecttransform.
Now apply a standard shader with a diffuse woodmap to both boxes. The woodmap aligns to the X-axis. The two wooden beams look very different because of this alignment.
Suppose I wanted to fix the misalignment of the wood on box2. I could, of course create a second woodmaterial and rotate the woodmap to fix this. But let’s say I want to use the same shader on both objects. My solution wood be to rotate box2 90 degrees about the y-axis, convert box1 to EP and attach box2 to box1, detach it and rotate box2 -90 degrees about the y-axis. Now both beams have been ‘cut from the tree’ the same way.
So I guess I am trying to find out how I can change this initial alignement of 3D (procedural) textures without touching the texturesettings itself. And my guess is it has something to do with the (initial?) object transform property.
Am I correct or way off?
thnx,
Obi
You should forget about the .objecttransform.
When your shader is set to Object space, all it uses is the object space (surprise!) that is defined in the base object as I described in my example.
In order to change the object space, you want to transform all vertices by rotating them at 90 degrees to match the shader alignment of box01, and then transform the whole beam back AT NODE LEVEL to match the height.
Transforming vertices at object level happens using an XFrom modifier. Apply an XForm, rotate its gizmo at 90 degrees, and your beam will look just the same as if you attached to and detached from Box01. Then rotate the whole node back -90 degrees.
b1 = box length:10 width:100 height:10 --create the two beams
b2 = box length:10 width:10 height:100
b1.material = b2.material = standard diffusemap:(wood()) --assign wood
theMod = xform() --create an XForm modifier
addModifier b2 theMod --add the modifier
theMod.gizmo.transform = rotateYMatrix 90 --rotate the gizmo 90 degrees about Y
render() --render to see that they are made from the "same wood"
b2.transform = rotateYMatrix -90 --transform back at node level
render() --render to see the result, should be identical to your attach/detach results
Aha!
So I create a box l:5 W:5 h:25, objecttransform = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])
apply the Xform, rotate the gizmo 90 degrees about Y, rotate the object -90 degrees about Y and the objecttransform becomes (matrix3 [0,0,1] [0,1,0] [-1,0,0] [0,0,0])
Now the viewport tells me that the object looks exactly the same yet the objecttransform tells me the object has been rotated -90 degrees about Y
Exactly what I needed and much more scriptable!
thank you for clearing that up Bobo!
Obi