Panda3D

animGroup.h

00001 // Filename: animGroup.h
00002 // Created by:  drose (21Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ANIMGROUP_H
00016 #define ANIMGROUP_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "typedWritableReferenceCount.h"
00021 #include "pointerTo.h"
00022 #include "namable.h"
00023 #include "luse.h"
00024 
00025 class AnimBundle;
00026 class BamReader;
00027 class FactoryParams;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : AnimGroup
00031 // Description : This is the base class for AnimChannel and
00032 //               AnimBundle.  It implements a hierarchy of
00033 //               AnimChannels.  The root of the hierarchy must be an
00034 //               AnimBundle.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA_CHAN AnimGroup : public TypedWritableReferenceCount, public Namable {
00037 protected:
00038   AnimGroup(const string &name = "");
00039   AnimGroup(AnimGroup *parent, const AnimGroup &copy);
00040 
00041 PUBLISHED:
00042   // This is the normal AnimGroup constructor.
00043   AnimGroup(AnimGroup *parent, const string &name);
00044   virtual ~AnimGroup();
00045 
00046   int get_num_children() const;
00047   AnimGroup *get_child(int n) const;
00048   MAKE_SEQ(get_children, get_num_children, get_child);
00049 
00050   AnimGroup *get_child_named(const string &name) const;
00051   AnimGroup *find_child(const string &name) const;
00052   void sort_descendants();
00053 
00054 public:
00055   virtual TypeHandle get_value_type() const;
00056 
00057 PUBLISHED:
00058   virtual void output(ostream &out) const;
00059   virtual void write(ostream &out, int indent_level) const;
00060 
00061 protected:
00062   void write_descendants(ostream &out, int indent_level) const;
00063 
00064   virtual AnimGroup *make_copy(AnimGroup *parent) const;
00065   PT(AnimGroup) copy_subtree(AnimGroup *parent) const;
00066   
00067 protected:
00068   typedef pvector< PT(AnimGroup) > Children;
00069   Children _children;
00070   AnimBundle *_root;
00071 
00072 public:
00073   static void register_with_read_factory();
00074   virtual void write_datagram(BamWriter* manager, Datagram &me);
00075   virtual int complete_pointers(TypedWritable **p_list,
00076                                 BamReader *manager);
00077 
00078   static TypedWritable *make_AnimGroup(const FactoryParams &params);
00079 
00080 protected:
00081   void fillin(DatagramIterator& scan, BamReader* manager);
00082 
00083 private:
00084   typedef pvector< string > frozenJoints;
00085   int _num_children;
00086 
00087 public:
00088   virtual TypeHandle get_type() const {
00089     return get_class_type();
00090   }
00091   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00092 
00093   static TypeHandle get_class_type() {
00094     return _type_handle;
00095   }
00096   static void init_type() {
00097     TypedWritableReferenceCount::init_type();
00098     register_type(_type_handle, "AnimGroup",
00099                   TypedWritableReferenceCount::get_class_type());
00100   }
00101 
00102 private:
00103   static TypeHandle _type_handle;
00104 };
00105 
00106 inline ostream &operator << (ostream &out, const AnimGroup &anim) {
00107   anim.output(out);
00108   return out;
00109 }
00110 
00111 #include "animGroup.I"
00112 
00113 #endif
00114 
00115 
 All Classes Functions Variables Enumerations