|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m3g.Object3D javax.microedition.m3g.Transformable
An abstract base class for Node and Texture2D, defining common methods for manipulating node and texture transformations.
Node transformations and texture transformations consist of four individual components: translation (T), orientation (R), scale (S) and a generic 4x4 matrix (M). Formally, a homogeneous vector p = (x, y, z, w), representing vertex coordinates (in Node) or texture coordinates (in Texture2D), is transformed into p' = (x', y', z', w') as follows:
See the Node and Texture2D class descriptions for more information on node transformations and texture transformations.
Transformable is an abstract class, and therefore has no public constructor. When a class derived from Transformable is instantiated, the attributes inherited from it will have the following default values:
The transformation components are initially set to identity so that they do not affect the texture coordinates or vertex coordinates in any way. Note that the orientation axis can be left undefined because the angle is zero.
Method Summary | |
void |
getCompositeTransform(Transform transform)
Retrieves the composite transformation matrix of this Transformable. |
void |
getOrientation(float[] angleAxis)
Retrieves the orientation component of this Transformable. |
void |
getScale(float[] xyz)
Retrieves the scale component of this Transformable. |
void |
getTransform(Transform transform)
Retrieves the matrix component of this Transformable. |
void |
getTranslation(float[] xyz)
Retrieves the translation component of this Transformable. |
void |
postRotate(float angle,
float ax,
float ay,
float az)
Multiplies the current orientation component from the right by the given orientation. |
void |
preRotate(float angle,
float ax,
float ay,
float az)
Multiplies the current orientation component from the left by the given orientation. |
void |
scale(float sx,
float sy,
float sz)
Multiplies the current scale component by the given scale factors. |
void |
setOrientation(float angle,
float ax,
float ay,
float az)
Sets the orientation component of this Transformable. |
void |
setScale(float sx,
float sy,
float sz)
Sets the scale component of this Transformable. |
void |
setTransform(Transform transform)
Sets the matrix component of this Transformable by copying in the given Transform. |
void |
setTranslation(float tx,
float ty,
float tz)
Sets the translation component of this Transformable. |
void |
translate(float tx,
float ty,
float tz)
Adds the given offset to the current translation component. |
Methods inherited from class javax.microedition.m3g.Object3D |
addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject |
Method Detail |
public void setOrientation(float angle, float ax, float ay, float az)
Sets the orientation component of this Transformable. The
orientation is specified such that looking along the rotation
axis, the rotation is angle
degrees clockwise.
Note that the axis does not have to be a unit vector.
angle
- angle of rotation about the axis, in degreesax
- X component of the rotation axisay
- Y component of the rotation axisaz
- Z component of the rotation axis
java.lang.IllegalArgumentException
- if the rotation axis (ax
ay az)
is zero and angle
is nonzerogetOrientation
,
preRotate
,
postRotate
public void preRotate(float angle, float ax, float ay, float az)
Multiplies the current orientation component from the left
by the given orientation. The orientation is given in axis-angle
format, as in setOrientation
.
Denoting the given orientation by R' and the current orientation by R, the new orientation is computed as follows:
Depending on the internal representation of orientations, the multiplication may be done with quaternions, matrices, or something else, as long as the resulting orientation is the same as it would be if matrices or quaternions were used.
angle
- angle of rotation about the axis, in degreesax
- X component of the rotation axisay
- Y component of the rotation axisaz
- Z component of the rotation axis
java.lang.IllegalArgumentException
- if the rotation axis (ax
ay az)
is zero and angle
is nonzerosetOrientation
,
postRotate
public void postRotate(float angle, float ax, float ay, float az)
Multiplies the current orientation component from the right
by the given orientation. Except for the multiplication order,
this method is equivalent to preRotate
.
Denoting the given orientation by R' and the current orientation by R, the new orientation is computed as follows:
angle
- angle of rotation about the axis, in degreesax
- X component of the rotation axisay
- Y component of the rotation axisaz
- Z component of the rotation axis
java.lang.IllegalArgumentException
- if the rotation axis (ax
ay az)
is zero and angle
is nonzerosetOrientation
,
preRotate
public void getOrientation(float[] angleAxis)
Retrieves the orientation component of this Transformable.
The returned axis and angle values are not necessarily the same that were last written to the orientation component. Instead, they may be any values that produce an equivalent result. For example, a 90 degree rotation about the positive Z axis is equivalent to a 270 degree rotation about the negative Z axis. In particular, if the rotation angle is zero, the returned rotation axis is undefined and may also be the zero vector.
angleAxis
- a float array to fill in with (angle
ax ay az)
java.lang.NullPointerException
- if angleAxis
is null
java.lang.IllegalArgumentException
- if angleAxis.length < 4
setOrientation
public void setScale(float sx, float sy, float sz)
Sets the scale component of this Transformable.
Note that if any of the scale factors are set to zero, this transformation becomes uninvertible. That, in turn, may cause certain operations to produce undefined results or to fail with an ArithmeticException.
sx
- scale along the X axissy
- scale along the Y axissz
- scale along the Z axisgetScale
,
scale
public void scale(float sx, float sy, float sz)
Multiplies the current scale component by the given scale factors. Denoting the current scale by (sx sy sz) and the given scale by (sx' sy' sz'), the new scale factors are computed as follows:
Since this is an operation on scalar values, the order of multiplication makes no difference. Unlike with the rotation component, separate methods for left and right multiplication are therefore not needed.
sx
- scale along the X axissy
- scale along the Y axissz
- scale along the Z axissetScale
public void getScale(float[] xyz)
Retrieves the scale component of this Transformable.
xyz
- a float array to fill in with (sx sy sz)
java.lang.NullPointerException
- if xyz
is null
java.lang.IllegalArgumentException
- if xyz.length < 3
setScale
public void setTranslation(float tx, float ty, float tz)
Sets the translation component of this Transformable.
tx
- translation along the X axisty
- translation along the Y axistz
- translation along the Z axisgetTranslation
,
translate
public void translate(float tx, float ty, float tz)
Adds the given offset to the current translation component. Denoting the current translation component by (tx ty tz) and the given offset by (tx' ty' tz'), the new translation component is computed as follows:
tx
- translation along the X axisty
- translation along the Y axistz
- translation along the Z axissetTranslation
public void getTranslation(float[] xyz)
Retrieves the translation component of this Transformable.
xyz
- a float array to fill in with (tx ty tz)
java.lang.NullPointerException
- if xyz
is null
java.lang.IllegalArgumentException
- if xyz.length < 3
setTranslation
public void setTransform(Transform transform)
Sets the matrix component of this Transformable by copying in the given Transform. This does not affect the separate translation, orientation and scale components.
A generic matrix component is required for transformations that can not be expressed in the component form efficiently, or at all. These include, for example, pivot transforms and non-axis-aligned scales.
If this Transformable is a Node object, the bottom row of the given matrix must be (0 0 0 1). Projective transformations are not supported in the scene graph so as to reduce run-time memory consumption and to accelerate rendering. Note, however, that arbitrary 4x4 modelview matrices are supported in the immediate mode.
transform
- the Transform object to copy in, or null to indicate
the identity matrix
java.lang.IllegalArgumentException
- if this Transformable is a Node and
the bottom row of transform
is not (0 0 0 1)getTransform
public void getTransform(Transform transform)
Retrieves the matrix component of this Transformable. This does not include the separate translation, orientation and scale components. The transformation is copied into the given Transform object.
transform
- the Transform object to receive the
transformation matrix
java.lang.NullPointerException
- if transform
is nullsetTransform
public void getCompositeTransform(Transform transform)
Retrieves the composite transformation matrix of this Transformable. The composite transformation matrix is the concatenation of the translation, rotation, scale and generic matrix components. Formally, C = T R S M. The composite transformation is copied into the given Transform object.
transform
- the Transform object to receive the composite
transformation matrix
java.lang.NullPointerException
- if transform
is null
|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |