Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

EggCharacterCollection Class Reference

Represents a set of characters, as read and collected from possibly several model and/or animation egg files. More...

#include <eggCharacterCollection.h>

List of all members.

Public Types

typedef pvector< EggInfoEggs
typedef pvector< EggCharacterData * > Characters

Public Member Functions

 EggCharacterCollection ()
virtual ~EggCharacterCollection ()
int add_egg (EggData *egg)
 Adds a new egg file to the list of models and animation files for this particular character.

int get_num_eggs () const
 Returns the number of egg files that have successfully been added to the Character table.

EggDataget_egg (int i) const
 Returns the ith egg file.

int get_first_model_index (int egg_index) const
 Returns the first model index associated with the indicated egg file.

int get_num_models (int egg_index) const
 Returns the number of different models found in the indicated egg file.

int get_num_characters () const
 Returns the number of separate Characters that have been discovered in the various egg files added to the collection.

EggCharacterDataget_character (int i) const
 Returns the ith character in the collection.

EggCharacterDataget_character_by_name (const string &character_name) const
 Returns the Character with the indicated name, if it exists in the collection, or NULL if it does not.

EggCharacterDataget_character_by_model_index (int model_index) const
 Returns the character associated with the indicated model index.

virtual void write (ostream &out, int indent_level=0) const
virtual EggCharacterDatamake_character_data ()
 Allocates and returns a new EggCharacterData structure.

virtual EggJointDatamake_joint_data (EggCharacterData *char_data)
 Allocates and returns a new EggJointData structure for the given character.

virtual EggSliderDatamake_slider_data (EggCharacterData *char_data)
 Allocates and returns a new EggSliderData structure for the given character.

EggCharacterDatamake_character (const string &character_name)
 Allocates and returns a new EggCharacterData object representing the named character, if there is not already a character by that name.


Public Attributes

Eggs _eggs
Characters _characters
Characters _characters_by_model_index

Private Types

typedef pvector< EggNode * > EggNodeList
typedef pmap< EggNode *, EggNodeListTopEggNodes
typedef pmap< string, TopEggNodesTopEggNodesByName

Private Member Functions

bool scan_hierarchy (EggNode *egg_node)
 Walks the given egg data's hierarchy, looking for either the start of an animation channel or the start of a character model.

void scan_for_top_joints (EggNode *egg_node, EggNode *model_root, const string &character_name)
 Once a character model has been found, continue scanning the egg hierarchy to look for the topmost nodes encountered.

void scan_for_top_tables (EggTable *bundle, EggNode *model_root, const string &character_name)
 Once an animation has been found, continue scanning the egg hierarchy to look for the topmost.

void scan_for_morphs (EggNode *egg_node, int model_index, EggCharacterData *char_data)
 Go back through a model's hierarchy and look for morph targets on the vertices and primitives.

void scan_for_sliders (EggNode *egg_node, int model_index, EggCharacterData *char_data)
 Go back to the animation tables and look for morph slider animation channels.

void add_morph_back_pointers (EggAttributes *attrib, EggObject *egg_object, int model_index, EggCharacterData *char_data)
 Adds the back pointers for the kinds of morphs we might find in an EggAttributes object.

void match_egg_nodes (EggCharacterData *char_Data, EggJointData *joint_data, EggNodeList &egg_nodes, int egg_index, int model_index)
 Attempts to match up the indicated list of egg_nodes with the children of the given joint_data, by name if possible.

void found_egg_match (EggCharacterData *char_data, EggJointData *joint_data, EggNode *egg_node, int egg_index, int model_index)
 Marks a one-to-one association between the indicated EggJointData and the indicated EggNode, and then recurses below.


Private Attributes

TopEggNodesByName _top_egg_nodes
int _next_model_index


Detailed Description

Represents a set of characters, as read and collected from possibly several model and/or animation egg files.

Definition at line 47 of file eggCharacterCollection.h.


Member Typedef Documentation

typedef pvector<EggCharacterData *> EggCharacterCollection::Characters
 

Definition at line 85 of file eggCharacterCollection.h.

typedef pvector<EggNode *> EggCharacterCollection::EggNodeList [private]
 

Definition at line 105 of file eggCharacterCollection.h.

typedef pvector<EggInfo> EggCharacterCollection::Eggs
 

Definition at line 82 of file eggCharacterCollection.h.

typedef pmap<EggNode *, EggNodeList> EggCharacterCollection::TopEggNodes [private]
 

Definition at line 106 of file eggCharacterCollection.h.

typedef pmap<string, TopEggNodes> EggCharacterCollection::TopEggNodesByName [private]
 

Definition at line 107 of file eggCharacterCollection.h.


Constructor & Destructor Documentation

EggCharacterCollection::EggCharacterCollection  ) 
 

