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

Definition at line 33 of file eggTransform.h.

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 137 of file eggTransform.I.

References add_matrix4().

Referenced by clear_transform().

◆ add_matrix4()

void EggTransform::add_matrix4 ( const LMatrix4d mat)
inline

Appends an arbitrary 4x4 matrix to the current transform.

Definition at line 149 of file eggTransform.I.

References has_transform().

Referenced by add_matrix3(), EggSaver::add_node(), MayaToEggConverter::clear(), MaxToEggConverter::convert(), and DAEToEggConverter::get_input_units().

◆ 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 102 of file eggTransform.cxx.

References add_rotx(), and LMatrix4d::rotate_mat_normaxis().

Referenced by add_translate3d().

◆ add_rotate3d() [1/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 161 of file eggTransform.cxx.

References LMatrix4d::rotate_mat().

Referenced by EggSaver::add_node(), add_rotz(), DAEToEggConverter::get_input_units(), and FltToEggLevelState::set_transform().

◆ add_rotate3d() [2/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 178 of file eggTransform.cxx.

References add_scale2d(), LQuaterniond::get_angle(), and LQuaterniond::get_axis().

◆ 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 116 of file eggTransform.cxx.

References add_roty(), and LMatrix4d::rotate_mat_normaxis().

Referenced by add_rotate2d().

◆ 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 131 of file eggTransform.cxx.

References add_rotz(), and LMatrix4d::rotate_mat_normaxis().

Referenced by add_rotx().

◆ 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 146 of file eggTransform.cxx.

References add_rotate3d(), and LMatrix4d::rotate_mat_normaxis().

Referenced by add_roty().

◆ add_scale2d()

void EggTransform::add_scale2d ( const LVecBase2d scale)

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

Definition at line 191 of file eggTransform.cxx.

References add_scale3d(), and LMatrix4d::scale_mat().

Referenced by add_rotate3d().

◆ add_scale3d()

void EggTransform::add_scale3d ( const LVecBase3d scale)

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

Definition at line 206 of file eggTransform.cxx.

References add_uniform_scale(), and LMatrix4d::scale_mat().

Referenced by EggSaver::add_node(), add_scale2d(), DAEToEggConverter::get_input_units(), and 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 72 of file eggTransform.cxx.

References add_translate3d(), and LMatrix4d::translate_mat().

◆ add_translate3d()

void EggTransform::add_translate3d ( const LVector3d translate)

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

Definition at line 86 of file eggTransform.cxx.

References add_rotate2d(), and LMatrix4d::translate_mat().

Referenced by EggSaver::add_node(), add_translate2d(), MayaToEggConverter::clear(), DAEToEggConverter::get_input_units(), and FltToEggLevelState::set_transform().

◆ add_uniform_scale()

void EggTransform::add_uniform_scale ( double  scale)

Appends a uniform scale to the current transform.

Definition at line 220 of file eggTransform.cxx.

References LMatrix4d::scale_mat(), and write().

Referenced by add_scale3d().

◆ clear_transform()

void EggTransform::clear_transform ( )
inline

Resets the transform to empty, identity.

Definition at line 125 of file eggTransform.I.

References add_matrix3().

Referenced by MayaToEggConverter::clear(), EggGroup::clear_default_pose(), EggPrimitive::copy_vertices(), 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 344 of file eggTransform.I.

References get_component_mat4(), and LMatrix3d::ident_mat().

Referenced by get_component_vec3(), and EggLoader::make_polyset().

◆ 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 358 of file eggTransform.I.

References LMatrix4d::ident_mat().

Referenced by get_component_mat3(), and EggLoader::make_polyset().

◆ 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 299 of file eggTransform.I.

References get_component_vec2().

Referenced by get_component_type(), and EggLoader::make_polyset().

◆ get_component_type()

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

Returns the type of the nth component.

Definition at line 284 of file eggTransform.I.

References get_component_number().

Referenced by get_num_components(), and EggLoader::make_polyset().

◆ 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 314 of file eggTransform.I.

References get_component_vec3(), and LVector2d::zero().

Referenced by get_component_number(), and EggLoader::make_polyset().

◆ 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 330 of file eggTransform.I.

References get_component_mat3(), and LVector3d::zero().

Referenced by get_component_vec2(), and EggLoader::make_polyset().

◆ get_num_components()

int EggTransform::get_num_components ( ) const
inline

Returns the number of components that make up the transform.

Definition at line 274 of file eggTransform.I.

References get_component_type().

Referenced by EggLoader::make_polyset(), and transform_is_identity().

◆ 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 234 of file eggTransform.I.

References get_transform3d(), has_transform3d(), and LMatrix3d::ident_mat().

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

◆ 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 251 of file eggTransform.I.

References transform_is_identity().

Referenced by XFileMaker::add_tree(), MayaToEggConverter::clear(), MaxToEggConverter::convert(), EggPrimitive::copy_vertices(), XFileAnimationSet::create_hierarchy(), CharacterMaker::egg_to_slider(), get_transform2d(), 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 163 of file eggTransform.I.

References has_transform2d().

Referenced by add_matrix4(), XFileMaker::add_tree(), EggRenderState::compare_to(), EggPrimitive::copy_vertices(), CharacterMaker::egg_to_slider(), EggRenderState::fill_state(), has_transform2d(), has_transform3d(), EggTexture::is_equivalent_to(), EggLoader::make_polyset(), and EggTexture::sorts_less_than().

◆ 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 180 of file eggTransform.I.

References has_transform(), and set_transform2d().

Referenced by TextureReference::from_egg(), has_transform(), 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 210 of file eggTransform.I.

References has_transform(), and set_transform3d().

Referenced by EggPrimitive::copy_vertices(), get_transform2d(), and set_transform2d().

◆ 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 192 of file eggTransform.I.

References has_transform3d().

Referenced by MayaToEggConverter::clear(), has_transform2d(), and 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 222 of file eggTransform.I.

References get_transform2d().

Referenced by EggSaver::add_node(), MayaToEggConverter::clear(), VRMLToEggConverter::convert_file(), XFileToEggConverter::find_joint(), SoftNodeDesc::get_transform(), has_transform3d(), and 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 262 of file eggTransform.I.

References LMatrix4d::almost_equal(), get_num_components(), and LMatrix4d::ident_mat().

Referenced by EggPrimitive::copy_vertices(), get_transform3d(), EggTexture::is_equivalent_to(), and EggTexture::sorts_less_than().

◆ write()

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

Writes the transform to the indicated stream in Egg format.

Definition at line 233 of file eggTransform.cxx.

References LMatrix4d::ident_mat().

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


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