Panda3D

jointVertexTransform.h

00001 // Filename: jointVertexTransform.h
00002 // Created by:  drose (24Mar05)
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 JOINTVERTEXTRANSFORM_H
00016 #define JOINTVERTEXTRANSFORM_H
00017 
00018 #include "pandabase.h"
00019 #include "characterJoint.h"
00020 #include "vertexTransform.h"
00021 #include "pointerTo.h"
00022 #include "lightMutex.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : JointVertexTransform
00026 // Description : This is a specialization on VertexTransform that
00027 //               returns the transform necessary to move vertices as
00028 //               if they were assigned to the indicated joint.  The
00029 //               geometry itself should be parented to the scene graph
00030 //               at the level of the character's root joint; that is,
00031 //               it should not be parented under a node directly
00032 //               animated by any joints.
00033 //
00034 //               Multiple combinations of these with different weights
00035 //               are used to implement soft-skinned vertices for an
00036 //               animated character.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA_CHAR JointVertexTransform : public VertexTransform {
00039 private:
00040   JointVertexTransform();
00041 
00042 PUBLISHED:
00043   JointVertexTransform(CharacterJoint *joint);
00044   virtual ~JointVertexTransform();
00045 
00046   INLINE const CharacterJoint *get_joint() const;
00047 
00048   virtual void get_matrix(LMatrix4 &matrix) const;
00049   virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const;
00050   virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const;
00051 
00052   virtual void output(ostream &out) const;
00053 
00054 private:
00055   INLINE void check_matrix() const;
00056   void compute_matrix();
00057 
00058   PT(CharacterJoint) _joint;
00059 
00060   LMatrix4 _matrix;
00061   bool _matrix_stale;
00062   LightMutex _lock;
00063 
00064 public:
00065   static void register_with_read_factory();
00066   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00067   virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00068 
00069 protected:
00070   static TypedWritable *make_from_bam(const FactoryParams &params);
00071   void fillin(DatagramIterator &scan, BamReader *manager);
00072 
00073 public:
00074   static TypeHandle get_class_type() {
00075     return _type_handle;
00076   }
00077   static void init_type() {
00078     VertexTransform::init_type();
00079     register_type(_type_handle, "JointVertexTransform",
00080                   VertexTransform::get_class_type());
00081   }
00082   virtual TypeHandle get_type() const {
00083     return get_class_type();
00084   }
00085   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00086 
00087 private:
00088   static TypeHandle _type_handle;
00089 
00090   friend class CharacterJoint;
00091 };
00092 
00093 #include "jointVertexTransform.I"
00094 
00095 #endif
 All Classes Functions Variables Enumerations