Panda3D
Classes | Public Member Functions | Friends

EggCharacterData Class Reference

Represents a single character, as read and collected from several models and animation files. More...

#include "eggCharacterData.h"

Inheritance diagram for EggCharacterData:
Namable MemoryBase

List of all members.

Classes

class  Model

Public Member Functions

 EggCharacterData (EggCharacterCollection *collection)
void add_model (int model_index, EggNode *model_root, EggData *egg_data)
 Indicates that the given model_index (with the indicated model_root) is associated with this character.
bool check_num_frames (int model_index)
 Walks through each component and ensures that all have the same number of frames of animation (except for those that contain 0 or 1 frames, of course).
void choose_optimal_hierarchy ()
 Chooses the best possible parent joint for each of the joints in the hierarchy, based on the score computed by EggJointData::score_reparent_to().
bool do_reparent ()
 Begins the process of restructuring the joint hierarchy according to the previous calls to reparent_to() on various joints.
size_t estimate_db_size () const
 Returns the estimated amount of memory, in megabytes, that will be required to perform the do_reparent() operation.
EggJointDatafind_joint (const string &name) const
 Returns the first joint found with the indicated name, or NULL if no joint has that name.
EggSliderDatafind_slider (const string &name) const
 Returns the slider with the indicated name, or NULL if no slider has that name.
EggComponentDataget_component (int n) const
 Returns the nth joint or slider in the character.
EggDataget_egg_data (int n) const
 Returns the EggData representing the egg file that defined this particular model.
double get_frame_rate (int model_index) const
 Returns the stated frame rate of the specified model.
EggJointDataget_joint (int n) const
 Returns the nth joint in the character joint hierarchy.
int get_model_index (int n) const
 Returns the model_index of the nth model associated with this character.
EggNodeget_model_root (int n) const
 Returns the model_root of the nth model associated with this character.
int get_num_components () const
 Returns the total number of joints and sliders in the character.
int get_num_frames (int model_index) const
 Returns the number of frames of animation of the indicated model.
int get_num_joints () const
 Returns the total number of joints in the character joint hierarchy.
int get_num_models () const
 Returns the total number of models associated with this character.
int get_num_sliders () const
 Returns the number of sliders in the character slider list.
EggJointDataget_root_joint () const
 Returns the root joint of the character hierarchy.
EggSliderDataget_slider (int n) const
 Returns the nth slider in the character slider list.
EggJointDatamake_new_joint (const string &name, EggJointData *parent)
 Creates a new joint as a child of the indicated joint and returns it.
EggSliderDatamake_slider (const string &name)
 Returns the slider matching the indicated name.
void rename_char (const string &name)
 Renames all of the models in the character data to the indicated name.
virtual void write (ostream &out, int indent_level=0) const

Friends

class EggCharacterCollection

Detailed Description

Represents a single character, as read and collected from several models and animation files.

This contains a hierarchy of EggJointData nodes representing the skeleton, as well as a list of EggSliderData nodes representing the morph channels for the character.

This is very similar to the Character class from Panda, in that it's capable of associating skeleton-morph animation channels with models and calculating the vertex position for each frame. To some degree, it duplicates the functionality of Character. However, it differs in one fundamental principle: it is designed to be a non-real-time operation, working directly on the Egg structures as they are, instead of first boiling the Egg data into native Panda Geom tables for real-time animation. Because of this, it is (a) double-precision instead of single precision, (b) capable of generating modified Egg files, and (c) about a hundred times slower than the Panda Character class.

The data in this structure is normally filled in by the EggCharacterCollection class.

Definition at line 60 of file eggCharacterData.h.


Member Function Documentation

void EggCharacterData::add_model ( int  model_index,
EggNode model_root,
EggData egg_data 
)

Indicates that the given model_index (with the indicated model_root) is associated with this character.

This is normally called by the EggCharacterCollection class as new models are discovered.

A "model" here is either a character model (or one LOD of a character model), or a character animation file: in either case, a hierarchy of joints.

Definition at line 98 of file eggCharacterData.cxx.

Referenced by EggCharacterCollection::add_egg().

bool EggCharacterData::check_num_frames ( int  model_index)

Walks through each component and ensures that all have the same number of frames of animation (except for those that contain 0 or 1 frames, of course).

Returns true if all are valid, false if there is a discreprency (in which case the shorter component are extended).

Definition at line 169 of file eggCharacterData.cxx.

References EggComponentData::extend_to(), and EggComponentData::get_num_frames().

Referenced by EggCharacterCollection::check_errors().

void EggCharacterData::choose_optimal_hierarchy ( )

Chooses the best possible parent joint for each of the joints in the hierarchy, based on the score computed by EggJointData::score_reparent_to().

This is a fairly expensive operation that involves lots of recomputing of transforms across the hierarchy.

The joints are not actually reparented yet, but the new_parent of each joint is set. Call do_reparent() to actually perform the suggested reparenting operation.

Definition at line 331 of file eggCharacterData.cxx.

References get_root_joint(), EggJointData::reparent_to(), and EggJointData::score_reparent_to().

bool EggCharacterData::do_reparent ( )

Begins the process of restructuring the joint hierarchy according to the previous calls to reparent_to() on various joints.

This will reparent the joint hierachy in all models as requested, while adjusting the transforms as appropriate so that each joint retains the same net transform across all frames that it had before the operation. Returns true on success, false on failure.

Definition at line 214 of file eggCharacterData.cxx.

References EggJointData::calc_new_parent_depth(), EggJointData::do_begin_compute_reparent(), EggJointData::do_begin_reparent(), EggJointData::do_compute_reparent(), EggJointData::do_finish_reparent(), EggJointData::do_joint_rebuild(), and get_num_frames().

size_t EggCharacterData::estimate_db_size ( ) const

Returns the estimated amount of memory, in megabytes, that will be required to perform the do_reparent() operation.

This is used mainly be EggCharacterDb to decide up front whether to store this data in-RAM or on-disk.

Definition at line 422 of file eggCharacterData.cxx.

References get_num_frames().

EggJointData * EggCharacterData::find_joint ( const string &  name) const [inline]

Returns the first joint found with the indicated name, or NULL if no joint has that name.

Definition at line 102 of file eggCharacterData.I.

References EggJointData::find_joint().

EggSliderData * EggCharacterData::find_slider ( const string &  name) const

Returns the slider with the indicated name, or NULL if no slider has that name.

Definition at line 380 of file eggCharacterData.cxx.

EggComponentData * EggCharacterData::get_component ( int  n) const [inline]

Returns the nth joint or slider in the character.

This can be used to walk linearly through all joints and sliders in the character when you don't care about making a distinction between the two; it returns the same objects that can also be discovered via get_slider() and get_root_joint().

Definition at line 190 of file eggCharacterData.I.

EggData * EggCharacterData::get_egg_data ( int  n) const [inline]

Returns the EggData representing the egg file that defined this particular model.

Note that one egg file might contain multiple models.

Definition at line 75 of file eggCharacterData.I.

Referenced by EggCharacterCollection::check_errors().

double EggCharacterData::get_frame_rate ( int  model_index) const

Returns the stated frame rate of the specified model.

Similar to get_num_frames().

Definition at line 143 of file eggCharacterData.cxx.

References EggComponentData::get_frame_rate().

EggJointData * EggCharacterData::get_joint ( int  n) const [inline]

Returns the nth joint in the character joint hierarchy.

This returns all of the joints in the hierarchy in an arbitrary ordering.

Definition at line 141 of file eggCharacterData.I.

Referenced by EggCharacterCollection::check_errors().

int EggCharacterData::get_model_index ( int  n) const [inline]

Returns the model_index of the nth model associated with this character.

This model_index may be used to ask questions about the particular model from the EggCharacterCollection object, or from the individual EggJointData and EggSliderData objects.

A "model" here is either a character model (or one LOD of a character model), or a character animation file: in either case, a hierarchy of joints.

Definition at line 46 of file eggCharacterData.I.

Referenced by EggCharacterCollection::check_errors().

EggNode * EggCharacterData::get_model_root ( int  n) const [inline]

Returns the model_root of the nth model associated with this character.

This is the node at which the character, animation bundle, or LOD officially began within its particular egg file.

Definition at line 62 of file eggCharacterData.I.

int EggCharacterData::get_num_components ( ) const [inline]

Returns the total number of joints and sliders in the character.

Definition at line 175 of file eggCharacterData.I.

int EggCharacterData::get_num_frames ( int  model_index) const

Returns the number of frames of animation of the indicated model.

This is more reliable than asking a particular joint or slider of the animation for its number of frames, since a particular joint may have only 1 frame (if it is unanimated), even though the overall animation has many frames.

Definition at line 117 of file eggCharacterData.cxx.

References EggComponentData::get_num_frames().

Referenced by do_reparent(), estimate_db_size(), EggRetargetAnim::retarget_anim(), and EggTopstrip::strip_anim().

int EggCharacterData::get_num_joints ( ) const [inline]

Returns the total number of joints in the character joint hierarchy.

Definition at line 129 of file eggCharacterData.I.

Referenced by EggCharacterCollection::check_errors().

int EggCharacterData::get_num_models ( ) const [inline]

Returns the total number of models associated with this character.

A "model" here is either a character model (or one LOD of a character model), or a character animation file: in either case, a hierarchy of joints.

Definition at line 28 of file eggCharacterData.I.

Referenced by EggCharacterCollection::check_errors().

int EggCharacterData::get_num_sliders ( ) const [inline]

Returns the number of sliders in the character slider list.

Definition at line 153 of file eggCharacterData.I.

EggJointData * EggCharacterData::get_root_joint ( ) const [inline]

Returns the root joint of the character hierarchy.

This root joint does not represent an actual joint in the hierarchy, but instead is a fictitious joint that is the parent of all the top joints in the hierarchy (since the hierarchy may actually contain zero or more top joints).

Definition at line 91 of file eggCharacterData.I.

Referenced by EggCharacterCollection::add_egg(), choose_optimal_hierarchy(), and EggCharacterFilter::write_eggs().

EggSliderData * EggCharacterData::get_slider ( int  n) const [inline]

Returns the nth slider in the character slider list.

Definition at line 163 of file eggCharacterData.I.

EggJointData * EggCharacterData::make_new_joint ( const string &  name,
EggJointData parent 
) [inline]

Creates a new joint as a child of the indicated joint and returns it.

The new joint will be initialized to the identity transform, so that in inherits the net transform of the indicated parent joint.

Definition at line 115 of file eggCharacterData.I.

EggSliderData * EggCharacterData::make_slider ( const string &  name)

Returns the slider matching the indicated name.

If no such slider exists already, creates a new one.

Definition at line 397 of file eggCharacterData.cxx.

References EggCharacterCollection::make_slider_data().

void EggCharacterData::rename_char ( const string &  name)

Renames all of the models in the character data to the indicated name.

This is the name that is used to identify unique skeleton hierarchies; if you set two different models to the same name, they will be loaded together as if they are expected to have the same skeleton hierarchy.

Definition at line 75 of file eggCharacterData.cxx.


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