Panda3D
eggComponentData.h
1 // Filename: eggComponentData.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 EGGCOMPONENTDATA_H
16 #define EGGCOMPONENTDATA_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "eggObject.h"
21 #include "namable.h"
22 #include "pset.h"
23 
25 class EggCharacterData;
26 class EggBackPointer;
27 class NameUniquifier;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : EggComponentData
31 // Description : This is the base class of both EggJointData and
32 // EggSliderData. It represents a single component of a
33 // character, either a joint or a slider, along with
34 // back pointers to the references to this component in
35 // all model and animation egg files read.
36 ////////////////////////////////////////////////////////////////////
37 class EggComponentData : public EggObject, public Namable {
38 public:
40  EggCharacterData *char_data);
41  virtual ~EggComponentData();
42 
43  void add_name(const string &name, NameUniquifier &uniquifier);
44  bool matches_name(const string &name) const;
45 
46  int get_num_frames(int model_index) const;
47  void extend_to(int model_index, int num_frames) const;
48  double get_frame_rate(int model_index) const;
49 
50  virtual void add_back_pointer(int model_index, EggObject *egg_object)=0;
51  virtual void write(ostream &out, int indent_level = 0) const=0;
52 
53  INLINE int get_num_models() const;
54  INLINE bool has_model(int model_index) const;
55  INLINE EggBackPointer *get_model(int model_index) const;
56  void set_model(int model_index, EggBackPointer *back);
57 
58 protected:
59 
60  // This points back to all the egg structures that reference this
61  // particular table or slider.
63  BackPointers _back_pointers;
64 
65  typedef pset<string> Names;
66  Names _names;
67 
68  EggCharacterCollection *_collection;
69  EggCharacterData *_char_data;
70 
71 
72 public:
73  static TypeHandle get_class_type() {
74  return _type_handle;
75  }
76  static void init_type() {
77  EggObject::init_type();
78  register_type(_type_handle, "EggComponentData",
79  EggObject::get_class_type());
80  }
81  virtual TypeHandle get_type() const {
82  return get_class_type();
83  }
84  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85 
86 private:
87  static TypeHandle _type_handle;
88 };
89 
90 #include "eggComponentData.I"
91 
92 #endif
93 
94 
int get_num_frames(int model_index) const
Returns the number of frames of animation for this particular component in the indicated model...
void set_model(int model_index, EggBackPointer *back)
Sets the back_pointer associated with the given model_index.
void extend_to(int model_index, int num_frames) const
Extends the number of frames in the indicated model (presumably an animation table model) to the give...
int get_num_models() const
Returns the maximum number of back pointers this component may have.
EggBackPointer * get_model(int model_index) const
Returns the back pointer to an egg file for the indicated model if it exists, or NULL if it does not...
This is the base class of both EggJointData and EggSliderData.
A handy class for converting a list of arbitrary names (strings) so that each name is guaranteed to b...
A base class for all things which can have a name.
Definition: namable.h:29
Represents a set of characters, as read and collected from possibly several model and/or animation eg...
bool matches_name(const string &name) const
Returns true if the indicated name matches any name that was ever matched with this particular joint...
bool has_model(int model_index) const
Returns true if the component has a back pointer to an egg file somewhere for the indicated model...
Represents a single character, as read and collected from several models and animation files...
double get_frame_rate(int model_index) const
Returns the number of frames of animation for this particular component in the indicated model...
void add_name(const string &name, NameUniquifier &uniquifier)
Adds the indicated name to the set of names that this component can be identified with...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This stores a pointer from an EggJointData or EggSliderData object back to the referencing data in an...
The highest-level base class in the egg directory.
Definition: eggObject.h:31