Panda3D
eggCharacterCollection.h
1 // Filename: eggCharacterCollection.h
2 // Created by: drose (26Feb01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGCHARACTERCOLLECTION_H
16 #define EGGCHARACTERCOLLECTION_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "eggCharacterData.h"
21 
22 #include "eggData.h"
23 #include "eggNode.h"
24 #include "pointerTo.h"
25 
26 class EggTable;
27 class EggAttributes;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : EggCharacterCollection
31 // Description : Represents a set of characters, as read and collected
32 // from possibly several model and/or animation egg
33 // files.
34 ////////////////////////////////////////////////////////////////////
36 public:
38  virtual ~EggCharacterCollection();
39 
40  int add_egg(EggData *egg);
41 
42  INLINE int get_num_eggs() const;
43  INLINE EggData *get_egg(int i) const;
44  INLINE int get_first_model_index(int egg_index) const;
45  INLINE int get_num_models(int egg_index) const;
46 
47  INLINE int get_num_characters() const;
48  INLINE EggCharacterData *get_character(int i) const;
49  EggCharacterData *get_character_by_name(const string &character_name) const;
50 
51  INLINE EggCharacterData *get_character_by_model_index(int model_index) const;
52 
53  void rename_char(int i, const string &name);
54 
55  virtual void write(ostream &out, int indent_level = 0) const;
56  void check_errors(ostream &out, bool force_initial_rest_frame);
57 
59  virtual EggJointData *make_joint_data(EggCharacterData *char_data);
60  virtual EggSliderData *make_slider_data(EggCharacterData *char_data);
61 
62 public:
63  EggCharacterData *make_character(const string &character_name);
64 
65  class EggInfo {
66  public:
67  PT(EggData) _egg;
69  Models _models;
70  int _first_model_index;
71  };
72 
73  typedef pvector<EggInfo> Eggs;
74  Eggs _eggs;
75 
77  Characters _characters;
78  Characters _characters_by_model_index;
79 
80 private:
81  bool scan_hierarchy(EggNode *egg_node);
82  void scan_for_top_joints(EggNode *egg_node, EggNode *model_root,
83  const string &character_name);
84  void scan_for_top_tables(EggTable *bundle, EggNode *model_root,
85  const string &character_name);
86  void scan_for_morphs(EggNode *egg_node, int model_index,
87  EggCharacterData *char_data);
88  void scan_for_sliders(EggNode *egg_node, int model_index,
89  EggCharacterData *char_data);
90 
91  void add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object,
92  int model_index, EggCharacterData *char_data);
93  void add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object,
94  int model_index, EggCharacterData *char_data);
95 
96  // The _top_egg_nodes member is only used temporarily, when adding
97  // each pre-existing egg file to the structure for the first time.
99  class ModelDescription {
100  public:
101  INLINE ModelDescription();
102  EggNodeList _top_nodes;
103  EggObject *_root_node;
104  };
105 
108  TopEggNodesByName _top_egg_nodes;
109 
110  int _next_model_index;
111 
112  void match_egg_nodes(EggCharacterData *char_Data, EggJointData *joint_data,
113  EggNodeList &egg_nodes, int egg_index, int model_index);
114  void found_egg_match(EggCharacterData *char_data, EggJointData *joint_data,
115  EggNode *egg_node, int egg_index, int model_index);
116 };
117 
118 #include "eggCharacterCollection.I"
119 
120 #endif
121 
122 
virtual EggCharacterData * make_character_data()
Allocates and returns a new EggCharacterData structure.
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
int get_num_models(int egg_index) const
Returns the number of different models found in the indicated egg file.
This corresponds to a single morph slider control.
Definition: eggSliderData.h:31
int add_egg(EggData *egg)
Adds a new egg file to the list of models and animation files for this particular character...
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
EggData * get_egg(int i) const
Returns the ith egg file.
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Definition: eggAttributes.h:37
int get_num_characters() const
Returns the number of separate Characters that have been discovered in the various egg files added to...
EggCharacterData * 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.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
EggCharacterData * get_character(int i) const
Returns the ith character in the collection.
Represents a set of characters, as read and collected from possibly several model and/or animation eg...
int get_first_model_index(int egg_index) const
Returns the first model index associated with the indicated egg file.
EggCharacterData * 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...
Represents a single character, as read and collected from several models and animation files...
This corresponds to a.
Definition: eggTable.h:31
void rename_char(int i, const string &name)
Renames the ith character to the indicated name.
EggCharacterData * get_character_by_model_index(int model_index) const
Returns the character associated with the indicated model index.
This is one node of a hierarchy of EggJointData nodes, each of which represents a single joint of the...
Definition: eggJointData.h:34
virtual EggSliderData * make_slider_data(EggCharacterData *char_data)
Allocates and returns a new EggSliderData structure for the given character.
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:38
void check_errors(ostream &out, bool force_initial_rest_frame)
Can be called after the collection has been completely filled up with egg files to output any message...
int get_num_eggs() const
Returns the number of egg files that have successfully been added to the Character table...
The highest-level base class in the egg directory.
Definition: eggObject.h:31
virtual EggJointData * make_joint_data(EggCharacterData *char_data)
Allocates and returns a new EggJointData structure for the given character.