00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PARTGROUP_H
00020 #define PARTGROUP_H
00021
00022 #include "pandabase.h"
00023
00024 #include "typedWritableReferenceCount.h"
00025 #include "pointerTo.h"
00026 #include "namable.h"
00027 #include "typedef.h"
00028
00029 #include "plist.h"
00030
00031 class AnimControl;
00032 class AnimGroup;
00033 class PartBundle;
00034 class BamReader;
00035 class FactoryParams;
00036
00037
00038
00039
00040
00041
00042 class EXPCL_PANDA PartGroup : public TypedWritableReferenceCount, public Namable {
00043 public:
00044
00045
00046
00047
00048 enum HierarchyMatchFlags {
00049 HMF_ok_part_extra = 0x01,
00050 HMF_ok_anim_extra = 0x02,
00051 HMF_ok_wrong_root_name = 0x04,
00052 };
00053
00054 protected:
00055
00056
00057
00058
00059 INLINE PartGroup(const string &name = "");
00060 INLINE PartGroup(const PartGroup ©);
00061
00062 public:
00063
00064 PartGroup(PartGroup *parent, const string &name);
00065 virtual ~PartGroup();
00066
00067 virtual PartGroup *make_copy() const;
00068 PartGroup *copy_subgraph() const;
00069
00070 PUBLISHED:
00071 int get_num_children() const;
00072 PartGroup *get_child(int n) const;
00073 PartGroup *find_child(const string &name) const;
00074
00075 virtual void write(ostream &out, int indent_level) const;
00076 virtual void write_with_value(ostream &out, int indent_level) const;
00077
00078 public:
00079 virtual TypeHandle get_value_type() const;
00080
00081 void sort_descendants();
00082 bool check_hierarchy(const AnimGroup *anim,
00083 const PartGroup *parent,
00084 int hierarchy_match_flags = 0) const;
00085
00086 virtual bool do_update(PartBundle *root, PartGroup *parent,
00087 bool parent_changed, bool anim_changed);
00088
00089 protected:
00090 void write_descendants(ostream &out, int indent_level) const;
00091 void write_descendants_with_value(ostream &out, int indent_level) const;
00092
00093 virtual void pick_channel_index(plist<int> &holes, int &next) const;
00094 virtual void bind_hierarchy(AnimGroup *anim, int channel_index);
00095
00096 typedef pvector< PT(PartGroup) > Children;
00097 Children _children;
00098
00099 public:
00100 static void register_with_read_factory(void);
00101 virtual void write_datagram(BamWriter* manager, Datagram &me);
00102 virtual int complete_pointers(TypedWritable **p_list,
00103 BamReader *manager);
00104
00105 static TypedWritable *make_PartGroup(const FactoryParams ¶ms);
00106
00107 protected:
00108 void fillin(DatagramIterator& scan, BamReader* manager);
00109
00110 private:
00111 int _num_children;
00112
00113 public:
00114
00115 virtual TypeHandle get_type() const {
00116 return get_class_type();
00117 }
00118 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00119 static TypeHandle get_class_type() {
00120 return _type_handle;
00121 }
00122
00123 public:
00124 static void init_type() {
00125 TypedWritableReferenceCount::init_type();
00126 register_type(_type_handle, "PartGroup",
00127 TypedWritableReferenceCount::get_class_type());
00128 }
00129
00130 private:
00131 static TypeHandle _type_handle;
00132
00133 friend class Character;
00134 };
00135
00136 #include "partGroup.I"
00137
00138 #endif
00139
00140