Panda3D
 All Classes Functions Variables Enumerations
characterJoint.h
00001 // Filename: characterJoint.h
00002 // Created by:  drose (23Feb99)
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 CHARACTERJOINT_H
00016 #define CHARACTERJOINT_H
00017 
00018 #include "pandabase.h"
00019 #include "transformState.h"
00020 
00021 #include "movingPartMatrix.h"
00022 #include "pandaNode.h"
00023 #include "nodePathCollection.h"
00024 #include "ordered_vector.h"
00025 
00026 class JointVertexTransform;
00027 class Character;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : CharacterJoint
00031 // Description : This represents one joint of the character's
00032 //               animation, containing an animating transform matrix.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_CHAR CharacterJoint : public MovingPartMatrix {
00035 protected:
00036   CharacterJoint();
00037   CharacterJoint(const CharacterJoint &copy);
00038 
00039 PUBLISHED:
00040   CharacterJoint(Character *character,
00041                  PartBundle *root, PartGroup *parent, const string &name,
00042                  const LMatrix4 &default_value);
00043   virtual ~CharacterJoint();
00044 
00045 public:
00046   virtual bool is_character_joint() const;
00047   virtual PartGroup *make_copy() const;
00048 
00049   virtual bool update_internals(PartBundle *root, PartGroup *parent, 
00050                                 bool self_changed, bool parent_changed, 
00051                                 Thread *current_thread);
00052   virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat);
00053 
00054 PUBLISHED:
00055   bool add_net_transform(PandaNode *node);
00056   bool remove_net_transform(PandaNode *node);
00057   bool has_net_transform(PandaNode *node) const;
00058   void clear_net_transforms();
00059   NodePathCollection get_net_transforms();
00060 
00061   bool add_local_transform(PandaNode *node);
00062   bool remove_local_transform(PandaNode *node);
00063   bool has_local_transform(PandaNode *node) const;
00064   void clear_local_transforms();
00065   NodePathCollection get_local_transforms();
00066 
00067   void get_transform(LMatrix4 &transform) const;
00068   INLINE const LMatrix4 &get_transform() const;  
00069   CPT(TransformState) get_transform_state() const;  
00070   
00071   void get_net_transform(LMatrix4 &transform) const;
00072 
00073   Character *get_character() const;
00074 
00075 private:
00076   void set_character(Character *character);
00077 
00078 private:
00079   // Not a reference-counted pointer.
00080   Character *_character;
00081 
00082   typedef ov_set< PT(PandaNode) > NodeList;
00083   NodeList _net_transform_nodes;
00084   NodeList _local_transform_nodes;
00085 
00086   typedef ov_set<JointVertexTransform *> VertexTransforms;
00087   VertexTransforms _vertex_transforms;
00088 
00089 public:
00090   static void register_with_read_factory();
00091   virtual void write_datagram(BamWriter* manager, Datagram &me);
00092   virtual int complete_pointers(TypedWritable **p_list,
00093                                 BamReader *manager);
00094 
00095   static TypedWritable *make_CharacterJoint(const FactoryParams &params);
00096 
00097 protected:
00098   void fillin(DatagramIterator& scan, BamReader* manager);
00099 
00100 private:
00101   int _num_net_nodes, _num_local_nodes;
00102 
00103 public:
00104   // The _geom_node member just holds a temporary pointer to a node
00105   // for the CharacterMaker's convenenience while creating the
00106   // character.  It does not store any meaningful value after
00107   // creation is complete.
00108   PT(PandaNode) _geom_node;
00109 
00110   // These are filled in as the joint animates.
00111   LMatrix4 _net_transform;
00112   LMatrix4 _initial_net_transform_inverse;
00113 
00114 public:
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   static void init_type() {
00123     MovingPartMatrix::init_type();
00124     register_type(_type_handle, "CharacterJoint",
00125                   MovingPartMatrix::get_class_type());
00126   }
00127 
00128 private:
00129   static TypeHandle _type_handle;
00130 
00131   friend class Character;
00132   friend class CharacterJointBundle;
00133   friend class JointVertexTransform;
00134 };
00135 
00136 #include "characterJoint.I"
00137 
00138 #endif
00139 
00140 
 All Classes Functions Variables Enumerations