Strange behaviour of applyTransform(..., absolute = True)

Started by BIA_user, May 26, 2016, 07:57:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BIA_user

Hello,

While trying to set node position via scripting I found something strange. I first created a new scene with "File/new" and added a cube and a cylinder with "Edit\add geometry\cube" and "Edit\add geometry\cylinder". Then I selected object "pCube1" in the "Scene" window in the right panel, activated tab "Position" and setted Y translation to 2.5. The cube moved above the cylinder.
Then I opened then scripting console. I initialized a variable to the cube by
c = lux.getSceneTree().find(name = "pCube1")[0]
print(c)

<lux.SceneNode object at 0x28f82a0, name: "pCube1", kind: Object>

As the print instruction show I got the right object.

I created a matrix with
t = luxmath.Matrix().makeIdentity().makeTranslate(luxmath.Vector(0, 1, 0))
and applied it to the cube:
c.applyTransform(t)
The cube moved one unit above its current position. Applying to transform again moved the cube again.

So far it's good.

I then decided to move the cube back to it's original position. For this I created an identity matrix
id = luxmath.Matrix().makeIdentity()
and applied it absolutely
c.applyTransform(id, absolute = True)

I expected the cube to move back just above the cylinder or to the reference frame origin. But the cube moved under the cylinder at position Y=-5 (from Y=4.5). Applying the transform again moved the cube back at Y=4.5. In fact every application of the transform switch the cube between the two positions.
Since the transformation is supposed to be absolute I expected to new position to be the same relative to the reference frame, not to change between two places.

Since I am new to both Keyshot and Python scripting there may be something obvious I didn't catch. Does anybody have an idea of what is happening ?

I am using Keyshot 6.1.72 64bits on Windows 7.

In a related note, is there a way to get the current position/orientation/transform matrix of a SceneNode so it can be saved for future use ?

Thanks