Panda3D

partBundleNode.h

00001 // Filename: partBundleNode.h
00002 // Created by:  drose (06Mar02)
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 PARTBUNDLENODE_H
00016 #define PARTBUNDLENODE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "partBundle.h"
00021 #include "partBundleHandle.h"
00022 
00023 #include "pandaNode.h"
00024 #include "dcast.h"
00025 #include "pvector.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : PartBundleNode
00029 // Description : This is a node that contains a pointer to an
00030 //               PartBundle.  Like AnimBundleNode, it exists to make
00031 //               it easy to store PartBundles in the scene graph.
00032 //
00033 //               (Unlike AnimBundleNode, however, PartBundleNode has
00034 //               an additional function: it is also the base class of
00035 //               the Character node type, which adds additional
00036 //               functionality.)
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA_CHAN PartBundleNode : public PandaNode {
00039 PUBLISHED:
00040   INLINE PartBundleNode(const string &name, PartBundle *bundle);
00041 
00042 protected:
00043   INLINE PartBundleNode();
00044   INLINE PartBundleNode(const PartBundleNode &copy);
00045 
00046 public:
00047   virtual ~PartBundleNode();
00048   virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs,
00049                                          int attrib_types,
00050                                          GeomTransformer &transformer);
00051   virtual void xform(const LMatrix4 &mat);
00052 
00053 PUBLISHED:
00054   INLINE int get_num_bundles() const;
00055   INLINE PartBundle *get_bundle(int n) const;
00056   MAKE_SEQ(get_bundles, get_num_bundles, get_bundle);
00057   INLINE PartBundleHandle *get_bundle_handle(int n) const;
00058   MAKE_SEQ(get_bundle_handles, get_num_bundles, get_bundle_handle);
00059 
00060 protected:
00061   void add_bundle(PartBundle *bundle);
00062   void add_bundle_handle(PartBundleHandle *handle);
00063   void steal_bundles(PartBundleNode *other);
00064   virtual void update_bundle(PartBundleHandle *old_bundle_handle, 
00065                              PartBundle *new_bundle);
00066 
00067 protected:
00068   typedef pvector< PT(PartBundleHandle) > Bundles;
00069   Bundles _bundles;
00070 
00071 public:
00072   virtual void write_datagram(BamWriter* manager, Datagram &me);
00073   virtual int complete_pointers(TypedWritable **p_list,
00074                                 BamReader *manager);
00075 
00076 protected:
00077   void fillin(DatagramIterator& scan, BamReader* manager);
00078 
00079 public:
00080   virtual TypeHandle get_type() const {
00081     return get_class_type();
00082   }
00083   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00084   static TypeHandle get_class_type() {
00085     return _type_handle;
00086   }
00087   static void init_type() {
00088     PandaNode::init_type();
00089     register_type(_type_handle, "PartBundleNode",
00090                   PandaNode::get_class_type());
00091   }
00092 
00093 private:
00094   static TypeHandle _type_handle;
00095 };
00096 
00097 #include "partBundleNode.I"
00098 
00099 #endif
 All Classes Functions Variables Enumerations