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
19#include "typedWritableReferenceCount.h"
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
27 class AnimControl;
28 class AnimGroup;
29 class PartBundle;
30 class PartSubset;
31 class BamReader;
32 class FactoryParams;
33 class BitArray;
34 class CycleData;
35 class TransformState;
36 class PandaNode;
37 class AnimChannelBase;
38
39/**
40 * This is the base class for PartRoot and MovingPart. It defines a hierarchy
41 * of MovingParts.
42 */
43 class 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
54 protected:
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
90 public:
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
103 protected:
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
119 public:
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
127 protected:
128 void fillin(DatagramIterator& scan, BamReader* manager);
129
130 public:
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
139 public:
140 static void init_type() {
141 TypedWritableReferenceCount::init_type();
142 register_type(_type_handle, "PartGroup",
143 TypedWritableReferenceCount::get_class_type());
144 }
145
146 private:
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
AnimChannelBase
Parent class for all animation channels.
Definition animChannelBase.h:30
AnimControl
Controls the timing of a character animation.
Definition animControl.h:38
AnimGroup
This is the base class for AnimChannel and AnimBundle.
Definition animGroup.h:33
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BitArray
A dynamic array with an unlimited number of bits.
Definition bitArray.h:40
CycleData
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
PandaNode
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
PartBundle
This is the root of a MovingPart hierarchy.
Definition partBundle.h:46
PartGroup::get_num_children
get_num_children
Returns the number of child nodes of the group.
Definition partGroup.h:72
PartGroup::sort_descendants
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
Definition partGroup.cxx:167
PartGroup::get_child_named
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.
Definition partGroup.cxx:118
PartGroup::copy_subgraph
PartGroup * copy_subgraph() const
Allocates and returns a new copy of this node and of all of its children.
Definition partGroup.cxx:75
PartGroup::write
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
Definition partGroup.cxx:256
PartGroup::make_copy
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
Definition partGroup.cxx:67
PartGroup::find_child
PartGroup * find_child(const std::string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists.
Definition partGroup.cxx:136
PartGroup::apply_freeze_scalar
virtual bool apply_freeze_scalar(PN_stdfloat value)
Freezes this particular joint so that it will always hold the specified transform.
Definition partGroup.cxx:211
PartGroup::apply_freeze
bool apply_freeze(const TransformState *transform)
Freezes this particular joint so that it will always hold the specified transform.
Definition partGroup.cxx:185
PartGroup::apply_control
virtual bool apply_control(PandaNode *node)
Specifies a node to influence this particular joint so that it will always hold the node's transform.
Definition partGroup.cxx:225
PartGroup::clear_forced_channel
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
Definition partGroup.cxx:237
PartGroup::get_child
get_child
Returns the nth child of the group.
Definition partGroup.h:72
PartGroup::register_with_read_factory
static void register_with_read_factory()
Factory method to generate a PartGroup object.
Definition partGroup.cxx:695
PartGroup::check_hierarchy
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...
Definition partGroup.cxx:294
PartGroup::make_PartGroup
static TypedWritable * make_PartGroup(const FactoryParams &params)
Factory method to generate a PartGroup object.
Definition partGroup.cxx:681
PartGroup::get_forced_channel
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
Definition partGroup.cxx:247
PartGroup::is_character_joint
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
Definition partGroup.cxx:58
PartGroup::write_with_value
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...
Definition partGroup.cxx:268
PartGroup::determine_effective_channels
virtual void determine_effective_channels(const CycleData *root_cdata)
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effecti...
Definition partGroup.cxx:503
PartGroup::do_xform
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...
Definition partGroup.cxx:490
PartGroup::get_value_type
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
Definition partGroup.cxx:281
PartGroup::apply_freeze_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.
Definition partGroup.cxx:198
PartGroup::do_update
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.
Definition partGroup.cxx:470
PartSubset
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition partSubset.h:25
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
TransformState
Indicates a coordinate-system transform on vertices.
Definition transformState.h:54
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
TypedWritable::complete_pointers
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().
Definition typedWritable.cxx:81
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
namable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
partGroup.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
plist.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
thread.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedef.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.