Panda3D
Public Types | Public Member Functions | List of all members
EggTransform Class Reference

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. More...

Inheritance diagram for EggTransform:
EggGroup EggTexture EggBin

Public Types

enum  ComponentType {
  CT_invalid = 0, CT_translate2d = 1, CT_translate3d = 2, CT_rotate2d = 3,
  CT_rotx = 4, CT_roty = 5, CT_rotz = 6, CT_rotate3d = 7,
  CT_scale2d = 8, CT_scale3d = 9, CT_uniform_scale = 10, CT_matrix3 = 11,
  CT_matrix4 = 12
}
 

Public Member Functions

 __init__ ()
 
 __init__ (const EggTransform copy)
 
 addMatrix3 (const LMatrix3d mat)
 Appends an arbitrary 3x3 matrix to the current transform. More...
 
 addMatrix4 (const LMatrix4d mat)
 Appends an arbitrary 4x4 matrix to the current transform. More...
 
 addRotate2d (double angle)
 Appends a 2-d rotation to the current transform. More...
 
 addRotate3d (const LQuaterniond quat)
 Appends an arbitrary 3-d rotation to the current transform, expressed as a quaternion. More...
 
 addRotate3d (double angle, const LVector3d axis)
 Appends a 3-d rotation about an arbitrary axis to the current transform. More...
 
 addRotx (double angle)
 Appends a rotation about the X axis to the current transform. More...
 
 addRoty (double angle)
 Appends a rotation about the Y axis to the current transform. More...
 
 addRotz (double angle)
 Appends a rotation about the Z axis to the current transform. More...
 
 addScale2d (const LVecBase2d scale)
 Appends a possibly non-uniform scale to the current transform. More...
 
 addScale3d (const LVecBase3d scale)
 Appends a possibly non-uniform scale to the current transform. More...
 
 addTranslate2d (const LVector2d translate)
 Appends a 2-d translation operation to the current transform. More...
 
 addTranslate3d (const LVector3d translate)
 Appends a 3-d translation operation to the current transform. More...
 
 addUniformScale (double scale)
 Appends a uniform scale to the current transform. More...
 
 clearTransform ()
 Resets the transform to empty, identity. More...
 
const LMatrix3d getComponentMat3 (int n)
 Returns the 3x3 matrix associated with the nth component. More...
 
const LMatrix4d getComponentMat4 (int n)
 Returns the 4x4 matrix associated with the nth component. More...
 
double getComponentNumber (int n)
 Returns the solitary number associated with the nth component. More...
 
EggTransform::ComponentType getComponentType (int n)
 Returns the type of the nth component. More...
 
const LVecBase2d getComponentVec2 (int n)
 Returns the 2-component vector associated with the nth component. More...
 
const LVecBase3d getComponentVec3 (int n)
 Returns the 3-component vector associated with the nth component. More...
 
int getNumComponents ()
 Returns the number of components that make up the transform. More...
 
LMatrix3d getTransform2d ()
 Returns the overall transform as a 3x3 matrix. More...
 
const LMatrix4d getTransform3d ()
 Returns the overall transform as a 4x4 matrix. More...
 
bool hasTransform ()
 Returns true if the transform is nonempty, false if it is empty (no transform components have been added). More...
 
bool hasTransform2d ()
 Returns true if the transform is specified as a 2-d transform, e.g. More...
 
bool hasTransform3d ()
 Returns true if the transform is specified as a 3-d transform, e.g. More...
 
EggTransform operator= (const EggTransform copy)
 
 setTransform2d (const LMatrix3d mat)
 Sets the overall transform as a 3x3 matrix. More...
 
 setTransform3d (const LMatrix4d mat)
 Sets the overall transform as a 4x4 matrix. More...
 
bool transformIsIdentity ()
 Returns true if the described transform is identity, false otherwise. More...
 
 write (Ostream out, int indent_level, str label)
 Writes the transform to the indicated stream in Egg format. More...
 

Detailed Description

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.

Member Enumeration Documentation

◆ ComponentType

Enumerator
CT_invalid 
CT_translate2d 
CT_translate3d 
CT_rotate2d 
CT_rotx 
CT_roty 
CT_rotz 
CT_rotate3d 
CT_scale2d 
CT_scale3d 
CT_uniform_scale 
CT_matrix3 
CT_matrix4 

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

◆ __init__() [2/2]

__init__ ( const EggTransform  copy)

◆ addMatrix3()

addMatrix3 ( const LMatrix3d  mat)

Appends an arbitrary 3x3 matrix to the current transform.

◆ addMatrix4()

addMatrix4 ( const LMatrix4d  mat)

Appends an arbitrary 4x4 matrix to the current transform.

◆ addRotate2d()

addRotate2d ( double  angle)

Appends a 2-d rotation to the current transform.

The rotation angle is specified in degrees counterclockwise about the origin.

◆ addRotate3d() [1/2]

addRotate3d ( const LQuaterniond  quat)

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.

◆ addRotate3d() [2/2]

addRotate3d ( double  angle,
const LVector3d  axis 
)

Appends a 3-d rotation about an arbitrary axis to the current transform.

The rotation angle is specified in degrees counterclockwise about the axis.

◆ addRotx()

addRotx ( double  angle)

Appends a rotation about the X axis to the current transform.

The rotation angle is specified in degrees counterclockwise about the axis.

◆ addRoty()

addRoty ( double  angle)

Appends a rotation about the Y axis to the current transform.

The rotation angle is specified in degrees counterclockwise about the axis.

◆ addRotz()

addRotz ( double  angle)

Appends a rotation about the Z axis to the current transform.

The rotation angle is specified in degrees counterclockwise about the axis.

◆ addScale2d()

addScale2d ( const LVecBase2d  scale)

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

◆ addScale3d()

addScale3d ( const LVecBase3d  scale)

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

◆ addTranslate2d()

addTranslate2d ( const LVector2d  translate)

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

◆ addTranslate3d()

addTranslate3d ( const LVector3d  translate)

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

◆ addUniformScale()

addUniformScale ( double  scale)

Appends a uniform scale to the current transform.

◆ clearTransform()

clearTransform ( )

Resets the transform to empty, identity.

◆ getComponentMat3()

const LMatrix3d getComponentMat3 ( int  n)

Returns the 3x3 matrix associated with the nth component.

It is an error to call this if the component type is not CT_matrix3.

◆ getComponentMat4()

const LMatrix4d getComponentMat4 ( int  n)

Returns the 4x4 matrix associated with the nth component.

It is an error to call this if the component type is not CT_matrix4.

◆ getComponentNumber()

double getComponentNumber ( int  n)

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.

◆ getComponentType()

EggTransform::ComponentType getComponentType ( int  n)

Returns the type of the nth component.

◆ getComponentVec2()

const LVecBase2d getComponentVec2 ( int  n)

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.

◆ getComponentVec3()

const LVecBase3d getComponentVec3 ( int  n)

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.

◆ getNumComponents()

int getNumComponents ( )

Returns the number of components that make up the transform.

◆ getTransform2d()

LMatrix3d getTransform2d ( )

Returns the overall transform as a 3x3 matrix.

It is an error to call this if has_transform3d() is true.

◆ getTransform3d()

const LMatrix4d getTransform3d ( )

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.

◆ hasTransform()

bool hasTransform ( )

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.

◆ hasTransform2d()

bool hasTransform2d ( )

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.

◆ hasTransform3d()

bool hasTransform3d ( )

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.

◆ operator=()

EggTransform operator= ( const EggTransform  copy)

◆ setTransform2d()

setTransform2d ( const LMatrix3d  mat)

Sets the overall transform as a 3x3 matrix.

This completely replaces whatever componentwise transform may have been defined.

◆ setTransform3d()

setTransform3d ( const LMatrix4d  mat)

Sets the overall transform as a 4x4 matrix.

This completely replaces whatever componentwise transform may have been defined.

◆ transformIsIdentity()

bool transformIsIdentity ( )

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

◆ write()

write ( Ostream  out,
int  indent_level,
str  label 
)

Writes the transform to the indicated stream in Egg format.