Математика

Физика

Химия

Биология

Техника и    технологии

Transforms

A transform is a data object describing a model’s position, orientation, and scale in the 3D world. Transform methods can be used to move a given vector, light, camera, or model from its current location to a new position and/or orientation.

Transform creation method

Use the transform() method to create a new transform data object:

Method

Description

Returns

transform()

Creates a new transform initialized as the identity transform. The identity transform has no rotation and a vector position of (0,0,0)

A new transform object

 

Transform properties

Use these properties to work with transforms:

Property

Access

Description

Default

position

Get and set

Script vector object describing the position of a transform with the value vector(xOffset, yOffset, zOffset). A model.transform position represents the model’s position in relation to its parent.

vector
(0,0,0)

scale

Get and set

Script vector object describing the x, y, and z scale of the transform with the vector value vector(xScale, yScale, zScale).

Scaling is always applied model-relative.

vector
(1,1,1)

rotation

Get and set

Script vector object describing the xRotation, yRotation, and zRotation components of the transform with the value vector(xRotation, yRotation, zRotation), with the rotation values defined in degrees.

This value can vary because of the permissible types of transform operation. For example, translate followed by rotate gives a different value than rotate followed by translate, and the results can’t be differentiated after the fact from the rotational information alone.

The rotate() and preRotate() methods are the preferred way to modify a transform’s orientation. Rotation is generally relative to the object’s original orientation at the start of the movie.

vector
(0,0,0)

axisAngle

Get and set

A list including a vector and a floating-point value that describes this transform’s rotation as an axis/angle pair.

The vector represents the direction, and the angle represents the rotation around the vector.

[vector
(1.0000,
0.0000,
0.0000)
A]

x axis

Get and set

A vector representing the transform’s canonical x axis in transform space. Example:

transform.identity()
transform.rotate(0,90,0))
put transform.xaxis
--vector(0,0,-1)

Canonical means reduced to the simplest possible mathematical expression.

vector
(1,0,0)

y axis

Get and set

A vector representing the transform’s canonical y axis in transform space. Example:

transform.identity()
transform.rotate(90,0,0)
put transform.yaxis
--vector(0,0,1)

vector
(0,1,0)

z axis

Get and set

A vector representing the transform’s canonical z axis in transform space. Example:

transform.identity()
transform.rotate(0,90,0)
put transform.zaxis
--vector(1,0,0)

vector
(0,0,1)

Transform methods

Use these methods to work with transforms:

Method

Description

Returns

rotate
(
xAngle,
yAngle, zAngle
)

Applies a rotation transformation after the current transformation:

model.transform.identity()

model.transform.translate(100,0,0)

model.transform.rotate(0,0,90)

After this series of transformations, performed in this order, the model’s local origin will be at (0,100,0), assuming the model’s parent is the world.

Nothing

preRotate
(
xAngle,
yAngle, zAngle
)

Applies a rotation transformation before the current transformation:

model.transform.identity()
model.transform.translate(100,0,0)
model.transform.preRotate(0,0,90)

After this series of transformations, performed in this order, the model’s local origin will be at (100,0,0), assuming the model’s parent is the world.

Nothing

rotate
(
point,
vector, angle
)

Similar to transform.rotate(xAngle, yAngle, zAngle), except that the arguments are two vectors specifying an axis of rotation as a point and a vector, plus an angle specifying the clockwise rotation around that axis:

model.transform.identity()
model.transform.translate(-50,0,0)
model.transform.rotate(vector(100,0,0) vector(0,1,0))

After this series of transformations, performed in this order, the model’s local origin will be at (250,0,0), assuming the model’s parent is the world.

Nothing

preRotate
(
point,
vector, angle
)

Similar to transform.preRotate(xAngle, yAngle, zAngle), except that the arguments are two vectors specifying an axis of rotation as a point and a vector, plus an angle specifying the clockwise rotation around that axis.

model.transform.identity()
model.transform.translate(-50,0,0)
model.transform.preRotate(vector(100,0,0) vector(0,1,0))

After this series of transformations, performed in this order, the model’s local origin will be at (150,0,0), assuming the model’s parent is the world.

Nothing

translate
(
xIncrement,yIncrement,zIncrement)

Translates the position of the transform relative to the transform’s current orientation:

model.transform.identity()
model.transform.rotate(0,90,0)
model.transform.translate(100,0,0)

After this series of transformations, performed in this order, the model’s local origin will be at (100,0,0), assuming the model’s parent is the world.

Nothing

preTranslate
(
xIncrement,
yIncrement,

zIncrement)

Translates the position of the transform before the current transformation:

model.transform.identity()
model.transform.rotate(0,90,0)
model.transform.translate(100,0,0)

