Panda3D
Loading...
Searching...
No Matches
characterJoint.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file characterJoint.h
10 * @author drose
11 * @date 1999-02-23
12 */
13
14#ifndef CHARACTERJOINT_H
15#define CHARACTERJOINT_H
16
17#include "pandabase.h"
18#include "transformState.h"
19
20#include "movingPartMatrix.h"
21#include "pandaNode.h"
22#include "nodePathCollection.h"
23#include "ordered_vector.h"
24
26class Character;
27
28/**
29 * This represents one joint of the character's animation, containing an
30 * animating transform matrix.
31 */
32class EXPCL_PANDA_CHAR CharacterJoint : public MovingPartMatrix {
33protected:
35 CharacterJoint(const CharacterJoint &copy);
36
37PUBLISHED:
38 explicit CharacterJoint(Character *character, PartBundle *root,
39 PartGroup *parent, const std::string &name,
40 const LMatrix4 &default_value);
41 virtual ~CharacterJoint();
42
43public:
44 virtual bool is_character_joint() const;
45 virtual PartGroup *make_copy() const;
46
47 virtual bool update_internals(PartBundle *root, PartGroup *parent,
48 bool self_changed, bool parent_changed,
49 Thread *current_thread);
50 virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat);
51
52PUBLISHED:
53 bool add_net_transform(PandaNode *node);
54 bool remove_net_transform(PandaNode *node);
55 bool has_net_transform(PandaNode *node) const;
56 void clear_net_transforms();
57 NodePathCollection get_net_transforms();
58
59 bool add_local_transform(PandaNode *node);
60 bool remove_local_transform(PandaNode *node);
61 bool has_local_transform(PandaNode *node) const;
62 void clear_local_transforms();
63 NodePathCollection get_local_transforms();
64
65 void get_transform(LMatrix4 &transform) const;
66 INLINE const LMatrix4 &get_transform() const;
67 CPT(TransformState) get_transform_state() const;
68
69 void get_net_transform(LMatrix4 &transform) const;
70
71 Character *get_character() const;
72
73private:
74 void set_character(Character *character);
75
76private:
77 // Not a reference-counted pointer.
78 Character *_character;
79
80 typedef ov_set< PT(PandaNode) > NodeList;
81 NodeList _net_transform_nodes;
82 NodeList _local_transform_nodes;
83
85 VertexTransforms _vertex_transforms;
86
87public:
88 static void register_with_read_factory();
89 virtual void write_datagram(BamWriter* manager, Datagram &me);
90 virtual int complete_pointers(TypedWritable **p_list,
91 BamReader *manager);
92
93 static TypedWritable *make_CharacterJoint(const FactoryParams &params);
94
95protected:
96 void fillin(DatagramIterator& scan, BamReader* manager);
97
98private:
99 int _num_net_nodes, _num_local_nodes;
100
101public:
102 // The _geom_node member just holds a temporary pointer to a node for the
103 // CharacterMaker's convenenience while creating the character. It does not
104 // store any meaningful value after creation is complete.
105 PT(PandaNode) _geom_node;
106
107 // These are filled in as the joint animates.
108 LMatrix4 _net_transform;
109 LMatrix4 _initial_net_transform_inverse;
110
111 // This is the product of the above; the matrix that gets applied to a
112 // vertex (whose coordinates are in the coordinate space of the character
113 // in its neutral pose) to transform it from its neutral position to its
114 // animated position.
115 LMatrix4 _skinning_matrix;
116
117public:
118 virtual TypeHandle get_type() const {
119 return get_class_type();
120 }
121 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
122 static TypeHandle get_class_type() {
123 return _type_handle;
124 }
125 static void init_type() {
126 MovingPartMatrix::init_type();
127 register_type(_type_handle, "CharacterJoint",
128 MovingPartMatrix::get_class_type());
129 }
130
131private:
132 static TypeHandle _type_handle;
133
134 friend class Character;
135 friend class CharacterJointBundle;
136 friend class JointVertexTransform;
137};
138
139#include "characterJoint.I"
140
141#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
The collection of all the joints and sliders in the character.
This represents one joint of the character's animation, containing an animating transform matrix.
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
Definition character.h:38
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This is a specialization on VertexTransform that returns the transform necessary to move vertices as ...
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.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a particular kind of MovingPart that accepts a matrix each frame.
static void register_with_read_factory()
Factory method to generate a MovingPartMatrix object.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
Definition movingPart.I:100
This is a set of zero or more NodePaths.
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
This is the root of a MovingPart hierarchy.
Definition partBundle.h:46
This is the base class for PartRoot and MovingPart.
Definition partGroup.h:43
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
Definition partGroup.cxx:67
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
Definition partGroup.cxx:58
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...
A thread; that is, a lightweight process.
Definition thread.h:46
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.