41 _net_transform(copy._net_transform),
42 _initial_net_transform_inverse(copy._initial_net_transform_inverse),
43 _skinning_matrix(copy._skinning_matrix)
54 const LMatrix4 &default_value) :
62 update_internals(root, parent,
true,
false, current_thread);
68 _initial_net_transform_inverse = invert(_net_transform);
69 _skinning_matrix = LMatrix4::ident_mat();
77 nassertv(_vertex_transforms.
empty());
78 nassertv(_character ==
nullptr);
112 bool parent_changed,
Thread *current_thread) {
113 nassertr(parent !=
nullptr,
false);
115 bool net_changed =
false;
119 if (parent_changed || self_changed) {
122 _net_transform = _value * parent_joint->_net_transform;
136 if (!_net_transform_nodes.
empty()) {
139 NodeList::iterator ai;
140 for (ai = _net_transform_nodes.
begin();
141 ai != _net_transform_nodes.
end();
149 _skinning_matrix = _initial_net_transform_inverse * _net_transform;
153 VertexTransforms::iterator vti;
154 for (vti = _vertex_transforms.
begin(); vti != _vertex_transforms.
end(); ++vti) {
155 (*vti)->mark_modified(current_thread);
159 if (self_changed && !_local_transform_nodes.
empty()) {
162 NodeList::iterator ai;
163 for (ai = _local_transform_nodes.
begin();
164 ai != _local_transform_nodes.
end();
171 return self_changed || net_changed;
179 do_xform(
const LMatrix4 &mat,
const LMatrix4 &inv_mat) {
180 _initial_net_transform_inverse = inv_mat * _initial_net_transform_inverse;
197 if (_character !=
nullptr) {
198 node->
set_effect(CharacterJointEffect::make(_character));
202 return _net_transform_nodes.insert(node).second;
215 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
216 if (effect !=
nullptr &&
218 node->
clear_effect(CharacterJointEffect::get_class_type());
221 return (_net_transform_nodes.erase(node) > 0);
230 return (_net_transform_nodes.
count(node) > 0);
239 NodeList::iterator ai;
240 for (ai = _net_transform_nodes.
begin();
241 ai != _net_transform_nodes.
end();
245 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
246 if (effect !=
nullptr &&
248 node->
clear_effect(CharacterJointEffect::get_class_type());
252 _net_transform_nodes.
clear();
264 NodeList::iterator ai;
265 for (ai = _net_transform_nodes.
begin();
266 ai != _net_transform_nodes.
end();
289 if (_character !=
nullptr) {
290 node->
set_effect(CharacterJointEffect::make(_character));
294 return _local_transform_nodes.insert(node).second;
307 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
308 if (effect !=
nullptr &&
310 node->
clear_effect(CharacterJointEffect::get_class_type());
313 return (_local_transform_nodes.erase(node) > 0);
322 return (_local_transform_nodes.
count(node) > 0);
331 NodeList::iterator ai;
332 for (ai = _local_transform_nodes.
begin();
333 ai != _local_transform_nodes.
end();
337 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
338 if (effect !=
nullptr &&
340 node->
clear_effect(CharacterJointEffect::get_class_type());
344 _local_transform_nodes.
clear();
356 NodeList::iterator ai;
357 for (ai = _local_transform_nodes.
begin();
358 ai != _local_transform_nodes.
end();
376 get_transform_state()
const {
377 return TransformState::make_mat( _value );
384 void CharacterJoint::
385 get_net_transform(LMatrix4 &transform)
const {
386 transform = _net_transform;
393 get_character()
const {
400 void CharacterJoint::
402 if (character != _character) {
404 if (character !=
nullptr) {
406 NodeList::iterator ai;
407 for (ai = _net_transform_nodes.
begin();
408 ai != _net_transform_nodes.
end();
411 node->
set_effect(CharacterJointEffect::make(character));
413 for (ai = _local_transform_nodes.
begin();
414 ai != _local_transform_nodes.
end();
417 node->
set_effect(CharacterJointEffect::make(character));
422 NodeList::iterator ai;
423 for (ai = _net_transform_nodes.
begin();
424 ai != _net_transform_nodes.
end();
428 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
429 if (effect !=
nullptr &&
431 node->
clear_effect(CharacterJointEffect::get_class_type());
434 for (ai = _local_transform_nodes.
begin();
435 ai != _local_transform_nodes.
end();
439 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
440 if (effect !=
nullptr &&
442 node->
clear_effect(CharacterJointEffect::get_class_type());
448 _character = character;
457 NodeList::iterator ni;
463 for (ni = _net_transform_nodes.
begin();
464 ni != _net_transform_nodes.
end();
470 for (ni = _local_transform_nodes.
begin();
471 ni != _local_transform_nodes.
end();
476 _initial_net_transform_inverse.write_datagram(me);
484 void CharacterJoint::
487 MovingPartMatrix::fillin(scan, manager);
494 for(i = 0; i < _num_net_nodes; i++) {
499 for(i = 0; i < _num_local_nodes; i++) {
503 _initial_net_transform_inverse.read_datagram(scan);
515 _character = DCAST(
Character, p_list[pi++]);
517 _character =
nullptr;
521 for (i = 0; i < _num_net_nodes; i++) {
523 _net_transform_nodes.insert(node);
526 for (i = 0; i < _num_local_nodes; i++) {
528 _local_transform_nodes.insert(node);
544 me->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(TransformState) CharacterJoint
Copies the joint's current net transform (composed from the root of the character joint hierarchy) in...
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...
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
This effect will be added automatically to a node by CharacterJoint::add_net_transform() and Characte...
This represents one joint of the character's animation, containing an animating transform matrix.
bool has_net_transform(PandaNode *node) const
Returns true if the node is on the list of nodes that will be updated each frame with the joint's net...
NodePathCollection get_local_transforms()
Returns a list of the local transforms set for this node.
const LMatrix4 & get_transform() const
Returns the transform matrix of the joint.
bool add_net_transform(PandaNode *node)
Adds the indicated node to the list of nodes that will be updated each frame with the joint's net tra...
bool has_local_transform(PandaNode *node) const
Returns true if the node is on the list of nodes that will be updated each frame with the joint's loc...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
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...
static TypedWritable * make_CharacterJoint(const FactoryParams ¶ms)
Factory method to generate a CharacterJoint object.
bool remove_local_transform(PandaNode *node)
Removes the indicated node from the list of nodes that will be updated each frame with the joint's lo...
void clear_net_transforms()
Removes all nodes from the list of nodes that will be updated each frame with the joint's net transfo...
bool add_local_transform(PandaNode *node)
Adds the indicated node to the list of nodes that will be updated each frame with the joint's local t...
bool remove_net_transform(PandaNode *node)
Removes the indicated node from the list of nodes that will be updated each frame with the joint's ne...
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
NodePathCollection get_net_transforms()
Returns a list of the net transforms set for this node.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
void clear_local_transforms()
Removes all nodes from the list of nodes that will be updated each frame with the joint's local trans...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Takes in a vector of pointers to TypedWritable objects that correspond to all the requests for pointe...
static void register_with_read_factory()
Factory method to generate a CharacterJoint object.
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.
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
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.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is a set of zero or more NodePaths.
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
A basic node of the scene graph or data graph.
void clear_effect(TypeHandle type)
Removes the render effect of the given type from this node.
set_transform
Sets the transform that will be applied to this node and below.
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
This is the root of a MovingPart hierarchy.
get_root_xform
Returns the transform matrix which is implicitly applied at the root of the animated hierarchy.
This is the base class for PartRoot and MovingPart.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
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...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
size_type_0 count(const key_type_0 &key) const
Returns the number of elements that sort equivalent to the key that are in the vector.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
void clear()
Removes all elements from the ordered vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.