After this series of transformations, performed in this order, the model’s local origin will be at (0,0,100), assuming the model’s parent is the world.

Nothing

multiply
(
transform2)

Alters the original transform by applying the positional/rotational/scaling effects of transform2 to the original transform.

If transform2 describes a rotation of 90° around the x axis and this transform describes a translation of 100 units in the y axis, transform.multiply(transform2) alters this transform so that it describes a translation followed by a rotation.

Nothing

preMultiply
(
transform2)

Alters the original transform by preapplying the positional/rotational/scaling effects of transform2 to the original transform.

If transform2 describes a rotation of 90° around the x axis and this transform describes a translation of 100 units in the y axis, transform.preMultiply(transform2) alters this transform so that it describes a rotation followed by a translation.

Nothing

interpolate

(oTransform2,
fPercentage)

Returns a new transform by interpolating from the original transform to transform2 by fPercentage. The value of fPercentage should be between 0 and 100.

A new transform object

interpolateTo
(oTransform2,
fPercentage)

Modifies the existing transform by fPercentage. The value of fPercentage should be between 0 and 100.

Nothing

duplicate()

Returns a new transform that is a copy of the original transform.

A new transform object

identity

Resets the transform to an identity transform:

position: --0,0,0

rotation: 0,00

scale: 1,1,1

Nothing

invert()

Turns the transform into the inverse of its previous position and rotation. If you multiply a vector by a transform, the rotational and positional changes described by the transform are applied to the vector. Inverting the transform and multiplying the vector again restores the vector to its original.

Nothing

inverse()

Same as invert() except that the original transform is unaffected.

A new transform object

 

Transform operator

Use the asterisk (*) to multiply two transforms:

Operator

Description

Returns

transform1 *
transform2

Returns a new transform that is the product of the two original transforms. Useful for combining the effects of two transforms.

A new transform object

transform (property)

Usage

member(whichCastmember).node(whichNode).transform
member(whichCastmember).node(whichNode).transform.transformProperty
member(whichCastmember).model(whichModel).bonesPlayer.bone[boneID].transform
member(whichCastmember).model(whichModel).bonesPlayer.bone[boneID].transform.transformProperty

                

Description

3D property and command; allows you to get or set the transform associated with a particular node or a specific bone within a model using the bonesPlayer modifier. As a command, transform provides access to the various commands and properties of the transform object. A node can be a camera, group, light or model object.

For node objects, this property defaults to the identity transform. A node’s transform defines the position, rotation and scale of the node relative to is parent object. If a node’s parent is the World group object, then the transform property of the node has the same value as is returned by the getWorldTransform() command.

For bones within models using the bonesPlayer modifier, this property defaults in value to the transform assigned to the bone upon creation of the model file. The transform of a bone represents the bone’s rotation relative to its parent bone and its position relative to its original joint position. The original joint position is determine upon creation of the model file.

You can use the following transform commands and properties with the transform property of node objects:

Note: This section only contains summaries, see the individual entries for more detailed information.

  • preScale applies scaling before the current positional, rotational, and scale offsets held by the transform.
  • preTranslate applies a translation before the current positional, rotational, and scale offsets held by the transform.
  • preRotate applies a rotation before the current positional, rotational, and scale offsets held by the transform.
  • scale (command) applies scaling after the current positional, rotational, and scale offsets held by the transform.
  • scale (transform) allows you to get or set the degree of scaling of the transform.
  • translate applies a translation after the current positional, rotational, and scale offsets held by the transform.
  • rotate applies a rotation after the current positional, rotational, and scale offsets held by the transform.
  • position (transform) allows you to get or set the positional offset of the transform.
  • rotation (transform) allows you to get or set the rotational offset of the transform.

If you want to modify the transform property of a bone within a model, then you must store a copy of the original transform of the bone, modify the stored copy using the above commands and properties, then reset the bone’s transform property so that it is equal to the modified transform. For example:

t = member("character").model("biped").bonesPlayer.bone[38].transform.duplicate()
t.translate(25,0,-3)
member("character").model("biped").bonesPlayer.bone[38].transform = t

                                                

Parameters

None.

Example

This Lingo shows the transform of the model box, followed by the position and rotation properties of the transform:

put member("3d world").model("box").transform
-- transform(1.000000,0.000000,0.000000,0.000000, 0.000000,1.000000,0.000000,0.000000, 0.000000,0.000000,1.000000,0.000000, -94.144844,119.012825,0.000000,1.000000)
put member("3d world").model("box").transform.position
-- vector(-94.1448, 119.0128, 0.0000)
put member("3d world").model("box").transform.rotation
--vector(0.0000, 0.0000, 0.0000)

                                                

 

Назад

 

Hosted by uCoz