[Closed] Strange transform coordinate system behavior
Hi there fellow scripters,
I have a problem that I’ve been tearing some hair out over.
When I have an object whose coordinates I call up through the “$object.pos” function, it returns the world space coordinates of that object (whether or not it’s parented to something else). But, when I call up the “$object.pos.controller.value” for the same object, it will only return the local coordinates of that object, even if I preface the function with “in coordsys world”.
The reason I need to get the world coordinates of the object through the “.pos.controller.value” parameters is because I’m using that controller to drive a positional float script (using the new variables capabilities of Max8, since dependsOn is obsolete)…and the new variables only support controllers or subanims (according to the error message that comes up when I try otherwise).
Does anyone understand my problem? And/or…anybody got an idea for a solution?
Basically, I’m looking for some way to tell my float script to look at the WORLD coordinates of the object’s position controller that it’s referencing, and not the local coordinates.
Any help is much appreciated!
WYAFISWYG
What You Ask For Is What You Get
In Max, each transformation controller saves data in parent space. Of course, of the object is “child of the world”. parent and world space are identical. Whenever you link an object to another, the controllers are being rebuilt to contain parent space info. So asking for the value of a key in a controller will always give you the value stored in the key, no matter what coordsys context you put the call in.
To get the world space, you would have to multiply the value by all transforms up the hierarchy, or use the .pos or transform.row4 property. You can set a variable in the script controller to point at the NODE, then use that variable to read the .pos inside the script’s code. This is legal practice (as opposed to using $SomeObject.pos) and should solve your problem.
I almost don’t have any idea about script controllers but on the local coordinates subject, you could transform the parent-space position to world-space by transforming the position vector of the object by its parent (if it exists) transformation matrix:
if obj.parent != undefined do
worldPosition = obj.pos.controller.value * obj.parent.transform
But as I’ve said, I’m not too much experienced with script controllers, so I don’t know if you can do that!.
Greets.