Panda3D
Loading...
Searching...
No Matches
partGroup.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 partGroup.h
10 * @author drose
11 * @date 1999-02-22
12 */
13
14#ifndef PARTGROUP_H
15#define PARTGROUP_H
16
17#include "pandabase.h"
18
20#include "pointerTo.h"
21#include "namable.h"
22#include "typedef.h"
23#include "thread.h"
24#include "plist.h"
25#include "luse.h"
26
27class AnimControl;
28class AnimGroup;
29class PartBundle;
30class PartSubset;
31class BamReader;
32class FactoryParams;
33class BitArray;
34class CycleData;
35class TransformState;
36class PandaNode;
37class AnimChannelBase;
38
39/**
40 * This is the base class for PartRoot and MovingPart. It defines a hierarchy
41 * of MovingParts.
42 */
43class EXPCL_PANDA_CHAN PartGroup : public TypedWritableReferenceCount, public Namable {
44PUBLISHED:
45 // This enum defines bits which may be passed into check_hierarchy() and
46 // PartBundle::bind_anim() to allow an inexact match of channel hierarchies.
47 // This specifies conditions that we don't care about enforcing.
48 enum HierarchyMatchFlags {
49 HMF_ok_part_extra = 0x01,
50 HMF_ok_anim_extra = 0x02,
51 HMF_ok_wrong_root_name = 0x04,
52 };
53
54protected:
55 // The default constructor is protected: don't try to create a PartGroup
56 // without a parent. To create a PartGroup hierarchy, you must first create
57 // a PartBundle, and use that as the parent of any subsequent children.
58 INLINE PartGroup(const std::string &name = "");
59 INLINE PartGroup(const PartGroup &copy);
60
61PUBLISHED:
62 // This is the normal PartGroup constructor.
63 explicit PartGroup(PartGroup *parent, const std::string &name);
64 virtual ~PartGroup();
65 virtual bool is_character_joint() const;
66
67 virtual PartGroup *make_copy() const;
68 PartGroup *copy_subgraph() const;
69
70 int get_num_children() const;
71 PartGroup *get_child(int n) const;
72 MAKE_SEQ(get_children, get_num_children, get_child);
73
74 PartGroup *get_child_named(const std::string &name) const;
75 PartGroup *find_child(const std::string &name) const;
76 void sort_descendants();
77
78 MAKE_SEQ_PROPERTY(children, get_num_children, get_child);
79
80 bool apply_freeze(const TransformState *transform);
81 virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale);
82 virtual bool apply_freeze_scalar(PN_stdfloat value);
83 virtual bool apply_control(PandaNode *node);
84 virtual bool clear_forced_channel();
85 virtual AnimChannelBase *get_forced_channel() const;
86
87 virtual void write(std::ostream &out, int indent_level) const;
88 virtual void write_with_value(std::ostream &out, int indent_level) const;
89
90public:
91 virtual TypeHandle get_value_type() const;
92
93 bool check_hierarchy(const AnimGroup *anim,
94 const PartGroup *parent,
95 int hierarchy_match_flags = 0) const;
96
97 virtual bool do_update(PartBundle *root, const CycleData *root_cdata,
98 PartGroup *parent, bool parent_changed,
99 bool anim_changed, Thread *current_thread);
100 virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat);
101 virtual void determine_effective_channels(const CycleData *root_cdata);
102
103protected:
104 void write_descendants(std::ostream &out, int indent_level) const;
105 void write_descendants_with_value(std::ostream &out, int indent_level) const;
106
107 virtual void pick_channel_index(plist<int> &holes, int &next) const;
108 virtual void bind_hierarchy(AnimGroup *anim, int channel_index,
109 int &joint_index, bool is_included,
110 BitArray &bound_joints,
111 const PartSubset &subset);
112 virtual void find_bound_joints(int &joint_index, bool is_included,
113 BitArray &bound_joints,
114 const PartSubset &subset);
115
116 typedef pvector< PT(PartGroup) > Children;
117 Children _children;
118
119public:
120 static void register_with_read_factory();
121 virtual void write_datagram(BamWriter* manager, Datagram &me);
122 virtual int complete_pointers(TypedWritable **p_list,
123 BamReader *manager);
124
125 static TypedWritable *make_PartGroup(const FactoryParams &params);
126
127protected:
128 void fillin(DatagramIterator& scan, BamReader* manager);
129
130public:
131 virtual TypeHandle get_type() const {
132 return get_class_type();
133 }
134 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
135 static TypeHandle get_class_type() {
136 return _type_handle;
137 }
138
139public:
140 static void init_type() {
141 TypedWritableReferenceCount::init_type();
142 register_type(_type_handle, "PartGroup",
143 TypedWritableReferenceCount::get_class_type());
144 }
145
146private:
147 static TypeHandle _type_handle;
148
149 friend class Character;
150 friend class CharacterJointBundle;
151 friend class PartBundle;
152};
153
154#include "partGroup.I"
155
156#endif
Parent class for all animation channels.
Controls the timing of a character animation.
Definition animControl.h:38
This is the base class for AnimChannel and AnimBundle.
Definition animGroup.h:33
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
A dynamic array with an unlimited number of bits.
Definition bitArray.h:40
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
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...
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
get_num_children
Returns the number of child nodes of the group.
Definition partGroup.h:72
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
PartGroup * get_child_named(const std::string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
PartGroup * copy_subgraph() const
Allocates and returns a new copy of this node and of all of its children.
Definition partGroup.cxx:75
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
Definition partGroup.cxx:67
PartGroup * find_child(const std::string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists.
virtual bool apply_freeze_scalar(PN_stdfloat value)
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.
virtual bool apply_control(PandaNode *node)
Specifies a node to influence this particular joint so that it will always hold the node's transform.
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
get_child
Returns the nth child of the group.
Definition partGroup.h:72
static void register_with_read_factory()
Factory method to generate a PartGroup object.
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...
static TypedWritable * make_PartGroup(const FactoryParams &params)
Factory method to generate a PartGroup object.
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
Definition partGroup.cxx:58
virtual void write_with_value(std::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 void determine_effective_channels(const CycleData *root_cdata)
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effecti...
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 TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
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.
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.
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition partSubset.h:25
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
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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 our own Panda specialization on the default STL list.
Definition plist.h:35
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.