Panda3D
Loading...
Searching...
No Matches
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...

#include "eggTransform.h"

Inheritance diagram for EggTransform:
EggGroup EggTexture EggBin

Public Types

enum  ComponentType {
  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
}
 

Public Member Functions

 EggTransform (const EggTransform &copy)
 
void add_matrix3 (const LMatrix3d &mat)
 Appends an arbitrary 3x3 matrix to the current transform.
 
void add_matrix4 (const LMatrix4d &mat)
 Appends an arbitrary 4x4 matrix to the current transform.
 
void add_rotate2d (double angle)
 Appends a 2-d rotation to the current transform.
 
void add_rotate3d (const LQuaterniond &quat)
 Appends an arbitrary 3-d rotation to the current transform, expressed as a quaternion.
 
void add_rotate3d (double angle, const LVector3d &axis)
 Appends a 3-d rotation about an arbitrary axis to the current transform.
 
void add_rotx (double angle)
 Appends a rotation about the X axis to the current transform.
 
void add_roty (double angle)
 Appends a rotation about the Y axis to the current transform.
 
void add_rotz (double angle)
 Appends a rotation about the Z axis to the current transform.
 
void add_scale2d (const LVecBase2d &scale)
 Appends a possibly non-uniform scale to the current transform.
 
void add_scale3d (const LVecBase3d &scale)
 Appends a possibly non-uniform scale to the current transform.
 
void add_translate2d (const LVector2d &translate)
 Appends a 2-d translation operation to the current transform.
 
void add_translate3d (const LVector3d &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 ()
 Resets the transform to empty, identity.
 
const LMatrix3d & get_component_mat3 (int n) const
 Returns the 3x3 matrix associated with the nth component.
 
const LMatrix4d & get_component_mat4 (int n) const
 Returns the 4x4 matrix associated with the nth component.
 
double get_component_number (int n) const
 Returns the solitary number associated with the nth component.
 
ComponentType get_component_type (int n) const
 Returns the type of the nth component.
 
const LVecBase2d & get_component_vec2 (int n) const
 Returns the 2-component vector associated with the nth component.
 
const LVecBase3d & get_component_vec3 (int n) const
 Returns the 3-component vector associated with the nth component.
 
int get_num_components () const
 Returns the number of components that make up the transform.
 
LMatrix3d get_transform2d () const
 Returns the overall transform as a 3x3 matrix.
 
const LMatrix4d & get_transform3d () const
 Returns the overall transform as a 4x4 matrix.
 
bool has_transform () const
 Returns true if the transform is nonempty, false if it is empty (no transform components have been added).
 
bool has_transform2d () const
 Returns true if the transform is specified as a 2-d transform, e.g.
 
bool has_transform3d () const
 Returns true if the transform is specified as a 3-d transform, e.g.
 
EggTransformoperator= (const EggTransform &copy)
 
void set_transform2d (const LMatrix3d &mat)
 Sets the overall transform as a 3x3 matrix.
 
void set_transform3d (const LMatrix4d &mat)
 Sets the overall transform as a 4x4 matrix.
 
bool transform_is_identity () const
 Returns true if the described transform is identity, false otherwise.
 
void write (std::ostream &out, int indent_level, const std::string &label) const
 Writes the transform to the indicated stream in Egg format.
 

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.

Definition at line 29 of file eggTransform.h.

Member Enumeration Documentation

◆ ComponentType

enum EggTransform::ComponentType

Definition at line 61 of file eggTransform.h.

Constructor & Destructor Documentation

◆ EggTransform() [1/2]

EggTransform::EggTransform ( )

Definition at line 20 of file eggTransform.cxx.

◆ EggTransform() [2/2]

EggTransform::EggTransform ( const EggTransform & copy)

Definition at line 30 of file eggTransform.cxx.

◆ ~EggTransform()

EggTransform::~EggTransform ( )
virtual

Definition at line 52 of file eggTransform.cxx.

Member Function Documentation

◆ add_matrix3()

void EggTransform::add_matrix3 ( const LMatrix3d & mat)
inline

Appends an arbitrary 3x3 matrix to the current transform.

Definition at line 122 of file eggTransform.I.

◆ add_matrix4()

void EggTransform::add_matrix4 ( const LMatrix4d & mat)
inline

Appends an arbitrary 4x4 matrix to the current transform.

Definition at line 131 of file eggTransform.I.

◆ add_rotate2d()

void EggTransform::add_rotate2d ( double angle)

Appends a 2-d rotation to the current transform.

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

Definition at line 83 of file eggTransform.cxx.

◆ add_rotate3d() [1/2]

void EggTransform::add_rotate3d ( 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.

Definition at line 144 of file eggTransform.cxx.

References add_rotate3d().

◆ add_rotate3d() [2/2]

void EggTransform::add_rotate3d ( 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.

Definition at line 130 of file eggTransform.cxx.

Referenced by add_rotate3d(), and FltToEggLevelState::set_transform().

◆ add_rotx()

void EggTransform::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.

Definition at line 94 of file eggTransform.cxx.

◆ add_roty()

void EggTransform::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.

Definition at line 106 of file eggTransform.cxx.

◆ add_rotz()

void EggTransform::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.

Definition at line 118 of file eggTransform.cxx.

◆ add_scale2d()

void EggTransform::add_scale2d ( const LVecBase2d & scale)

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

Definition at line 154 of file eggTransform.cxx.

◆ add_scale3d()

void EggTransform::add_scale3d ( const LVecBase3d & scale)

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

Definition at line 166 of file eggTransform.cxx.

Referenced by FltToEggLevelState::set_transform().

◆ add_translate2d()

void EggTransform::add_translate2d ( const LVector2d & translate)

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

Definition at line 59 of file eggTransform.cxx.

◆ add_translate3d()

void EggTransform::add_translate3d ( const LVector3d & translate)

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

Definition at line 70 of file eggTransform.cxx.

Referenced by FltToEggLevelState::set_transform().

◆ add_uniform_scale()

void EggTransform::add_uniform_scale ( double scale)

Appends a uniform scale to the current transform.

Definition at line 178 of file eggTransform.cxx.

◆ clear_transform()

void EggTransform::clear_transform ( )
inline

Resets the transform to empty, identity.

Definition at line 113 of file eggTransform.I.

Referenced by EggGroup::clear_default_pose(), and FltToEggLevelState::set_transform().

◆ get_component_mat3()

const LMatrix3d & EggTransform::get_component_mat3 ( int n) const
inline

Returns the 3x3 matrix associated with the nth component.

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

Definition at line 282 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_component_mat4()

const LMatrix4d & EggTransform::get_component_mat4 ( int n) const
inline

Returns the 4x4 matrix associated with the nth component.

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

Definition at line 293 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_component_number()

double EggTransform::get_component_number ( int n) const
inline

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.

Definition at line 248 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_component_type()

EggTransform::ComponentType EggTransform::get_component_type ( int n) const
inline

Returns the type of the nth component.

Definition at line 236 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_component_vec2()

const LVecBase2d & EggTransform::get_component_vec2 ( int n) const
inline

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.

Definition at line 259 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_component_vec3()

const LVecBase3d & EggTransform::get_component_vec3 ( int n) const
inline

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.

Definition at line 271 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_num_components()

int EggTransform::get_num_components ( ) const
inline

Returns the number of components that make up the transform.

Definition at line 228 of file eggTransform.I.

Referenced by CPT(), and write().

◆ get_transform2d()

LMatrix3d EggTransform::get_transform2d ( ) const
inline

Returns the overall transform as a 3x3 matrix.

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

Definition at line 197 of file eggTransform.I.

References has_transform3d().

Referenced by TextureReference::from_egg(), and XFileVertex::set_from_egg().

◆ get_transform3d()

const LMatrix4d & EggTransform::get_transform3d ( ) const
inline

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.

Definition at line 211 of file eggTransform.I.

Referenced by XFileAnimationSet::create_hierarchy(), EggTexture::is_equivalent_to(), and EggTexture::sorts_less_than().

◆ has_transform()

bool EggTransform::has_transform ( ) const
inline

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.

Definition at line 142 of file eggTransform.I.

Referenced by EggRenderState::fill_state(), has_transform2d(), has_transform3d(), EggTexture::is_equivalent_to(), EggTexture::sorts_less_than(), EggGroup::write(), and EggTexture::write().

◆ has_transform2d()

bool EggTransform::has_transform2d ( ) const
inline

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.

Definition at line 155 of file eggTransform.I.

References has_transform().

Referenced by TextureReference::from_egg(), and XFileVertex::set_from_egg().

◆ has_transform3d()

bool EggTransform::has_transform3d ( ) const
inline

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.

Definition at line 178 of file eggTransform.I.

References has_transform().

Referenced by get_transform2d().

◆ operator=()

EggTransform & EggTransform::operator= ( const EggTransform & copy)

Definition at line 41 of file eggTransform.cxx.

◆ set_transform2d()

void EggTransform::set_transform2d ( const LMatrix3d & mat)
inline

Sets the overall transform as a 3x3 matrix.

This completely replaces whatever componentwise transform may have been defined.

Definition at line 164 of file eggTransform.I.

Referenced by TextureReference::update_egg().

◆ set_transform3d()

void EggTransform::set_transform3d ( const LMatrix4d & mat)
inline

Sets the overall transform as a 4x4 matrix.

This completely replaces whatever componentwise transform may have been defined.

Definition at line 187 of file eggTransform.I.

Referenced by FltToEggLevelState::set_transform().

◆ transform_is_identity()

bool EggTransform::transform_is_identity ( ) const
inline

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

Definition at line 219 of file eggTransform.I.

Referenced by EggTexture::is_equivalent_to(), and EggTexture::sorts_less_than().

◆ write()

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

Writes the transform to the indicated stream in Egg format.

Definition at line 188 of file eggTransform.cxx.

References get_component_mat3(), get_component_mat4(), get_component_number(), get_component_type(), get_component_vec2(), get_component_vec3(), get_num_components(), and indent().

Referenced by EggGroup::write(), and EggTexture::write().


The documentation for this class was generated from the following files: