Panda3D
eggComponentData.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggComponentData.h
10  * @author drose
11  * @date 2001-02-26
12  */
13 
14 #ifndef EGGCOMPONENTDATA_H
15 #define EGGCOMPONENTDATA_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "eggObject.h"
20 #include "namable.h"
21 #include "pset.h"
22 
24 class EggCharacterData;
25 class EggBackPointer;
26 class NameUniquifier;
27 
28 /**
29  * This is the base class of both EggJointData and EggSliderData. It
30  * represents a single component of a character, either a joint or a slider,
31  * along with back pointers to the references to this component in all model
32  * and animation egg files read.
33  */
34 class EggComponentData : public EggObject, public Namable {
35 public:
37  EggCharacterData *char_data);
38  virtual ~EggComponentData();
39 
40  void add_name(const std::string &name, NameUniquifier &uniquifier);
41  bool matches_name(const std::string &name) const;
42 
43  int get_num_frames(int model_index) const;
44  void extend_to(int model_index, int num_frames) const;
45  double get_frame_rate(int model_index) const;
46 
47  virtual void add_back_pointer(int model_index, EggObject *egg_object)=0;
48  virtual void write(std::ostream &out, int indent_level = 0) const=0;
49 
50  INLINE int get_num_models() const;
51  INLINE bool has_model(int model_index) const;
52  INLINE EggBackPointer *get_model(int model_index) const;
53  void set_model(int model_index, EggBackPointer *back);
54 
55 protected:
56 
57  // This points back to all the egg structures that reference this particular
58  // table or slider.
60  BackPointers _back_pointers;
61 
62  typedef pset<std::string> Names;
63  Names _names;
64 
65  EggCharacterCollection *_collection;
66  EggCharacterData *_char_data;
67 
68 
69 public:
70  static TypeHandle get_class_type() {
71  return _type_handle;
72  }
73  static void init_type() {
74  EggObject::init_type();
75  register_type(_type_handle, "EggComponentData",
76  EggObject::get_class_type());
77  }
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82 
83 private:
84  static TypeHandle _type_handle;
85 };
86 
87 #include "eggComponentData.I"
88 
89 #endif
int get_num_frames(int model_index) const
Returns the number of frames of animation for this particular component in the indicated model.
void add_name(const std::string &name, NameUniquifier &uniquifier)
Adds the indicated name to the set of names that this component can be identified with.
void set_model(int model_index, EggBackPointer *back)
Sets the back_pointer associated with the given model_index.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:26
bool matches_name(const std::string &name) const
Returns true if the indicated name matches any name that was ever matched with this particular joint,...
Represents a set of characters, as read and collected from possibly several model and/or animation eg...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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:29