Definition at line 48 of file eggCharacterCollection.cxx.

References _characters.

EggCharacterCollection::~EggCharacterCollection  )  [virtual]
 

Definition at line 60 of file eggCharacterCollection.cxx.

References EggCharacterCollection::EggInfo::_egg, _eggs, _top_egg_nodes, and scan_hierarchy().


Member Function Documentation

int EggCharacterCollection::add_egg EggData egg  ) 
 

Adds a new egg file to the list of models and animation files for this particular character.

Returns the new egg_index if the file is successfully added, or -1 if there is some problem (for instance, it does not contain a character model or animation table).

If the joint hierarchy does not match the existing joint hierarchy, a best match is attempted.

Definition at line 95 of file eggCharacterCollection.cxx.

References _next_model_index.

void EggCharacterCollection::add_morph_back_pointers EggAttributes attrib,
EggObject egg_object,
int  model_index,
EggCharacterData char_data
[private]
 

Adds the back pointers for the kinds of morphs we might find in an EggAttributes object.

Definition at line 491 of file eggCharacterCollection.cxx.

Referenced by scan_for_top_joints().

void EggCharacterCollection::found_egg_match EggCharacterData char_data,
EggJointData joint_data,
EggNode egg_node,
int  egg_index,
int  model_index
[private]
 

Marks a one-to-one association between the indicated EggJointData and the indicated EggNode, and then recurses below.

Definition at line 682 of file eggCharacterCollection.cxx.

Referenced by scan_for_sliders().

EggCharacterData * EggCharacterCollection::get_character int  i  )  const [inline]
 

Returns the ith character in the collection.

Definition at line 138 of file eggCharacterCollection.I.

EggCharacterData * EggCharacterCollection::get_character_by_model_index int  model_index  )  const [inline]
 

Returns the character associated with the indicated model index.

Definition at line 154 of file eggCharacterCollection.I.

EggCharacterData * EggCharacterCollection::get_character_by_name const string &  character_name  )  const
 

Returns the Character with the indicated name, if it exists in the collection, or NULL if it does not.

Definition at line 154 of file eggCharacterCollection.cxx.

EggData * EggCharacterCollection::get_egg int  i  )  const [inline]
 

Returns the ith egg file.

Definition at line 47 of file eggCharacterCollection.I.

References _eggs, INLINE, and nassertr.

int EggCharacterCollection::get_first_model_index int  egg_index  )  const [inline]
 

Returns the first model index associated with the indicated egg file.

An egg file may contain multiple models, which will be consecutive integers beginning at get_first_model_index() and continuing for get_num_models().

Each "model" corresponds to a single character model, or one LOD of a multiple-LOD model, or a single animation bundle.

Definition at line 77 of file eggCharacterCollection.I.

References _eggs.

int EggCharacterCollection::get_num_characters  )  const [inline]
 

Returns the number of separate Characters that have been discovered in the various egg files added to the collection.

Definition at line 125 of file eggCharacterCollection.I.

int EggCharacterCollection::get_num_eggs  )  const [inline]
 

Returns the number of egg files that have successfully been added to the Character table.

Definition at line 34 of file eggCharacterCollection.I.

References _eggs, INLINE, nassertr, and NULL.

int EggCharacterCollection::get_num_models int  egg_index  )  const [inline]
 

Returns the number of different models found in the indicated egg file.

An egg file may contain multiple models, which will be consecutive integers beginning at get_first_model_index() and continuing for get_num_models().

Each "model" corresponds to a single character model, or one LOD of a multiple-LOD model, or a single animation bundle.

Definition at line 107 of file eggCharacterCollection.I.

References _characters_by_model_index, INLINE, nassertr, and NULL.

EggCharacterData * EggCharacterCollection::make_character const string &  character_name  ) 
 

Allocates and returns a new EggCharacterData object representing the named character, if there is not already a character by that name.

Definition at line 243 of file eggCharacterCollection.cxx.

References EggGroupNode::begin(), DCAST, EggGroupNode::end(), EggGroupNode::iterator, and scan_hierarchy().

EggCharacterData * EggCharacterCollection::make_character_data  )  [virtual]
 

Allocates and returns a new EggCharacterData structure.

This is primarily intended as a hook so derived classes can customize the type of EggCharacterData nodes used to represent the characters in this collection.

Definition at line 184 of file eggCharacterCollection.cxx.

EggJointData * EggCharacterCollection::make_joint_data EggCharacterData char_data  )  [virtual]
 

Allocates and returns a new EggJointData structure for the given character.

This is primarily intended as a hook so derived classes can customize the type of EggJointData nodes used to represent the joint hierarchy.

Definition at line 205 of file eggCharacterCollection.cxx.

References _characters.

Referenced by scan_for_sliders().

