Problem to translate an object to absolute position

Started by hakama, August 21, 2018, 03:47:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hakama

Hello,
I'm using KeyShot 7.3.40.
I'm having a problem when I try to translate an object to absolute position.
Following code does not translate an object. It doesn't give an error message either. If absolute=False then the object moves relatively.

M = luxmath.Matrix().makeIdentity().translate(luxmath.Vector((1, 0, 1)))
for node in root.find(name="Cube"):
   if node.isObject():
         node.applyTransform(M, absolute=True)

Morten Kristensen

Hi Heikki,

It works as intended. When you apply a transformation that is absolute then it matters what the transformation matrices are all the way to the root node. Let's say you have node B which is a child of node A, and you apply translate (1,0,1) absolutely. What happens is that you translate node A by (1,0,1) which affects the matrices down to node B. If node A's position is (2,2,2) and node B's position is (0,-2,0). Then applying translate (1,0,1) absolutely on node A yields (-1,-2,-1). But if it was done relatively it would have resulted in (1,-2,1).

If you want to move something to the absolute position (1,0,1) then you have to calculate the difference in the current position to that coordinate and then apply that transformation matrix instead.

I hope that helps.
Thanks!

hakama

Hi Morten,
I understand that it should work like that. However in my case applyTransform works only in relative mode. I tried to change scale values as well. If I use absolute mode then there is no change in the values of translation and scale. The object just don't move. Status of the script is succesfull in both cases.
regards, hakama

hakama

I just noticed that KeyShot Low Window shows the error when absolute option is used:

KeyShot 7.3.40 Log File - Thu Aug 30 14:56:00 2018
OS: Windows 10 64 bit
==================================================
(14:51:13) Invalid id [1072693248] specified for lux_object_from_id

My license info is:
KeyShot Version 7.3.40
Floating license
Feature:keyshot_enterprise