Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions
EggXfmSAnim Class Reference

This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that specify the nine components of a transformation. More...

#include "eggXfmSAnim.h"

Inheritance diagram for EggXfmSAnim:
EggGroupNode EggNode EggNamedObject EggObject Namable TypedReferenceCount MemoryBase TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Member Functions

 EggXfmSAnim (const string &name="", CoordinateSystem cs=CS_default)
 EggXfmSAnim (const EggXfmAnimData &convert_from)
 Converts the older-style XfmAnim table to the newer-style XfmSAnim table.
 EggXfmSAnim (const EggXfmSAnim &copy)
void add_component_data (const string &component_name, double value)
 Adds a new row to the named component (one of matrix_component_letters) of the table.
void add_component_data (int component, double value)
 Adds a new row to the indicated component (0-12) of the table.
bool add_data (const LMatrix4d &mat)
 Adds a new matrix to the table, by adding a new row to each of the subtables.
void clear_data ()
 Removes all data from the table.
void clear_fps ()
void clear_order ()
virtual TypeHandle force_init_type ()
CoordinateSystem get_coordinate_system () const
 Returns the coordinate system this table believes it is defined within.
double get_fps () const
 This is only valid if has_fps() returns true.
int get_num_rows () const
 Returns the effective number of rows in the table.
const string & get_order () const
virtual TypeHandle get_type () const
void get_value (int row, LMatrix4d &mat) const
 Returns the value of the aggregate row of the table as a matrix.
bool has_fps () const
bool has_order () const
virtual bool is_anim_matrix () const
 Returns true if this node represents a table of animation transformation data, false otherwise.
void normalize ()
 The inverse operation of optimize(), this ensures that all the sub-tables have the same length by duplicating rows as necessary.
EggXfmSAnimoperator= (const EggXfmSAnim &copy)
void optimize ()
 Optimizes the table by collapsing redundant sub-tables.
void optimize_to_standard_order ()
 Optimizes the table by collapsing redundant sub-tables, and simultaneously ensures that the order string is the standard order (which is the same as that supported by compose_matrix() and decompose_matrix()).
void set_fps (double fps)
void set_order (const string &order)
bool set_value (int row, const LMatrix4d &mat)
 Replaces the indicated row of the table with the given matrix.
virtual void write (ostream &out, int indent_level) const
 Writes the data to the indicated output stream in Egg format.

Static Public Member Functions

static void compose_with_order (LMatrix4d &mat, const LVecBase3d &scale, const LVecBase3d &shear, const LVecBase3d &hpr, const LVecBase3d &trans, const string &order, CoordinateSystem cs)
 Composes a matrix out of the nine individual components, respecting the order string.
static TypeHandle get_class_type ()
static const string & get_standard_order ()
 Returns the standard order of matrix component composition.
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.

Protected Member Functions

virtual void r_mark_coordsys (CoordinateSystem cs)
 This is only called immediately after loading an egg file from disk, to propagate the value found in the CoordinateSystem entry (or the default Y-up coordinate system) to all nodes that care about what the coordinate system is.
virtual void r_transform (const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs)
 Applies the indicated transform to all the rows of the table.

Detailed Description

This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that specify the nine components of a transformation.

It's implemented as a group that can contain any number of EggSAnimData children.

Definition at line 33 of file eggXfmSAnim.h.


Constructor & Destructor Documentation

EggXfmSAnim::EggXfmSAnim ( const EggXfmAnimData convert_from)

Member Function Documentation

void EggXfmSAnim::add_component_data ( const string &  component_name,
double  value 
)

Adds a new row to the named component (one of matrix_component_letters) of the table.

Definition at line 607 of file eggXfmSAnim.cxx.

References EggGroupNode::add_child(), EggAnimData::add_data(), and EggGroupNode::find_child().

Referenced by add_component_data(), and SoftNodeDesc::get_joint_transform().

void EggXfmSAnim::add_component_data ( int  component,
double  value 
)

Adds a new row to the indicated component (0-12) of the table.

Definition at line 629 of file eggXfmSAnim.cxx.

References add_component_data().

bool EggXfmSAnim::add_data ( const LMatrix4d mat)

Adds a new matrix to the table, by adding a new row to each of the subtables.

This is a convenience function that treats the table of tables as if it were a single table of matrices. It is an error to call this if any SAnimData children of this node have an improper name (e.g. not a single letter, or not one of "ijkabchprxyz").

This function has the further requirement that all nine of the subtables must exist and be of the same length. Furthermore, the order string must be the standard order string, which matches the system compose_matrix() and decompose_matrix() functions.

Thus, you probably cannot take an existing EggXfmSAnim object and start adding matrices to the end; you must clear out the original data first. (As a special exception, if no tables exist, they will be created.) The method normalize() will do this for you on an existing EggXfmSAnim.

This function may fail silently if the matrix cannot be decomposed into scale, shear, rotate, and translate. In this case, the closest approximation is added to the table, and false is returned.

Definition at line 525 of file eggXfmSAnim.cxx.

References EggGroupNode::add_child(), LMatrix4d::almost_equal(), EggGroupNode::find_child(), get_standard_order(), get_value(), and TypedObject::is_of_type().

Referenced by XFileAnimationSet::create_hierarchy(), EggMatrixTablePointer::make_new_joint(), EggXfmAnimData::r_transform(), and r_transform().

void EggXfmSAnim::clear_data ( ) [inline]

Removes all data from the table.

It does this by removing all of its children.

