15 #include "characterJoint.h"
16 #include "config_char.h"
17 #include "jointVertexTransform.h"
18 #include "characterJointEffect.h"
20 #include "datagramIterator.h"
21 #include "bamReader.h"
22 #include "bamWriter.h"
46 _net_transform(copy._net_transform),
47 _initial_net_transform_inverse(copy._initial_net_transform_inverse)
68 update_internals(root, parent,
true,
false, current_thread);
72 _initial_net_transform_inverse = invert(_net_transform);
82 nassertv(_vertex_transforms.
empty());
83 nassertv(_character == (
Character *)NULL);
126 bool parent_changed,
Thread *current_thread) {
127 nassertr(parent != (
PartGroup *)NULL,
false);
129 bool net_changed =
false;
133 if (parent_changed || self_changed) {
136 _net_transform = _value * parent_joint->_net_transform;
150 if (!_net_transform_nodes.
empty()) {
151 CPT(TransformState) t = TransformState::make_mat(_net_transform);
153 NodeList::iterator ai;
154 for (ai = _net_transform_nodes.
begin();
155 ai != _net_transform_nodes.
end();
164 VertexTransforms::iterator vti;
165 for (vti = _vertex_transforms.
begin(); vti != _vertex_transforms.
end(); ++vti) {
166 (*vti)->_matrix_stale =
true;
167 (*vti)->mark_modified(current_thread);
171 if (self_changed && !_local_transform_nodes.
empty()) {
172 CPT(TransformState) t = TransformState::make_mat(_value);
174 NodeList::iterator ai;
175 for (ai = _local_transform_nodes.
begin();
176 ai != _local_transform_nodes.
end();
183 return self_changed || net_changed;
195 _initial_net_transform_inverse = inv_mat * _initial_net_transform_inverse;
217 node->
set_effect(CharacterJointEffect::make(_character));
219 CPT(TransformState) t = TransformState::make_mat(_net_transform);
221 return _net_transform_nodes.insert(node).second;
238 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
241 node->
clear_effect(CharacterJointEffect::get_class_type());
244 return (_net_transform_nodes.erase(node) > 0);
256 return (_net_transform_nodes.
count(node) > 0);
268 NodeList::iterator ai;
269 for (ai = _net_transform_nodes.
begin();
270 ai != _net_transform_nodes.
end();
274 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
277 node->
clear_effect(CharacterJointEffect::get_class_type());
281 _net_transform_nodes.
clear();
296 NodeList::iterator ai;
297 for (ai = _net_transform_nodes.
begin();
298 ai != _net_transform_nodes.
end();
327 node->
set_effect(CharacterJointEffect::make(_character));
329 CPT(TransformState) t = TransformState::make_mat(_value);
331 return _local_transform_nodes.insert(node).second;
348 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
351 node->
clear_effect(CharacterJointEffect::get_class_type());
354 return (_local_transform_nodes.erase(node) > 0);
366 return (_local_transform_nodes.
count(node) > 0);
378 NodeList::iterator ai;
379 for (ai = _local_transform_nodes.
begin();
380 ai != _local_transform_nodes.
end();
384 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
387 node->
clear_effect(CharacterJointEffect::get_class_type());
391 _local_transform_nodes.
clear();
406 NodeList::iterator ai;
407 for (ai = _local_transform_nodes.
begin();
408 ai != _local_transform_nodes.
end();
429 get_transform_state()
const {
430 return TransformState::make_mat( _value );
440 void CharacterJoint::
441 get_net_transform(
LMatrix4 &transform)
const {
442 transform = _net_transform;
460 void CharacterJoint::
462 if (character != _character) {
467 NodeList::iterator ai;
468 for (ai = _net_transform_nodes.
begin();
469 ai != _net_transform_nodes.
end();
472 node->
set_effect(CharacterJointEffect::make(character));
474 for (ai = _local_transform_nodes.
begin();
475 ai != _local_transform_nodes.
end();
478 node->
set_effect(CharacterJointEffect::make(character));
483 NodeList::iterator ai;
484 for (ai = _net_transform_nodes.
begin();
485 ai != _net_transform_nodes.
end();
492 node->
clear_effect(CharacterJointEffect::get_class_type());
495 for (ai = _local_transform_nodes.
begin();
496 ai != _local_transform_nodes.
end();
500 CPT(
RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type());
502 DCAST(CharacterJointEffect, effect)->
get_character() == _character) {
503 node->
clear_effect(CharacterJointEffect::get_class_type());
509 _character = character;
520 NodeList::iterator ni;
526 for (ni = _net_transform_nodes.
begin();
527 ni != _net_transform_nodes.
end();
533 for (ni = _local_transform_nodes.
begin();
534 ni != _local_transform_nodes.
end();
550 void CharacterJoint::
553 MovingPartMatrix::fillin(scan, manager);
560 for(i = 0; i < _num_net_nodes; i++) {
565 for(i = 0; i < _num_local_nodes; i++) {
584 _character = DCAST(
Character, p_list[pi++]);
590 for (i = 0; i < _num_net_nodes; i++) {
592 _net_transform_nodes.insert(node);
595 for (i = 0; i < _num_local_nodes; i++) {
597 _local_transform_nodes.insert(node);
614 parse_params(params, scan, manager);
615 me->fillin(scan, manager);
A basic node of the scene graph or data graph.
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
An animated character, with skeleton-morph animation and either soft-skinned or hard-skinned vertices...
void clear()
Removes all elements from the ordered vector.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This effect will be added automatically to a node by CharacterJoint::add_net_transform() and Characte...
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.
Base class for objects that can be written to and read from Bam files.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
const LMatrix4 & get_root_xform() const
Returns the transform matrix which is implicitly applied at the root of the animated hierarchy...
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...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
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...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
void clear_local_transforms()
Removes all nodes from the list of nodes that will be updated each frame with the joint's local trans...
static TypedWritable * make_CharacterJoint(const FactoryParams ¶ms)
Factory method to generate a CharacterJoint object.
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...
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...
static void register_with_read_factory()
Factory method to generate a CharacterJoint object.
void write_datagram(Datagram &destination) const
Writes the matrix to the Datagram using add_stdfloat().
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
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...
This is a 4-by-4 transform matrix.
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...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
void read_datagram(DatagramIterator &source)
Reads the matrix from the Datagram using get_stdfloat().
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...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
This is a particular kind of MovingPart that accepts a matrix each frame.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A thread; that is, a lightweight process.
This is the root of a MovingPart hierarchy.
This represents one joint of the character's animation, containing an animating transform matrix...
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...
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 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...
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
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...
size_type_0 size() const
Returns the number of elements in the ordered vector.
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
A class to retrieve the individual data elements previously stored in a Datagram. ...
NodePathCollection get_local_transforms()
Returns a list of the local transforms set for this node.
void clear_effect(TypeHandle type)
Removes the render effect of the given type from this node.
Character * get_character() const
Returns the Character that owns this joint.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
TypeHandle is the identifier used to differentiate C++ class types.
NodePathCollection get_net_transforms()
Returns a list of the net transforms set for this node.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Sets the transform that will be applied to this node and below.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
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.
const LMatrix4 & get_transform() const
Returns the transform matrix of the joint.
This is a set of zero or more NodePaths.
This is the base class for PartRoot and MovingPart.