Panda3D
partBundle.I
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 partBundle.I
10  * @author drose
11  * @date 1999-02-22
12  */
13 
14 /**
15  * Returns the AnimPreloadTable associated with the PartBundle. This table,
16  * if present, can be used for the benefit of load_bind_anim() to allow
17  * asynchronous binding.
18  */
19 INLINE CPT(AnimPreloadTable) PartBundle::
20 get_anim_preload() const {
21  return _anim_preload.get_read_pointer();
22 }
23 
24 /**
25  * Returns a modifiable pointer to the AnimPreloadTable associated with the
26  * PartBundle, if any.
27  */
28 INLINE PT(AnimPreloadTable) PartBundle::
29 modify_anim_preload() {
30  return _anim_preload.get_write_pointer();
31 }
32 
33 /**
34  * Replaces the AnimPreloadTable associated with the PartBundle.
35  */
36 INLINE void PartBundle::
38  _anim_preload = anim_preload;
39 }
40 
41 /**
42  * Removes any AnimPreloadTable associated with the PartBundle.
43  */
44 INLINE void PartBundle::
46  _anim_preload = nullptr;
47 }
48 
49 /**
50  * Defines the algorithm that is used when blending multiple frames or
51  * multiple animations together, when either anim_blend_flag or
52  * frame_blend_flag is set to true.
53  *
54  * See partBundle.h for a description of the meaning of each of the BlendType
55  * values.
56  */
57 INLINE void PartBundle::
58 set_blend_type(PartBundle::BlendType bt) {
59  nassertv(Thread::get_current_pipeline_stage() == 0);
60  CDWriter cdata(_cycler);
61  cdata->_blend_type = bt;
62 }
63 
64 /**
65  * Returns the algorithm that is used when blending multiple frames or
66  * multiple animations together, when either anim_blend_flag or
67  * frame_blend_flag is set to true.
68  */
69 INLINE PartBundle::BlendType PartBundle::
70 get_blend_type() const {
71  CDReader cdata(_cycler);
72  return cdata->_blend_type;
73 }
74 
75 /**
76  * Returns whether the character allows multiple different animations to be
77  * bound simultaneously. See set_anim_blend_flag().
78  */
79 INLINE bool PartBundle::
80 get_anim_blend_flag() const {
81  CDReader cdata(_cycler);
82  return cdata->_anim_blend_flag;
83 }
84 
85 /**
86  * Specifies whether the character interpolates (blends) between two
87  * sequential frames of an active animation, showing a smooth intra-frame
88  * motion, or whether it holds each frame until the next frame is ready,
89  * showing precisely the specified animation.
90  *
91  * When this value is false, the character holds each frame until the next is
92  * ready. When this is true, the character will interpolate between two
93  * consecutive frames of animation for each frame the animation is onscreen,
94  * according to the amount of time elapsed between the frames.
95  *
96  * The default value of this flag is determined by the interpolate-frames
97  * Config.prc variable.
98  *
99  * Use set_blend_type() to change the algorithm that the character uses to
100  * interpolate matrix positions.
101  */
102 INLINE void PartBundle::
103 set_frame_blend_flag(bool frame_blend_flag) {
104  nassertv(Thread::get_current_pipeline_stage() == 0);
105  CDWriter cdata(_cycler);
106  cdata->_frame_blend_flag = frame_blend_flag;
107 }
108 
109 /**
110  * Returns whether the character interpolates (blends) between two sequential
111  * animation frames, or whether it holds the current frame until the next one
112  * is ready. See set_frame_blend_flag().
113  */
114 INLINE bool PartBundle::
115 get_frame_blend_flag() const {
116  CDReader cdata(_cycler);
117  return cdata->_frame_blend_flag;
118 }
119 
120 /**
121  * Specifies the transform matrix which is implicitly applied at the root of
122  * the animated hierarchy.
123  */
124 INLINE void PartBundle::
125 set_root_xform(const LMatrix4 &root_xform) {
126  nassertv(Thread::get_current_pipeline_stage() == 0);
127  CDWriter cdata(_cycler);
128  cdata->_root_xform = root_xform;
129  cdata->_anim_changed = true;
130 }
131 
132 /**
133  * Applies the indicated transform to the root of the animated hierarchy.
134  */
135 INLINE void PartBundle::
136 xform(const LMatrix4 &mat) {
137  nassertv(Thread::get_current_pipeline_stage() == 0);
138  CDWriter cdata(_cycler);
139  cdata->_root_xform = cdata->_root_xform * mat;
140  do_xform(mat, invert(mat));
141  cdata->_anim_changed = true;
142 }
143 
144 /**
145  * Returns the transform matrix which is implicitly applied at the root of the
146  * animated hierarchy.
147  */
148 INLINE const LMatrix4 &PartBundle::
149 get_root_xform() const {
150  CDReader cdata(_cycler);
151  return cdata->_root_xform;
152 }
153 
154 /**
155  * Returns the number of PartBundleNodes that contain a pointer to this
156  * PartBundle.
157  */
158 INLINE int PartBundle::
159 get_num_nodes() const {
160  return _nodes.size();
161 }
162 
163 /**
164  * Returns the nth PartBundleNode associated with this PartBundle.
165  */
167 get_node(int n) const {
168  nassertr(n >= 0 && n < (int)_nodes.size(), nullptr);
169  return _nodes[n];
170 }
171 
172 
173 /**
174  * Sets the amount by which the character is affected by the indicated
175  * AnimControl (and its associated animation). Normally, this will only be
176  * zero or one. Zero indicates the animation does not affect the character,
177  * and one means it does.
178  *
179  * If the _anim_blend_flag is not false (see set_anim_blend_flag()), it is
180  * possible to have multiple AnimControls in effect simultaneously. In this
181  * case, the effect is a weight that indicates the relative importance of each
182  * AnimControl to the final animation.
183  */
184 void PartBundle::
185 set_control_effect(AnimControl *control, PN_stdfloat effect) {
186  nassertv(Thread::get_current_pipeline_stage() == 0);
187 
188  CDWriter cdata(_cycler);
189  do_set_control_effect(control, effect, cdata);
190 }
191 
192 /**
193  * Returns the amount by which the character is affected by the indicated
194  * AnimControl and its associated animation. See set_control_effect().
195  */
196 INLINE PN_stdfloat PartBundle::
198  CDReader cdata(_cycler);
199  return do_get_control_effect(control, cdata);
200 }
201 
202 /**
203  * Specifies the minimum amount of time, in seconds, that should elapse
204  * between any two consecutive updates. This is normally used by
205  * Character::set_lod_animation(), and should not be called directly.
206  */
207 INLINE void PartBundle::
208 set_update_delay(double delay) {
209  _update_delay = delay;
210 }
This table records data about a list of animations for a particular model, such as number of frames a...
void set_control_effect(AnimControl *control, PN_stdfloat effect)
Sets the amount by which the character is affected by the indicated AnimControl (and its associated a...
Definition: partBundle.I:185
CPT(AnimPreloadTable) PartBundle
Returns the AnimPreloadTable associated with the PartBundle.
Definition: partBundle.I:19
void xform(const LMatrix4 &mat)
Applies the indicated transform to the root of the animated hierarchy.
Definition: partBundle.I:136
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
void set_anim_preload(AnimPreloadTable *table)
Replaces the AnimPreloadTable associated with the PartBundle.
Definition: partBundle.I:37
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
set_root_xform
Specifies the transform matrix which is implicitly applied at the root of the animated hierarchy.
Definition: partBundle.h:119
set_frame_blend_flag
Specifies whether the character interpolates (blends) between two sequential frames of an active anim...
Definition: partBundle.h:118
PN_stdfloat get_control_effect(AnimControl *control) const
Returns the amount by which the character is affected by the indicated AnimControl and its associated...
Definition: partBundle.I:197
This is a node that contains a pointer to an PartBundle.
void clear_anim_preload()
Removes any AnimPreloadTable associated with the PartBundle.
Definition: partBundle.I:45
void set_update_delay(double delay)
Specifies the minimum amount of time, in seconds, that should elapse between any two consecutive upda...
Definition: partBundle.I:208
set_blend_type
Defines the algorithm that is used when blending multiple frames or multiple animations together,...
Definition: partBundle.h:116
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
Controls the timing of a character animation.
Definition: animControl.h:38
get_node
Returns the nth PartBundleNode associated with this PartBundle.
Definition: partBundle.h:114