EggSliderData * EggCharacterCollection::make_slider_data EggCharacterData char_data  )  [virtual]
 

Allocates and returns a new EggSliderData structure for the given character.

This is primarily intended as a hook so derived classes can customize the type of EggSliderData nodes used to represent the slider list.

Definition at line 226 of file eggCharacterCollection.cxx.

References DCAST, EggGroup::DT_none, EggGroup::get_dart_type(), EggGroup::get_name(), and scan_for_top_joints().

void EggCharacterCollection::match_egg_nodes EggCharacterData char_Data,
EggJointData joint_data,
EggNodeList egg_nodes,
int  egg_index,
int  model_index
[private]
 

Attempts to match up the indicated list of egg_nodes with the children of the given joint_data, by name if possible.

Also recurses on each matched joint to build up the entire joint hierarchy.

Definition at line 537 of file eggCharacterCollection.cxx.

void EggCharacterCollection::scan_for_morphs EggNode egg_node,
int  model_index,
EggCharacterData char_data
[private]
 

Go back through a model's hierarchy and look for morph targets on the vertices and primitives.

Definition at line 403 of file eggCharacterCollection.cxx.

References EggAttributes::_dnormals, EggAttributes::_drgbas, EggAttributes::_duvs, EggSliderData::add_back_pointer(), EggMorphColor, EggMorphNormal, EggMorphTexCoord, and EggCharacterData::make_slider().

Referenced by scan_for_top_joints().

void EggCharacterCollection::scan_for_sliders EggNode egg_node,
int  model_index,
EggCharacterData char_data
[private]
 

Go back to the animation tables and look for morph slider animation channels.

Definition at line 447 of file eggCharacterCollection.cxx.

References EggJointData::_children, EggJointData::_parent, found_egg_match(), Namable::get_name(), EggNode::get_name(), and make_joint_data().

void EggCharacterCollection::scan_for_top_joints EggNode egg_node,
EggNode model_root,
const string &  character_name
[private]
 

Once a character model has been found, continue scanning the egg hierarchy to look for the topmost nodes encountered.

Definition at line 329 of file eggCharacterCollection.cxx.

References EggVertex::_dxyzs, EggSliderData::add_back_pointer(), add_morph_back_pointers(), EggGroupNode::begin(), EggPrimitive::begin(), EggPrimitive::const_iterator, DCAST, EggMorphVertex, EggGroupNode::end(), EggPrimitive::end(), EggGroupNode::get_class_type(), EggPrimitive::get_class_type(), EggNode::is_of_type(), EggGroupNode::iterator, EggCharacterData::make_slider(), and scan_for_morphs().

Referenced by make_slider_data().

void EggCharacterCollection::scan_for_top_tables EggTable bundle,
EggNode model_root,
const string &  character_name
[private]
 

Once an animation has been found, continue scanning the egg hierarchy to look for the topmost.

encountered.

Definition at line 367 of file eggCharacterCollection.cxx.

References EggSliderData::add_back_pointer(), EggTable::begin(), DCAST, EggTable::end(), EggSAnimData::get_class_type(), EggTable::get_class_type(), EggNode::get_name(), EggTable::get_name(), EggNode::is_of_type(), EggGroupNode::iterator, and EggCharacterData::make_slider().

bool EggCharacterCollection::scan_hierarchy EggNode egg_node  )  [private]
 

Walks the given egg data's hierarchy, looking for either the start of an animation channel or the start of a character model.

Returns true if either (or both) is found, false if the model appears to have nothing to do with characters.

Fills up the _top_egg_nodes according to the nodes found.

Definition at line 284 of file eggCharacterCollection.cxx.

Referenced by make_character(), and ~EggCharacterCollection().

void EggCharacterCollection::write ostream &  out,
int  indent_level = 0
const [virtual]
 

Definition at line 741 of file eggCharacterCollection.cxx.


Member Data Documentation

Characters EggCharacterCollection::_characters
 

Definition at line 86 of file eggCharacterCollection.h.

Referenced by EggCharacterCollection(), and make_joint_data().

Characters EggCharacterCollection::_characters_by_model_index
 

Definition at line 87 of file eggCharacterCollection.h.

Referenced by get_num_models().

Eggs EggCharacterCollection::_eggs
 

Definition at line 83 of file eggCharacterCollection.h.

Referenced by get_egg(), get_first_model_index(), get_num_eggs(), and ~EggCharacterCollection().

int EggCharacterCollection::_next_model_index [private]
 

Definition at line 110 of file eggCharacterCollection.h.

Referenced by add_egg().

TopEggNodesByName EggCharacterCollection::_top_egg_nodes [private]
 

Definition at line 108 of file eggCharacterCollection.h.

Referenced by ~EggCharacterCollection().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:26:07 2003 for Panda-Tool by doxygen1.3