00001 // Filename: partBundle.I00002 // Created by: drose (22Feb99)00003 //00004 ////////////////////////////////////////////////////////////////////00005 //00006 // PANDA 3D SOFTWARE00007 // Copyright (c) Carnegie Mellon University. All rights reserved.00008 //00009 // All use of this software is subject to the terms of the revised BSD00010 // license. You should have received a copy of this license along00011 // with this source code in a file named "LICENSE."00012 //00013 ////////////////////////////////////////////////////////////////////00014
00015
00016 ////////////////////////////////////////////////////////////////////00017 // Function: PartBundle::get_anim_preload00018 // Access: Published00019 // Description: Returns the AnimPreloadTable associated with00020 // the PartBundle. This table, if present, can be used00021 // for the benefit of load_bind_anim() to allow00022 // asynchronous binding.00023 ////////////////////////////////////////////////////////////////////00024 INLINE CPT(AnimPreloadTable) PartBundle::
00025 get_anim_preload() const {
00026 return _anim_preload.get_read_pointer();
00027 }
00028
00029 ////////////////////////////////////////////////////////////////////00030 // Function: PartBundle::modify_anim_preload00031 // Access: Published00032 // Description: Returns a modifiable pointer to the AnimPreloadTable00033 // associated with the PartBundle, if any.00034 ////////////////////////////////////////////////////////////////////00035 INLINE PT(AnimPreloadTable) PartBundle::
00036 modify_anim_preload() {
00037 return _anim_preload.get_write_pointer();
00038 }
00039
00040 ////////////////////////////////////////////////////////////////////00041 // Function: PartBundle::set_anim_preload00042 // Access: Published00043 // Description: Replaces the AnimPreloadTable associated with00044 // the PartBundle.00045 ////////////////////////////////////////////////////////////////////00046 INLINE voidPartBundle::00047set_anim_preload(AnimPreloadTable *anim_preload) {
00048 _anim_preload = anim_preload;
00049 }
00050
00051 ////////////////////////////////////////////////////////////////////00052 // Function: PartBundle::clear_anim_preload00053 // Access: Published00054 // Description: Removes any AnimPreloadTable associated with00055 // the PartBundle.00056 ////////////////////////////////////////////////////////////////////00057 INLINE voidPartBundle::00058clear_anim_preload() {
00059 _anim_preload = NULL;
00060 }
00061
00062 ////////////////////////////////////////////////////////////////////00063 // Function: PartBundle::set_blend_type00064 // Access: Published00065 // Description: Defines the algorithm that is used when blending00066 // multiple frames or multiple animations together, when00067 // either anim_blend_flag or frame_blend_flag is set00068 // to true.00069 //00070 // See partBundle.h for a description of the meaning of00071 // each of the BlendType values.00072 ////////////////////////////////////////////////////////////////////00073 INLINE voidPartBundle::00074set_blend_type(PartBundle::BlendType bt) {
00075 nassertv(Thread::get_current_pipeline_stage() == 0);
00076 CDWriter cdata(_cycler);
00077 cdata->_blend_type = bt;
00078 }
00079
00080 ////////////////////////////////////////////////////////////////////00081 // Function: PartBundle::get_blend_type00082 // Access: Published00083 // Description: Returns the algorithm that is used when blending00084 // multiple frames or multiple animations together, when00085 // either anim_blend_flag or frame_blend_flag is set00086 // to true.00087 ////////////////////////////////////////////////////////////////////00088 INLINE PartBundle::BlendType PartBundle::00089get_blend_type() const {
00090 CDReader cdata(_cycler);
00091 return cdata->_blend_type;
00092 }
00093
00094 ////////////////////////////////////////////////////////////////////00095 // Function: PartBundle::get_anim_blend_flag00096 // Access: Published00097 // Description: Returns whether the character allows multiple00098 // different animations to be bound simultaneously. See00099 // set_anim_blend_flag().00100 ////////////////////////////////////////////////////////////////////00101 INLINE boolPartBundle::00102get_anim_blend_flag() const {
00103 CDReader cdata(_cycler);
00104 return cdata->_anim_blend_flag;
00105 }
00106
00107 ////////////////////////////////////////////////////////////////////00108 // Function: PartBundle::set_frame_blend_flag00109 // Access: Published00110 // Description: Specifies whether the character interpolates (blends)00111 // between two sequential frames of an active animation,00112 // showing a smooth intra-frame motion, or whether it00113 // holds each frame until the next frame is ready,00114 // showing precisely the specified animation.00115 //00116 // When this value is false, the character holds each00117 // frame until the next is ready. When this is true,00118 // the character will interpolate between two00119 // consecutive frames of animation for each frame the00120 // animation is onscreen, according to the amount of00121 // time elapsed between the frames.00122 //00123 // The default value of this flag is determined by the00124 // interpolate-frames Config.prc variable.00125 //00126 // Use set_blend_type() to change the algorithm that the00127 // character uses to interpolate matrix positions.00128 ////////////////////////////////////////////////////////////////////00129 INLINE voidPartBundle::00130set_frame_blend_flag(bool frame_blend_flag) {
00131 nassertv(Thread::get_current_pipeline_stage() == 0);
00132 CDWriter cdata(_cycler);
00133 cdata->_frame_blend_flag = frame_blend_flag;
00134 }
00135
00136 ////////////////////////////////////////////////////////////////////00137 // Function: PartBundle::get_frame_blend_flag00138 // Access: Published00139 // Description: Returns whether the character interpolates (blends)00140 // between two sequential animation frames, or whether00141 // it holds the current frame until the next one is00142 // ready. See set_frame_blend_flag().00143 ////////////////////////////////////////////////////////////////////00144 INLINE boolPartBundle::00145get_frame_blend_flag() const {
00146 CDReader cdata(_cycler);
00147 return cdata->_frame_blend_flag;
00148 }
00149
00150 ////////////////////////////////////////////////////////////////////00151 // Function: PartBundle::set_root_xform00152 // Access: Published00153 // Description: Specifies the transform matrix which is implicitly00154 // applied at the root of the animated hierarchy.00155 ////////////////////////////////////////////////////////////////////00156 INLINE voidPartBundle::00157set_root_xform(constLMatrix4 &root_xform) {
00158 nassertv(Thread::get_current_pipeline_stage() == 0);
00159 CDWriter cdata(_cycler);
00160 cdata->_root_xform = root_xform;
00161 cdata->_anim_changed = true;
00162 }
00163
00164 ////////////////////////////////////////////////////////////////////00165 // Function: PartBundle::xform00166 // Access: Published00167 // Description: Applies the indicated transform to the root of the00168 // animated hierarchy.00169 ////////////////////////////////////////////////////////////////////00170 INLINE voidPartBundle::00171xform(constLMatrix4 &mat) {
00172 nassertv(Thread::get_current_pipeline_stage() == 0);
00173 CDWriter cdata(_cycler);
00174 cdata->_root_xform = cdata->_root_xform * mat;
00175 do_xform(mat, invert(mat));
00176 cdata->_anim_changed = true;
00177 }
00178
00179 ////////////////////////////////////////////////////////////////////00180 // Function: PartBundle::get_root_xform00181 // Access: Published00182 // Description: Returns the transform matrix which is implicitly00183 // applied at the root of the animated hierarchy.00184 ////////////////////////////////////////////////////////////////////00185 INLINE constLMatrix4 &PartBundle::00186get_root_xform() const {
00187 CDReader cdata(_cycler);
00188 return cdata->_root_xform;
00189 }
00190
00191 ////////////////////////////////////////////////////////////////////00192 // Function: PartBundle::get_num_nodes00193 // Access: Published00194 // Description: Returns the number of PartBundleNodes that contain a00195 // pointer to this PartBundle.00196 ////////////////////////////////////////////////////////////////////00197 INLINE intPartBundle::00198get_num_nodes() const {
00199 return _nodes.size();
00200 }
00201
00202 ////////////////////////////////////////////////////////////////////00203 // Function: PartBundle::get_node00204 // Access: Published00205 // Description: Returns the nth PartBundleNode associated with00206 // this PartBundle.00207 ////////////////////////////////////////////////////////////////////00208 INLINE PartBundleNode *PartBundle::00209get_node(int n) const {
00210 nassertr(n >= 0 && n < (int)_nodes.size(), NULL);
00211 return _nodes[n];
00212 }
00213
00214
00215 ////////////////////////////////////////////////////////////////////00216 // Function: PartBundle::set_control_effect00217 // Access: Published00218 // Description: Sets the amount by which the character is affected by00219 // the indicated AnimControl (and its associated00220 // animation). Normally, this will only be zero or one.00221 // Zero indicates the animation does not affect the00222 // character, and one means it does.00223 //00224 // If the _anim_blend_flag is not false (see00225 // set_anim_blend_flag()), it is possible to have00226 // multiple AnimControls in effect simultaneously. In00227 // this case, the effect is a weight that indicates the00228 // relative importance of each AnimControl to the final00229 // animation.00230 ////////////////////////////////////////////////////////////////////00231 voidPartBundle::00232set_control_effect(AnimControl *control, PN_stdfloat effect) {
00233 nassertv(Thread::get_current_pipeline_stage() == 0);
00234
00235 CDWriter cdata(_cycler);
00236 do_set_control_effect(control, effect, cdata);
00237 }
00238
00239 ////////////////////////////////////////////////////////////////////00240 // Function: PartBundle::get_control_effect00241 // Access: Published00242 // Description: Returns the amount by which the character is affected00243 // by the indicated AnimControl and its associated00244 // animation. See set_control_effect().00245 ////////////////////////////////////////////////////////////////////00246 INLINE PN_stdfloat PartBundle::00247get_control_effect(AnimControl *control) const {
00248 CDReader cdata(_cycler);
00249 return do_get_control_effect(control, cdata);
00250 }
00251
00252 ////////////////////////////////////////////////////////////////////00253 // Function: PartBundle::set_update_delay00254 // Access: Public00255 // Description: Specifies the minimum amount of time, in seconds,00256 // that should elapse between any two consecutive00257 // updates. This is normally used by00258 // Character::set_lod_animation(), and should not be00259 // called directly.00260 ////////////////////////////////////////////////////////////////////00261 INLINE voidPartBundle::00262set_update_delay(double delay) {
00263 _update_delay = delay;
00264 }