Definition at line 186 of file eggXfmSAnim.I.

void EggXfmSAnim::compose_with_order ( LMatrix4d mat,
const LVecBase3d scale,
const LVecBase3d shear,
const LVecBase3d hpr,
const LVecBase3d trans,
const string &  order,
CoordinateSystem  cs 
) [static]

Composes a matrix out of the nine individual components, respecting the order string.

The components will be applied in the order indicated by the string.

Definition at line 232 of file eggXfmSAnim.cxx.

References LVector3d::forward(), LMatrix4d::ident_mat(), LVector3d::right(), LMatrix4d::rotate_mat_normaxis(), LMatrix4d::scale_shear_mat(), LMatrix4d::translate_mat(), and LVector3d::up().

Referenced by EggXfmAnimData::get_value(), and get_value().

CoordinateSystem EggXfmSAnim::get_coordinate_system ( ) const [inline]

Returns the coordinate system this table believes it is defined within.

This should always match the coordinate system of the EggData structure that owns it. It is necessary to store it here because the meaning of the h, p, and r columns depends on the coordinate system.

Definition at line 175 of file eggXfmSAnim.I.

Referenced by EggXfmAnimData::EggXfmAnimData().

double EggXfmSAnim::get_fps ( ) const [inline]

This is only valid if has_fps() returns true.

Definition at line 98 of file eggXfmSAnim.I.

Referenced by EggXfmAnimData::EggXfmAnimData(), and write().

Returns the effective number of rows in the table.

This is actually the number of rows of the smallest subtable larger than one row. This is a convenience function that treats the table of tables as if it were a single table of matrices.

Definition at line 295 of file eggXfmSAnim.cxx.

References EggSAnimData::get_num_rows().

Referenced by EggXfmAnimData::EggXfmAnimData(), get_value(), and r_transform().

const string & EggXfmSAnim::get_standard_order ( ) [inline, static]

Returns the standard order of matrix component composition.

This is what the order string must be set to in order to use set_value() or add_data() successfully.

Definition at line 156 of file eggXfmSAnim.I.

Referenced by add_data(), normalize(), optimize_to_standard_order(), and set_value().

void EggXfmSAnim::get_value ( int  row,
LMatrix4d mat 
) const

Returns the value of the aggregate row of the table as a matrix.

This is a convenience function that treats the table of tables as if it were a single table of matrices. It is an error to call this if any SAnimData children of this node have an improper name (e.g. not a single letter, or not one of "ijkabchprxyz").

Definition at line 329 of file eggXfmSAnim.cxx.

References compose_with_order(), EggSAnimData::get_num_rows(), get_num_rows(), and EggSAnimData::get_value().

Referenced by add_data(), r_transform(), and set_value().

static void EggXfmSAnim::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from EggGroupNode.

Definition at line 103 of file eggXfmSAnim.h.

References EggGroupNode::init_type().

bool EggXfmSAnim::is_anim_matrix ( ) const [virtual]

Returns true if this node represents a table of animation transformation data, false otherwise.

Reimplemented from EggNode.

Definition at line 157 of file eggXfmSAnim.cxx.

The inverse operation of optimize(), this ensures that all the sub-tables have the same length by duplicating rows as necessary.

This is needed before doing operations like add_data() or set_value() on an existing table.

Definition at line 135 of file eggXfmSAnim.cxx.

References get_standard_order().

Optimizes the table by collapsing redundant sub-tables, and simultaneously ensures that the order string is the standard order (which is the same as that supported by compose_matrix() and decompose_matrix()).

Definition at line 118 of file eggXfmSAnim.cxx.

References get_standard_order(), and optimize().

void EggXfmSAnim::r_mark_coordsys ( CoordinateSystem  cs) [protected, virtual]

This is only called immediately after loading an egg file from disk, to propagate the value found in the CoordinateSystem entry (or the default Y-up coordinate system) to all nodes that care about what the coordinate system is.

Reimplemented from EggGroupNode.

Definition at line 688 of file eggXfmSAnim.cxx.

void EggXfmSAnim::r_transform ( const LMatrix4d mat,
const LMatrix4d inv,
CoordinateSystem  to_cs 
) [protected, virtual]

Applies the indicated transform to all the rows of the table.

This actually forces the generation of a totally new set of rows, and will quietly change the order to the standard order (if it is different).

Reimplemented from EggGroupNode.

Definition at line 645 of file eggXfmSAnim.cxx.

References add_data(), get_num_rows(), get_value(), optimize(), LMatrix4d::set_row(), and EggGroupNode::steal_children().

bool EggXfmSAnim::set_value ( int  row,
const LMatrix4d mat 
)

Replaces the indicated row of the table with the given matrix.

This function can only be called if all the constraints of add_data(), below, are met. Call normalize() first if you are not sure.

The return value is true if the matrix can be decomposed and stored as scale, shear, rotate, and translate, or false otherwise. The data is set in either case.

Definition at line 433 of file eggXfmSAnim.cxx.

References LMatrix4d::almost_equal(), EggGroupNode::find_child(), get_standard_order(), get_value(), and TypedObject::is_of_type().

void EggXfmSAnim::write ( ostream &  out,
int  indent_level 
) const [virtual]

Writes the data to the indicated output stream in Egg format.

Reimplemented from EggGroupNode.

Definition at line 168 of file eggXfmSAnim.cxx.

References get_fps(), TypedObject::is_of_type(), EggSAnimData::write(), and EggNamedObject::write_header().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations