[Closed] Finding Absolute Postition after Linked Movement
I’ve seen some threads that were close but to this topic but doesn’t quite answer my question because I an trying to find an object’s absolute world position after moving that object using a link constraint.
Say I have $box001.pos = [0,0,0]
I put a link constraint on it and link it to, say, $sphere001, and move $sphere001 to [100,-100,0].
At that point I link $box001 to the World.
Later, I want to move $box001 to an absolute World position, say [25, 25, 0]
Using $box.pos = [25, 25, 0], the $box001 winds up at [125, -75, 0] because $box001.pos has been offset relative to $sphere001’s movement.
$box001’s node is actually located at [125, -75, 0] but
$box001.pos returns [25, 25, 0] (even though $box001 is truly [125, -75, 0])
in coordsys world $box001.pos returns [25, 25, 0]
$box001.center is close but returns [125, -75, <num> (depending on the height)] and I don’t want have to keep offsetting for the height of my $box001.
$box.transform.position returns [125, -75, 0] but I can’t seem to be able to actually move the object using that control.
$box001.node returns an error.
Apologies if this is a simple question but there something like .pos that returns the absolute world value that is not affected by linked movements?
an objects .pos & .rotation are usually derived form the animation controller, and are never absolute.
an objects .transform value is always absolute.
try:
$box001.transform.pos
Edit: oh I see you are trying to write a value not read it.
You can set obj.transform but not individual transform components like obj.transform.pos
There is probably a way to do this by ripping apart the Pos, rotate and scale components of and rebuilding a new transform value, as Bobo explains in his CG Academy Video Series
But I would simply spawn a point helper where I want the box to go and then set $Box001.transform=$point01.transform
Of course, make a point at the target location and align my object to it.
:banghead:
I’m kind of secretly glad that the way to accomplish what I asked for is
by ripping apart the Pos, rotate and scale components of and rebuilding a new transform value
Makes me feel like it was a reasonable request to be posted on a forum. Thanks for the links!
values of #pos, #rotation, and #scale are in parent coordinate system
there is a way how to set transsform position part, and apply transform to a node:
tm = node.transform
tm[4] = pos -- absolute (world) position
node.transform = tm
tm = node.transform
tm[4] = pos -- absolute (world) position
node.transform = tm
So, if I understand this correctly…
You make an array “tm”, populated with the node.transform information.
Then you change tm[4] (the position information)
Then you assign all of the array’s information back to node.transform
Is that what I’m seeing here?
here is what it means:
tm = node.tramsform
makes a copy of a specified node transform which is a Matrix3 value
tm[4] = pos
sets row4 (which is position part of matrix3) using a specified position
node.transform = tm
sets specified matrix3 value as world transform of a specified node
b = box()
print b.pos
tm = b.transform
tm[4] = [10,0,0]
print tm
b.transform = tm
Wow! Thank you!
This is exactly what I was looking for.
Thank you both!
:bowdown: