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

panda/src/chan/partGroup.h

Go to the documentation of this file.
00001 // Filename: partGroup.h
00002 // Created by:  drose (22Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //       Class : PartGroup
00039 // Description : This is the base class for PartRoot and
00040 //               MovingPart.  It defines a hierarchy of MovingParts.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA PartGroup : public TypedWritableReferenceCount, public Namable {
00043 public:
00044   // This enum defines bits which may be passed into check_hierarchy()
00045   // and PartBundle::bind_anim() to allow an inexact match of channel
00046   // hierarchies.  This specifies conditions that we don't care about
00047   // enforcing.
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   // The default constructor is protected: don't try to create a
00056   // PartGroup without a parent.  To create a PartGroup hierarchy, you
00057   // must first create a PartBundle, and use that to create any
00058   // subsequent children.
00059   INLINE PartGroup(const string &name = "");
00060   INLINE PartGroup(const PartGroup &copy);
00061 
00062 public:
00063   // This is the normal PartGroup constructor.
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 &params);
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 

Generated on Fri May 2 00:35:16 2003 for Panda by doxygen1.3