Panda3D

partBundle.I

00001 // Filename: partBundle.I
00002 // Created by:  drose (22Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PartBundle::get_anim_preload
00018 //       Access: Published
00019 //  Description: Returns the AnimPreloadTable associated with
00020 //               the PartBundle.  This table, if present, can be used
00021 //               for the benefit of load_bind_anim() to allow
00022 //               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_preload
00031 //       Access: Published
00032 //  Description: Returns a modifiable pointer to the AnimPreloadTable
00033 //               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_preload
00042 //       Access: Published
00043 //  Description: Replaces the AnimPreloadTable associated with
00044 //               the PartBundle.
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE void PartBundle::
00047 set_anim_preload(AnimPreloadTable *anim_preload) {
00048   _anim_preload = anim_preload;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: PartBundle::clear_anim_preload
00053 //       Access: Published
00054 //  Description: Removes any AnimPreloadTable associated with
00055 //               the PartBundle.
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE void PartBundle::
00058 clear_anim_preload() {
00059   _anim_preload = NULL;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: PartBundle::set_blend_type
00064 //       Access: Published
00065 //  Description: Defines the algorithm that is used when blending
00066 //               multiple frames or multiple animations together, when
00067 //               either anim_blend_flag or frame_blend_flag is set
00068 //               to true.
00069 //
00070 //               See partBundle.h for a description of the meaning of
00071 //               each of the BlendType values.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE void PartBundle::
00074 set_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_type
00082 //       Access: Published
00083 //  Description: Returns the algorithm that is used when blending
00084 //               multiple frames or multiple animations together, when
00085 //               either anim_blend_flag or frame_blend_flag is set
00086 //               to true.
00087 ////////////////////////////////////////////////////////////////////
00088 INLINE PartBundle::BlendType PartBundle::
00089 get_blend_type() const {
00090   CDReader cdata(_cycler);
00091   return cdata->_blend_type;
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: PartBundle::get_anim_blend_flag
00096 //       Access: Published
00097 //  Description: Returns whether the character allows multiple
00098 //               different animations to be bound simultaneously.  See
00099 //               set_anim_blend_flag().
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE bool PartBundle::
00102 get_anim_blend_flag() const {
00103   CDReader cdata(_cycler);
00104   return cdata->_anim_blend_flag;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: PartBundle::set_frame_blend_flag
00109 //       Access: Published
00110 //  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 it
00113 //               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 each
00117 //               frame until the next is ready.  When this is true,
00118 //               the character will interpolate between two
00119 //               consecutive frames of animation for each frame the
00120 //               animation is onscreen, according to the amount of
00121 //               time elapsed between the frames.
00122 //
00123 //               The default value of this flag is determined by the
00124 //               interpolate-frames Config.prc variable.
00125 //
00126 //               Use set_blend_type() to change the algorithm that the
00127 //               character uses to interpolate matrix positions.
00128 ////////////////////////////////////////////////////////////////////
00129 INLINE void PartBundle::
00130 set_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_flag
00138 //       Access: Published
00139 //  Description: Returns whether the character interpolates (blends)
00140 //               between two sequential animation frames, or whether
00141 //               it holds the current frame until the next one is
00142 //               ready.  See set_frame_blend_flag().
00143 ////////////////////////////////////////////////////////////////////
00144 INLINE bool PartBundle::
00145 get_frame_blend_flag() const {
00146   CDReader cdata(_cycler);
00147   return cdata->_frame_blend_flag;
00148 }
00149 
00150 ////////////////////////////////////////////////////////////////////
00151 //     Function: PartBundle::set_root_xform
00152 //       Access: Published
00153 //  Description: Specifies the transform matrix which is implicitly
00154 //               applied at the root of the animated hierarchy.
00155 ////////////////////////////////////////////////////////////////////
00156 INLINE void PartBundle::
00157 set_root_xform(const LMatrix4 &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::xform
00166 //       Access: Published
00167 //  Description: Applies the indicated transform to the root of the
00168 //               animated hierarchy.
00169 ////////////////////////////////////////////////////////////////////
00170 INLINE void PartBundle::
00171 xform(const LMatrix4 &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_xform
00181 //       Access: Published
00182 //  Description: Returns the transform matrix which is implicitly
00183 //               applied at the root of the animated hierarchy.
00184 ////////////////////////////////////////////////////////////////////
00185 INLINE const LMatrix4 &PartBundle::
00186 get_root_xform() const {
00187   CDReader cdata(_cycler);
00188   return cdata->_root_xform;
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: PartBundle::get_num_nodes
00193 //       Access: Published
00194 //  Description: Returns the number of PartBundleNodes that contain a
00195 //               pointer to this PartBundle.
00196 ////////////////////////////////////////////////////////////////////
00197 INLINE int PartBundle::
00198 get_num_nodes() const {
00199   return _nodes.size();
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: PartBundle::get_node
00204 //       Access: Published
00205 //  Description: Returns the nth PartBundleNode associated with
00206 //               this PartBundle.
00207 ////////////////////////////////////////////////////////////////////
00208 INLINE PartBundleNode *PartBundle::
00209 get_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_effect
00217 //       Access: Published
00218 //  Description: Sets the amount by which the character is affected by
00219 //               the indicated AnimControl (and its associated
00220 //               animation).  Normally, this will only be zero or one.
00221 //               Zero indicates the animation does not affect the
00222 //               character, and one means it does.
00223 //
00224 //               If the _anim_blend_flag is not false (see
00225 //               set_anim_blend_flag()), it is possible to have
00226 //               multiple AnimControls in effect simultaneously.  In
00227 //               this case, the effect is a weight that indicates the
00228 //               relative importance of each AnimControl to the final
00229 //               animation.
00230 ////////////////////////////////////////////////////////////////////
00231 void PartBundle::
00232 set_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_effect
00241 //       Access: Published
00242 //  Description: Returns the amount by which the character is affected
00243 //               by the indicated AnimControl and its associated
00244 //               animation.  See set_control_effect().
00245 ////////////////////////////////////////////////////////////////////
00246 INLINE PN_stdfloat PartBundle::
00247 get_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_delay
00254 //       Access: Public
00255 //  Description: Specifies the minimum amount of time, in seconds,
00256 //               that should elapse between any two consecutive
00257 //               updates.  This is normally used by
00258 //               Character::set_lod_animation(), and should not be
00259 //               called directly.
00260 ////////////////////////////////////////////////////////////////////
00261 INLINE void PartBundle::
00262 set_update_delay(double delay) {
00263   _update_delay = delay;
00264 }
 All Classes Functions Variables Enumerations