Panda3D
jointVertexTransform.h
1 // Filename: jointVertexTransform.h
2 // Created by: drose (24Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef JOINTVERTEXTRANSFORM_H
16 #define JOINTVERTEXTRANSFORM_H
17 
18 #include "pandabase.h"
19 #include "characterJoint.h"
20 #include "vertexTransform.h"
21 #include "pointerTo.h"
22 #include "lightMutex.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : JointVertexTransform
26 // Description : This is a specialization on VertexTransform that
27 // returns the transform necessary to move vertices as
28 // if they were assigned to the indicated joint. The
29 // geometry itself should be parented to the scene graph
30 // at the level of the character's root joint; that is,
31 // it should not be parented under a node directly
32 // animated by any joints.
33 //
34 // Multiple combinations of these with different weights
35 // are used to implement soft-skinned vertices for an
36 // animated character.
37 ////////////////////////////////////////////////////////////////////
38 class EXPCL_PANDA_CHAR JointVertexTransform : public VertexTransform {
39 private:
41 
42 PUBLISHED:
44  virtual ~JointVertexTransform();
45 
46  INLINE const CharacterJoint *get_joint() const;
47 
48  virtual void get_matrix(LMatrix4 &matrix) const;
49  virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const;
50  virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const;
51 
52  virtual void output(ostream &out) const;
53 
54 private:
55  INLINE void check_matrix() const;
56  void compute_matrix();
57 
58  PT(CharacterJoint) _joint;
59 
60  LMatrix4 _matrix;
61  bool _matrix_stale;
62  LightMutex _lock;
63 
64 public:
65  static void register_with_read_factory();
66  virtual void write_datagram(BamWriter *manager, Datagram &dg);
67  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
68 
69 protected:
70  static TypedWritable *make_from_bam(const FactoryParams &params);
71  void fillin(DatagramIterator &scan, BamReader *manager);
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  VertexTransform::init_type();
79  register_type(_type_handle, "JointVertexTransform",
80  VertexTransform::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 
90  friend class CharacterJoint;
91 };
92 
93 #include "jointVertexTransform.I"
94 
95 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is our own Panda specialization on the default STL list.
Definition: plist.h:38
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const
Premultiplies this transform's matrix with the indicated previous matrix, so that the result is the n...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is a specialization on VertexTransform that returns the transform necessary to move vertices as ...
This represents one joint of the character's animation, containing an animating transform matrix...
virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const
Adds the value of this transform's matrix, modified by the indicated weight, into the indicated accum...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43