PDA

View Full Version : Get Local transform in Maxscript


Monopoli
08-03-2007, 03:24 PM
Hi all!

Is there a way to get the local transform of an object in Maxscript?

Bye!
Alex

mustan9
08-03-2007, 03:35 PM
Read the manual.

MaxScript Language Reference / 3ds Max Objects / Node: MAXWrapper / Node Common Properties.

Monopoli
08-03-2007, 03:58 PM
Read the manual.

MaxScript Language Reference / 3ds Max Objects / Node: MAXWrapper / Node Common Properties.

Maybe I'm a super noob, or simply I'm stupid, but I had just looked at that page and now I've looked it again, but I can't find nothing about local transforms.

Maybe you can help me :)

mustan9
08-03-2007, 04:03 PM
That's ok.

Here I cut and paste from the manual.

I think you wanted <node>.transform
------------------------------------------------------------------------------------

Node Transform Properties

Unless otherwise noted, the following transform properties are always interpreted with respect to the current working coordinate system as defined by the currently active coordsys context (http://forums.cgsociety.org/Context_Expressions.htm). The default coordsys is world. The pos, rotation, and scale properties of a node are aliases to the corresponding subcontroller for the node's transform controller. If the transform controller does not have one of these subcontrollers, accessing the corresponding node property will result in an "Unknown property" error message. For example, the LookAt controller does not have a Rotation subcontroller, and the IK controller does not have any subcontrollers. You can still access the transform values using the Matrix3 properties of the node's transform property, for example, objpos=obj.transform.translationpart.

<node>.transform : Matrix3 -- can read/write to. If written to,

: the Matrix3 value is decomposed into its

: position, rotation, and scale values, and these

: values are stored in the respective position,

: rotation, and scale controllers, if those

: controllers exist and can be written to.

<node>.pos : Point3 --can use .position synonym throughout

<node>.pos.controller : Controller --can use .track synonym throughout

<node>.pos.isAnimated : Boolean, read-only --true if position is animated

<node>.pos.keys : MAXKeyArray

<node>.pos.track : Controller --synonym of .pos.controller

<node>.rotation : Quat

<node>.rotation.x_rotation : Float --X rotation of node

<node>.rotation.y_rotation : Float --Y rotation of node

<node>.rotation.z_rotation : Float --Z rotation of node

<node>.rotation.controller : Controller --can use .track synonym throughout

<node>.rotation.isAnimated : Boolean, read-only --true if rotation is animated

<node>.rotation.keys : MAXKeyArray

<node>.rotation.track : Controller --synonym of .rotation.controller

<node>.scale : Point3 -- fraction

<node>.scale.controller : Controller --can use .track synonym throughout

<node>.scale.isAnimated : Boolean, read-only --true if scale is animated

<node>.scale.keys : MAXKeyArray

<node>.scale.track : Controller --synonym of .scale.controller

<node>.dir : Point3 -- local z-axis direction vector

Rotates node so that the node's Z axis points in the specified direction. The node is rotated around its Z axis such that the Y axis points as much as possible in the world -Z direction.

Getting and setting <node>.dir now respects the current coordinate system. Previously, this property was always in world coordinates.

<node>.max : Point3, read-only --max coordinates of node's bounding box

<node>.min : Point3, read-only --min coordinates of node's bounding box

<node>.center : Point3 -- coordinates of center of node's bounding box

<node>.transform : Matrix3 -- node's main transformation matrix

Note

Rotation in the internal transformation matrices is left-handed in contradiction to the 3ds Max user interface and MAXScript. Take care when mixing rotation derived from these matrices and rotation used in rotation-related functions or from rotation properties.

<node>.pivot : Point3 -- node's pivot point position

<node>.objectOffsetPos : Point3

<node>.objectOffsetRot : Quat

<node>.objectOffsetScale : Point3

Node geometry's position, rotation, and scale offset from the pivot in world coordinates.

<node>.objectTransform : Matrix3, read-only

Node geometry's offset in world coordinates.

Script:

-- Setting a node's rotation relative to world space without

-- messing with its position:

fn setNodeWorldRotation theNode theRot =

(

in coordsys (transmatrix theNode.transform.pos)

theNode.rotation = theRot

)



setNodeWorldRotation $ (eulerangles 45 45 0)



See also

Using Node Transform Properties (http://forums.cgsociety.org/Using_Node_Transform_Properties.htm)

eek
08-03-2007, 04:16 PM
Controllers in max a relative to a transform space there working in - i.e there local. This is except position/orientation constraints which work in an additive world space (odd) method. To get a local value of an object you can call its controller:

$object.transform.controller[axis].value

e.g $box01.pos.controller[2].value

These methods rely on the object having a controller on its position or rotation. If you just do $.pos.x with an object with no parent or no controller it will be in world space.

Calling an objects transform $.transform.pos will call its matrix transformation relative to the true world space unless you transform it into a local or target space ($.transform * $target.transform) *inverse needed respectively.

CGTalk Moderation
08-03-2007, 04:16 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.