Panda3D
 All Classes Functions Variables Enumerations
characterJoint.h
1 // Filename: characterJoint.h
2 // Created by: drose (23Feb99)
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 CHARACTERJOINT_H
16 #define CHARACTERJOINT_H
17 
18 #include "pandabase.h"
19 #include "transformState.h"
20 
21 #include "movingPartMatrix.h"
22 #include "pandaNode.h"
23 #include "nodePathCollection.h"
24 #include "ordered_vector.h"
25 
27 class Character;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : CharacterJoint
31 // Description : This represents one joint of the character's
32 // animation, containing an animating transform matrix.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_CHAR CharacterJoint : public MovingPartMatrix {
35 protected:
37  CharacterJoint(const CharacterJoint &copy);
38 
39 PUBLISHED:
40  CharacterJoint(Character *character,
41  PartBundle *root, PartGroup *parent, const string &name,
42  const LMatrix4 &default_value);
43  virtual ~CharacterJoint();
44 
45 public:
46  virtual bool is_character_joint() const;
47  virtual PartGroup *make_copy() const;
48 
49  virtual bool update_internals(PartBundle *root, PartGroup *parent,
50  bool self_changed, bool parent_changed,
51  Thread *current_thread);
52  virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat);
53 
54 PUBLISHED:
55  bool add_net_transform(PandaNode *node);
56  bool remove_net_transform(PandaNode *node);
57  bool has_net_transform(PandaNode *node) const;
58  void clear_net_transforms();
59  NodePathCollection get_net_transforms();
60 
61  bool add_local_transform(PandaNode *node);
62  bool remove_local_transform(PandaNode *node);
63  bool has_local_transform(PandaNode *node) const;
64  void clear_local_transforms();
65  NodePathCollection get_local_transforms();
66 
67  void get_transform(LMatrix4 &transform) const;
68  INLINE const LMatrix4 &get_transform() const;
69  CPT(TransformState) get_transform_state() const;
70 
71  void get_net_transform(LMatrix4 &transform) const;
72 
73  Character *get_character() const;
74 
75 private:
76  void set_character(Character *character);
77 
78 private:
79  // Not a reference-counted pointer.
80  Character *_character;
81 
83  NodeList _net_transform_nodes;
84  NodeList _local_transform_nodes;
85 
87  VertexTransforms _vertex_transforms;
88 
89 public:
90  static void register_with_read_factory();
91  virtual void write_datagram(BamWriter* manager, Datagram &me);
92  virtual int complete_pointers(TypedWritable **p_list,
93  BamReader *manager);
94 
95  static TypedWritable *make_CharacterJoint(const FactoryParams &params);
96 
97 protected:
98  void fillin(DatagramIterator& scan, BamReader* manager);
99 
100 private:
101  int _num_net_nodes, _num_local_nodes;
102 
103 public:
104  // The _geom_node member just holds a temporary pointer to a node
105  // for the CharacterMaker's convenenience while creating the
106  // character. It does not store any meaningful value after
107  // creation is complete.
108  PT(PandaNode) _geom_node;
109 
110  // These are filled in as the joint animates.
111  LMatrix4 _net_transform;
112  LMatrix4 _initial_net_transform_inverse;
113 
114 public:
115  virtual TypeHandle get_type() const {
116  return get_class_type();
117  }
118  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
119  static TypeHandle get_class_type() {
120  return _type_handle;
121  }
122  static void init_type() {
123  MovingPartMatrix::init_type();
124  register_type(_type_handle, "CharacterJoint",
125  MovingPartMatrix::get_class_type());
126  }
127 
128 private:
129  static TypeHandle _type_handle;
130 
131  friend class Character;
132  friend class CharacterJointBundle;
133  friend class JointVertexTransform;
134 };
135 
136 #include "characterJoint.I"
137 
138 #endif
139 
140 
static void register_with_read_factory()
Factory method to generate a MovingPartMatrix object.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
The collection of all the joints and sliders in the character.
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
Definition: partGroup.cxx:76
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
An animated character, with skeleton-morph animation and either soft-skinned or hard-skinned vertices...
Definition: character.h:41
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
virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat)
Called by PartBundle::xform(), this indicates the indicated transform is being applied to the root jo...
Definition: partGroup.cxx:555
virtual void write_datagram(BamWriter *manager, Datagram &me)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
Definition: partGroup.cxx:65
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual bool update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread)
This is called by do_update() whenever the part or some ancestor has changed values.
This is a specialization on VertexTransform that returns the transform necessary to move vertices as ...
This is a particular kind of MovingPart that accepts a matrix each frame.
A thread; that is, a lightweight process.
Definition: thread.h:51
This is the root of a MovingPart hierarchy.
Definition: partBundle.h:49
This represents one joint of the character's animation, containing an animating transform matrix...
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
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
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This is a set of zero or more NodePaths.
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:45