15 #include "partGroup.h" 16 #include "animGroup.h" 17 #include "config_chan.h" 18 #include "partSubset.h" 22 #include "datagramIterator.h" 23 #include "bamReader.h" 24 #include "bamWriter.h" 25 #include "transformState.h" 41 _children(get_class_type())
43 nassertv(parent != NULL);
45 parent->_children.push_back(
this);
90 if (root->get_type() != get_type()) {
92 <<
"Don't know how to copy " << get_type() <<
"\n";
95 Children::const_iterator ci;
96 for (ci = _children.begin(); ci != _children.end(); ++ci) {
98 root->_children.push_back(child);
112 return _children.size();
123 nassertr(n >= 0 && n < (
int)_children.size(), NULL);
138 Children::const_iterator ci;
139 for (ci = _children.begin(); ci != _children.end(); ++ci) {
141 if (child->get_name() == name) {
159 Children::const_iterator ci;
160 for (ci = _children.begin(); ci != _children.end(); ++ci) {
162 if (child->get_name() == name) {
178 return a->get_name() < b->get_name();
195 Children::iterator ci;
196 for (ci = _children.begin(); ci != _children.end(); ++ci) {
197 (*ci)->sort_descendants();
304 write(ostream &out,
int indent_level)
const {
305 indent(out, indent_level)
306 << get_type() <<
" " << get_name() <<
" {\n";
307 write_descendants(out, indent_level + 2);
308 indent(out, indent_level) <<
"}\n";
319 indent(out, indent_level)
320 << get_type() <<
" " << get_name() <<
" {\n";
321 write_descendants_with_value(out, indent_level + 2);
322 indent(out, indent_level) <<
"}\n";
353 int hierarchy_match_flags)
const {
356 if (chan_cat.is_error()) {
359 <<
" while matching anim node has type " << anim->
get_value_type()
365 if (chan_cat.is_info()) {
391 <<
" children, while matching anim node has " 401 match = (pc->get_name() == ac->get_name());
405 <<
"Part " << get_name() <<
" has a different set of children " 406 <<
" than matching anim node:\n";
416 if (pc->get_name() < ac->get_name()) {
418 <<
" part has " << pc->get_name()
419 <<
", not in anim.\n";
421 }
else if (ac->get_name() < pc->get_name()) {
423 <<
" anim has " << ac->get_name()
424 <<
", not in part.\n";
436 <<
" part has " << pc->get_name()
437 <<
", not in anim.\n";
444 <<
" anim has " << ac->get_name()
445 <<
", not in part.\n";
460 if (pc->get_name() < ac->get_name()) {
461 if (pc->get_name() ==
"morph") {
464 if ((hierarchy_match_flags & HMF_ok_part_extra) == 0) {
469 }
else if (ac->get_name() < pc->get_name()) {
470 if (ac->get_name() ==
"morph") {
473 if ((hierarchy_match_flags & HMF_ok_anim_extra) == 0) {
491 if (pc->get_name() ==
"morph") {
494 if ((hierarchy_match_flags & HMF_ok_part_extra) == 0) {
505 if (ac->get_name() ==
"morph") {
508 if ((hierarchy_match_flags & HMF_ok_anim_extra) == 0) {
533 bool parent_changed,
bool anim_changed,
Thread *current_thread) {
534 bool any_changed =
false;
536 Children::iterator ci;
537 for (ci = _children.begin(); ci != _children.end(); ++ci) {
538 if ((*ci)->do_update(root, root_cdata,
this, parent_changed,
539 anim_changed, current_thread)) {
556 Children::const_iterator ci;
558 for (ci = _children.begin(); ci != _children.end(); ++ci) {
559 (*ci)->do_xform(mat, inv_mat);
572 Children::iterator ci;
573 for (ci = _children.begin(); ci != _children.end(); ++ci) {
574 (*ci)->determine_effective_channels(root_cdata);
586 write_descendants(ostream &out,
int indent_level)
const {
587 Children::const_iterator ci;
589 for (ci = _children.begin(); ci != _children.end(); ++ci) {
590 (*ci)->write(out, indent_level);
601 write_descendants_with_value(ostream &out,
int indent_level)
const {
602 Children::const_iterator ci;
604 for (ci = _children.begin(); ci != _children.end(); ++ci) {
605 (*ci)->write_with_value(out, indent_level);
618 pick_channel_index(
plist<int> &holes,
int &next)
const {
619 Children::const_iterator ci;
620 for (ci = _children.begin(); ci != _children.end(); ++ci) {
621 (*ci)->pick_channel_index(holes, next);
633 bind_hierarchy(
AnimGroup *anim,
int channel_index,
int &joint_index,
634 bool is_included,
BitArray &bound_joints,
647 while (i < part_num_children && j < anim_num_children) {
651 if (pc->get_name() < ac->get_name()) {
654 pc->bind_hierarchy(NULL, channel_index, joint_index, is_included,
655 bound_joints, subset);
658 }
else if (ac->get_name() < pc->get_name()) {
664 pc->bind_hierarchy(ac, channel_index, joint_index, is_included,
665 bound_joints, subset);
672 while (i < part_num_children) {
674 pc->bind_hierarchy(NULL, channel_index, joint_index, is_included,
675 bound_joints, subset);
692 find_bound_joints(
int &joint_index,
bool is_included,
BitArray &bound_joints,
701 for (
int i = 0; i < part_num_children; ++i) {
703 pc->find_bound_joints(joint_index, is_included, bound_joints, subset);
717 for (
size_t i = 0; i < _children.size(); i++) {
742 _children.reserve(num_children);
743 for (
int i = 0; i < num_children; i++) {
745 _children.push_back(NULL);
760 Children::iterator ci;
761 for (ci = _children.begin(); ci != _children.end(); ++ci) {
779 parse_params(params, scan, manager);
780 me->fillin(scan, manager);
bool matches_exclude(const string &joint_name) const
Returns true if the indicated name matches a name on the exclude list, false otherwise.
A basic node of the scene graph or data graph.
This is the base class for all three-component vectors and points.
bool matches_include(const string &joint_name) const
Returns true if the indicated name matches a name on the include list, false otherwise.
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
bool get_bool()
Extracts a boolean value.
void add_string(const string &str)
Adds a variable-length string to the datagram.
static TypeHandle none()
Returns a special zero-valued TypeHandle that is used to indicate no type.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
int get_num_children() const
Returns the number of child nodes of the group.
virtual void write_with_value(ostream &out, int indent_level) const
Writes a brief description of the group, showing its current value, and that of all of its descendant...
virtual bool do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread)
Recursively update this particular part and all of its descendents for the current frame...
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
int get_num_children() const
Returns the number of child nodes of the group.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
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 void consider_yield()
Possibly suspends the current thread for the rest of the current epoch, if it has run for enough this...
virtual void write(ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
string get_string()
Extracts a variable-length string.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
PartGroup * find_child(const string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists...
A dynamic array with an unlimited number of bits.
Parent class for all animation channels.
PartGroup * get_child(int n) const
Returns the nth child of the group.
A base class for all things which can have a name.
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
This is the base class for AnimChannel and AnimBundle.
AnimGroup * get_child_named(const string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
AnimGroup * get_child(int n) const
Returns the nth child of the group.
virtual void determine_effective_channels(const CycleData *root_cdata)
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effecti...
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 a 4-by-4 transform matrix.
virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale)
Freezes this particular joint so that it will always hold the specified transform.
bool apply_freeze(const TransformState *transform)
Freezes this particular joint so that it will always hold the specified transform.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
virtual bool apply_control(PandaNode *node)
Specifies a node to influence this particular joint so that it will always hold the node's transform...
void read_datagram(DatagramIterator &source)
Reads the matrix from the Datagram using get_stdfloat().
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
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.
PartGroup * get_child_named(const string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
static void register_with_read_factory()
Factory method to generate a PartGroup object.
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.
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
bool check_hierarchy(const AnimGroup *anim, const PartGroup *parent, int hierarchy_match_flags=0) const
Walks the part hierarchy in tandem with the indicated anim hierarchy, and returns true if the hierarc...
PartGroup * copy_subgraph() const
Allocates and returns a new copy of this node and of all of its children.
A class to retrieve the individual data elements previously stored in a Datagram. ...
static TypedWritable * make_PartGroup(const FactoryParams ¶ms)
Factory method to generate a PartGroup object.
TypeHandle is the identifier used to differentiate C++ class types.
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
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...
virtual bool apply_freeze_scalar(PN_stdfloat value)
Freezes this particular joint so that it will always hold the specified transform.
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.
This is the base class for PartRoot and MovingPart.