# EggTransform¶

class EggTransform

This represents the <Transform> entry of a group or texture node: a list of component transform operations, applied in order, that describe a net transform matrix.

This may be either a 3-d transform, and therefore described by a 4x4 matrix, or a 2-d transform, described by a 3x3 matrix.

Inheritance diagram

enum ComponentType
enumerator CT_invalid = 0
enumerator CT_translate2d = 1
enumerator CT_translate3d = 2
enumerator CT_rotate2d = 3
enumerator CT_rotx = 4
enumerator CT_roty = 5
enumerator CT_rotz = 6
enumerator CT_rotate3d = 7
enumerator CT_scale2d = 8
enumerator CT_scale3d = 9
enumerator CT_uniform_scale = 10
enumerator CT_matrix3 = 11
enumerator CT_matrix4 = 12
EggTransform(void)
EggTransform(EggTransform const &copy)
void add_matrix3(LMatrix3d const &mat)

Appends an arbitrary 3x3 matrix to the current transform.

void add_matrix4(LMatrix4d const &mat)

Appends an arbitrary 4x4 matrix to the current transform.

void add_rotate2d(double angle)

Appends a 2-d rotation to the current transform. The rotation angle is specified in degrees counterclockwise about the origin.

void add_rotate3d(double angle, LVector3d const &axis)
void add_rotate3d(LQuaterniond const &quat)

Appends a 3-d rotation about an arbitrary axis to the current transform. The rotation angle is specified in degrees counterclockwise about the axis.

Appends an arbitrary 3-d rotation to the current transform, expressed as a quaternion. This is converted to axis-angle notation for the egg file.

void add_rotx(double angle)

Appends a rotation about the X axis to the current transform. The rotation angle is specified in degrees counterclockwise about the axis.

void add_roty(double angle)

Appends a rotation about the Y axis to the current transform. The rotation angle is specified in degrees counterclockwise about the axis.

void add_rotz(double angle)

Appends a rotation about the Z axis to the current transform. The rotation angle is specified in degrees counterclockwise about the axis.

void add_scale2d(LVecBase2d const &scale)

Appends a possibly non-uniform scale to the current transform.

void add_scale3d(LVecBase3d const &scale)

Appends a possibly non-uniform scale to the current transform.

void add_translate2d(LVector2d const &translate)

Appends a 2-d translation operation to the current transform.

void add_translate3d(LVector3d const &translate)

Appends a 3-d translation operation to the current transform.

void add_uniform_scale(double scale)

Appends a uniform scale to the current transform.

void clear_transform(void)

Resets the transform to empty, identity.

LMatrix3d const &get_component_mat3(int n) const

Returns the 3x3 matrix associated with the nth component. It is an error to call this if the component type is not CT_matrix3.

LMatrix4d const &get_component_mat4(int n) const

Returns the 4x4 matrix associated with the nth component. It is an error to call this if the component type is not CT_matrix4.

double get_component_number(int n) const

Returns the solitary number associated with the nth component. In the case of a rotation, this is the angle in degrees to rotate; in the case of uniform scale, this is the amount of the scale. Other types do not use this property.

ComponentType get_component_type(int n) const

Returns the type of the nth component.

LVecBase2d const &get_component_vec2(int n) const

Returns the 2-component vector associated with the nth component. This may be the translate vector, rotate axis, or non-uniform scale. It is an error to call this if the component type does not use a 2-d vector property.

LVecBase3d const &get_component_vec3(int n) const

Returns the 3-component vector associated with the nth component. This may be the translate vector, rotate axis, or non-uniform scale. It is an error to call this if the component type does not use a 3-d vector property.

int get_num_components(void) const

Returns the number of components that make up the transform.

LMatrix3d get_transform2d(void) const

Returns the overall transform as a 3x3 matrix. It is an error to call this if has_transform3d() is true.

LMatrix4d const &get_transform3d(void) const

Returns the overall transform as a 4x4 matrix. It is valid to call this even if has_transform2d() is true; in this case, the 3x3 transform will be expanded to a 4x4 matrix.

bool has_transform(void) const

Returns true if the transform is nonempty, false if it is empty (no transform components have been added). This is true for either a 2-d or a 3-d transform.

bool has_transform2d(void) const

Returns true if the transform is specified as a 2-d transform, e.g. with a 3x3 matrix, or false if it is specified as a 3-d transform (with a 4x4 matrix), or not specified at all.

Normally, EggTextures have a 2-d matrix (but occasionally they use a 3-d matrix), and EggGroups always have a 3-d matrix.

bool has_transform3d(void) const

Returns true if the transform is specified as a 3-d transform, e.g. with a 4x4 matrix, or false if it is specified as a 2-d transform (with a 2x2 matrix), or not specified at all.

Normally, EggTextures have a 3-d matrix (but occasionally they use a 3-d matrix), and EggGroups always have a 3-d matrix.

void set_transform2d(LMatrix3d const &mat)

Sets the overall transform as a 3x3 matrix. This completely replaces whatever componentwise transform may have been defined.

void set_transform3d(LMatrix4d const &mat)

Sets the overall transform as a 4x4 matrix. This completely replaces whatever componentwise transform may have been defined.

bool transform_is_identity(void) const

Returns true if the described transform is identity, false otherwise.

void write(std::ostream &out, int indent_level, std::string const &label) const

Writes the transform to the indicated stream in Egg format.