Panda3D
partBundle.I
1 // Filename: partBundle.I
2 // Created by: drose (22Feb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PartBundle::get_anim_preload
18 // Access: Published
19 // Description: Returns the AnimPreloadTable associated with
20 // the PartBundle. This table, if present, can be used
21 // for the benefit of load_bind_anim() to allow
22 // asynchronous binding.
23 ////////////////////////////////////////////////////////////////////
24 INLINE CPT(AnimPreloadTable) PartBundle::
25 get_anim_preload() const {
26  return _anim_preload.get_read_pointer();
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: PartBundle::modify_anim_preload
31 // Access: Published
32 // Description: Returns a modifiable pointer to the AnimPreloadTable
33 // associated with the PartBundle, if any.
34 ////////////////////////////////////////////////////////////////////
35 INLINE PT(AnimPreloadTable) PartBundle::
36 modify_anim_preload() {
37  return _anim_preload.get_write_pointer();
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: PartBundle::set_anim_preload
42 // Access: Published
43 // Description: Replaces the AnimPreloadTable associated with
44 // the PartBundle.
45 ////////////////////////////////////////////////////////////////////
46 INLINE void PartBundle::
48  _anim_preload = anim_preload;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: PartBundle::clear_anim_preload
53 // Access: Published
54 // Description: Removes any AnimPreloadTable associated with
55 // the PartBundle.
56 ////////////////////////////////////////////////////////////////////
57 INLINE void PartBundle::
59  _anim_preload = NULL;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: PartBundle::set_blend_type
64 // Access: Published
65 // Description: Defines the algorithm that is used when blending
66 // multiple frames or multiple animations together, when
67 // either anim_blend_flag or frame_blend_flag is set
68 // to true.
69 //
70 // See partBundle.h for a description of the meaning of
71 // each of the BlendType values.
72 ////////////////////////////////////////////////////////////////////
73 INLINE void PartBundle::
74 set_blend_type(PartBundle::BlendType bt) {
75  nassertv(Thread::get_current_pipeline_stage() == 0);
76  CDWriter cdata(_cycler);
77  cdata->_blend_type = bt;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: PartBundle::get_blend_type
82 // Access: Published
83 // Description: Returns the algorithm that is used when blending
84 // multiple frames or multiple animations together, when
85 // either anim_blend_flag or frame_blend_flag is set
86 // to true.
87 ////////////////////////////////////////////////////////////////////
88 INLINE PartBundle::BlendType PartBundle::
89 get_blend_type() const {
90  CDReader cdata(_cycler);
91  return cdata->_blend_type;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: PartBundle::get_anim_blend_flag
96 // Access: Published
97 // Description: Returns whether the character allows multiple
98 // different animations to be bound simultaneously. See
99 // set_anim_blend_flag().
100 ////////////////////////////////////////////////////////////////////
101 INLINE bool PartBundle::
103  CDReader cdata(_cycler);
104  return cdata->_anim_blend_flag;
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: PartBundle::set_frame_blend_flag
109 // Access: Published
110 // Description: Specifies whether the character interpolates (blends)
111 // between two sequential frames of an active animation,
112 // showing a smooth intra-frame motion, or whether it
113 // holds each frame until the next frame is ready,
114 // showing precisely the specified animation.
115 //
116 // When this value is false, the character holds each
117 // frame until the next is ready. When this is true,
118 // the character will interpolate between two
119 // consecutive frames of animation for each frame the
120 // animation is onscreen, according to the amount of
121 // time elapsed between the frames.
122 //
123 // The default value of this flag is determined by the
124 // interpolate-frames Config.prc variable.
125 //
126 // Use set_blend_type() to change the algorithm that the
127 // character uses to interpolate matrix positions.
128 ////////////////////////////////////////////////////////////////////
129 INLINE void PartBundle::
130 set_frame_blend_flag(bool frame_blend_flag) {
131  nassertv(Thread::get_current_pipeline_stage() == 0);
132  CDWriter cdata(_cycler);
133  cdata->_frame_blend_flag = frame_blend_flag;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: PartBundle::get_frame_blend_flag
138 // Access: Published
139 // Description: Returns whether the character interpolates (blends)
140 // between two sequential animation frames, or whether
141 // it holds the current frame until the next one is
142 // ready. See set_frame_blend_flag().
143 ////////////////////////////////////////////////////////////////////
144 INLINE bool PartBundle::
146  CDReader cdata(_cycler);
147  return cdata->_frame_blend_flag;
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: PartBundle::set_root_xform
152 // Access: Published
153 // Description: Specifies the transform matrix which is implicitly
154 // applied at the root of the animated hierarchy.
155 ////////////////////////////////////////////////////////////////////
156 INLINE void PartBundle::
157 set_root_xform(const LMatrix4 &root_xform) {
158  nassertv(Thread::get_current_pipeline_stage() == 0);
159  CDWriter cdata(_cycler);
160  cdata->_root_xform = root_xform;
161  cdata->_anim_changed = true;
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: PartBundle::xform
166 // Access: Published
167 // Description: Applies the indicated transform to the root of the
168 // animated hierarchy.
169 ////////////////////////////////////////////////////////////////////
170 INLINE void PartBundle::
171 xform(const LMatrix4 &mat) {
172  nassertv(Thread::get_current_pipeline_stage() == 0);
173  CDWriter cdata(_cycler);
174  cdata->_root_xform = cdata->_root_xform * mat;
175  do_xform(mat, invert(mat));
176  cdata->_anim_changed = true;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: PartBundle::get_root_xform
181 // Access: Published
182 // Description: Returns the transform matrix which is implicitly
183 // applied at the root of the animated hierarchy.
184 ////////////////////////////////////////////////////////////////////
185 INLINE const LMatrix4 &PartBundle::
186 get_root_xform() const {
187  CDReader cdata(_cycler);
188  return cdata->_root_xform;
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: PartBundle::get_num_nodes
193 // Access: Published
194 // Description: Returns the number of PartBundleNodes that contain a
195 // pointer to this PartBundle.
196 ////////////////////////////////////////////////////////////////////
197 INLINE int PartBundle::
198 get_num_nodes() const {
199  return _nodes.size();
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function: PartBundle::get_node
204 // Access: Published
205 // Description: Returns the nth PartBundleNode associated with
206 // this PartBundle.
207 ////////////////////////////////////////////////////////////////////
209 get_node(int n) const {
210  nassertr(n >= 0 && n < (int)_nodes.size(), NULL);
211  return _nodes[n];
212 }
213 
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: PartBundle::set_control_effect
217 // Access: Published
218 // Description: Sets the amount by which the character is affected by
219 // the indicated AnimControl (and its associated
220 // animation). Normally, this will only be zero or one.
221 // Zero indicates the animation does not affect the
222 // character, and one means it does.
223 //
224 // If the _anim_blend_flag is not false (see
225 // set_anim_blend_flag()), it is possible to have
226 // multiple AnimControls in effect simultaneously. In
227 // this case, the effect is a weight that indicates the
228 // relative importance of each AnimControl to the final
229 // animation.
230 ////////////////////////////////////////////////////////////////////
231 void PartBundle::
232 set_control_effect(AnimControl *control, PN_stdfloat effect) {
233  nassertv(Thread::get_current_pipeline_stage() == 0);
234 
235  CDWriter cdata(_cycler);
236  do_set_control_effect(control, effect, cdata);
237 }
238 
239 ////////////////////////////////////////////////////////////////////
240 // Function: PartBundle::get_control_effect
241 // Access: Published
242 // Description: Returns the amount by which the character is affected
243 // by the indicated AnimControl and its associated
244 // animation. See set_control_effect().
245 ////////////////////////////////////////////////////////////////////
246 INLINE PN_stdfloat PartBundle::
248  CDReader cdata(_cycler);
249  return do_get_control_effect(control, cdata);
250 }
251 
252 ////////////////////////////////////////////////////////////////////
253 // Function: PartBundle::set_update_delay
254 // Access: Public
255 // Description: Specifies the minimum amount of time, in seconds,
256 // that should elapse between any two consecutive
257 // updates. This is normally used by
258 // Character::set_lod_animation(), and should not be
259 // called directly.
260 ////////////////////////////////////////////////////////////////////
261 INLINE void PartBundle::
262 set_update_delay(double delay) {
263  _update_delay = delay;
264 }
BlendType get_blend_type() const
Returns the algorithm that is used when blending multiple frames or multiple animations together...
Definition: partBundle.I:89
bool get_anim_blend_flag() const
Returns whether the character allows multiple different animations to be bound simultaneously.
Definition: partBundle.I:102
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:232
void set_frame_blend_flag(bool frame_blend_flag)
Specifies whether the character interpolates (blends) between two sequential frames of an active anim...
Definition: partBundle.I:130
void xform(const LMatrix4 &mat)
Applies the indicated transform to the root of the animated hierarchy.
Definition: partBundle.I:171
PartBundleNode * get_node(int n) const
Returns the nth PartBundleNode associated with this PartBundle.
Definition: partBundle.I:209
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:555
void set_anim_preload(AnimPreloadTable *table)
Replaces the AnimPreloadTable associated with the PartBundle.
Definition: partBundle.I:47
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
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:247
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:58
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:262
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
int get_num_nodes() const
Returns the number of PartBundleNodes that contain a pointer to this PartBundle.
Definition: partBundle.I:198
void set_root_xform(const LMatrix4 &root_xform)
Specifies the transform matrix which is implicitly applied at the root of the animated hierarchy...
Definition: partBundle.I:157
Controls the timing of a character animation.
Definition: animControl.h:41
void set_blend_type(BlendType bt)
Defines the algorithm that is used when blending multiple frames or multiple animations together...
Definition: partBundle.I:74
const LMatrix4 & get_root_xform() const
Returns the transform matrix which is implicitly applied at the root of the animated hierarchy...
Definition: partBundle.I:186
static int get_current_pipeline_stage()
Returns the integer pipeline stage associated with the current thread.
Definition: thread.I:167
bool get_frame_blend_flag() const
Returns whether the character interpolates (blends) between two sequential animation frames...
Definition: partBundle.I:145