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

panda/src/char/character.h

Go to the documentation of this file.
00001 // Filename: character.h
00002 // Created by:  drose (06Mar02)
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 CHARACTER_H
00020 #define CHARACTER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "computedVertices.h"
00025 
00026 #include "partBundleNode.h"
00027 #include "vector_PartGroupStar.h"
00028 #include "pointerTo.h"
00029 #include "geom.h"
00030 #include "pStatCollector.h"
00031 
00032 class CharacterJointBundle;
00033 class ComputedVertices;
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : Character
00037 // Description : An animated character, with skeleton-morph animation
00038 //               and either soft-skinned or hard-skinned vertices.
00039 ////////////////////////////////////////////////////////////////////
00040 class EXPCL_PANDA Character : public PartBundleNode {
00041 protected:
00042   Character(const Character &copy);
00043 
00044 public:
00045   Character(const string &name);
00046   virtual ~Character();
00047 
00048   virtual PandaNode *make_copy() const;
00049 
00050   virtual bool safe_to_transform() const;
00051   virtual bool has_cull_callback() const;
00052   virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00053 
00054 PUBLISHED:
00055   INLINE CharacterJointBundle *get_bundle() const;
00056 
00057   INLINE ComputedVertices *get_computed_vertices() const;
00058   INLINE int get_num_parts() const;
00059   INLINE PartGroup *get_part(int n) const;
00060 
00061   INLINE void write_parts(ostream &out) const;
00062   INLINE void write_part_values(ostream &out) const;
00063 
00064   void update_to_now();
00065   void update();
00066   void force_update();
00067 
00068 private:
00069   void copy_joints(PartGroup *copy, PartGroup *orig);
00070 
00071   typedef pmap<const PandaNode *, PandaNode *> NodeMap;
00072 
00073   virtual void r_copy_children(const PandaNode *from, InstanceMap &inst_map);
00074   void r_copy_char(PandaNode *dest, const PandaNode *source,
00075                    const Character *from, NodeMap &node_map);
00076   PT(Geom) copy_geom(Geom *source, const Character *from);
00077   void copy_node_pointers(const Character *from, const NodeMap &node_map);
00078 
00079   // These are the actual dynamic vertex pools for this Character's
00080   // ComputedVertices--the vertices that it will recompute each frame
00081   // based on the soft-skinning and morphing requirements.  Note that
00082   // we store this concretely, instead of as a pointer, just because
00083   // we don't really need to make it a pointer.
00084   DynamicVertices _cv;
00085 
00086   // And this is the object that animates them.  It *is* a pointer, so
00087   // it can be shared between multiple instances of this Character.
00088   PT(ComputedVertices) _computed_vertices;
00089 
00090   // This vector is used by the ComputedVertices object to index back
00091   // into our joints and sliders.
00092   typedef vector_PartGroupStar Parts;
00093   Parts _parts;
00094 
00095   // Statistics
00096   PStatCollector _char_pcollector;
00097   static PStatCollector _anim_pcollector;
00098 
00099 public:
00100   static void register_with_read_factory();
00101   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00102   virtual int complete_pointers(TypedWritable **plist,
00103                                 BamReader *manager);
00104 
00105 protected:
00106   static TypedWritable *make_from_bam(const FactoryParams &params);
00107   void fillin(DatagramIterator &scan, BamReader *manager);
00108   
00109 public:
00110   virtual TypeHandle get_type() const {
00111     return get_class_type();
00112   }
00113   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00114   static TypeHandle get_class_type() {
00115     return _type_handle;
00116   }
00117   static void init_type() {
00118     PartBundleNode::init_type();
00119     register_type(_type_handle, "Character",
00120                   PartBundleNode::get_class_type());
00121   }
00122 
00123 private:
00124   static TypeHandle _type_handle;
00125 
00126   friend class CharacterMaker;
00127   friend class ComputedVerticesMaker;
00128   friend class ComputedVertices;
00129 };
00130 
00131 #include "character.I"
00132 
00133 #endif
00134 

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