09-18-2005, 12:19 PM
While you can kind of do this with matrices or xform, your best bet is to either use a plugin or a constraint. getAttr which is needed for matrix stuff is bad/slow and should never be used in expressions. XForm command is also bad, since if you ever reference in the rig, unless you are using namespace, it will also not work and once again is slow. The best is to write a plugin that reads the matrix and outputs...may be fastest...
That said, xform -q -ws -t "myObject"; should return worldspace translates.
However if you don't want to write a plugin, and or don't really care but want a good way to read the rotation or translate in WHATEVER space you want, worldspace or relative to another object then just make a locator, constrain it to the real object, and parent the locator to the space you want to read in.
For example if you have "myObject" and it is in a hierarchy but you want it in world space.
1. Make locator
2. Point/Orient constrain locator To the myObject.
3. Parent locator to the world, or under a group in your rig that never movers/does not inherit transforms.
Now you can use "locator.tx" or whatever you want in your expression, and it will be in worldspace. If you parented the locator to a different object then the values would be in the relative coordinate space of the object you parented it to, also useful in many cases.
This type of thing in highly useful in any rig. The thing to remember is that the TX, TY, TZ, RX etc...is always a "local" values which means that it is always "relative to the parent". Constraints are effectively a "plugin" like I was talking about that does the math to figure out what those values should be regardless of where the locator is parented to... so by using a constraint, the values you get will always be correct, although rotation will be limited to -180 to +180.
09-18-2005, 02:21 PM
Thank you Michael. The constraint idea will work fine, I was just thinking I was missing something obvious like .wtx (which of course I tried ;) ). I might just write something so I don't have a bunch of extra locators in my scene.
09-18-2005, 07:14 PM
Yeah the worldMatrix mat, mat, and mat will always have the world pos but in MEL that requires a bad bad bad getAttr... :|
09-18-2005, 07:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.