00001 // Filename: spriteParticleRenderer.I 00002 // Created by: charles (13Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function : SpriteParticleRenderer::get_source_type 00021 // Access : public 00022 // Description : Returns an indication of whether the texture for this 00023 // renderer was set via a call to set_texture(), or via 00024 // set_from_node(). 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE SpriteParticleRenderer::SourceType SpriteParticleRenderer:: 00027 get_source_type() const { 00028 return _source_type; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function : SpriteParticleRenderer::set_texture 00033 // Access : public 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE void SpriteParticleRenderer:: 00036 set_texture(Texture *tex) { 00037 _sprite_primitive->set_texture(tex); 00038 _sprite_primitive->set_ll_uv(TexCoordf(0.0f, 0.0f)); 00039 _sprite_primitive->set_ur_uv(TexCoordf(1.0f, 1.0f)); 00040 _source_type = ST_texture; 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function : SpriteParticleRenderer::set_ll_uv 00045 // Access : public 00046 // Description : Sets the UV coordinate of the lower-left corner of 00047 // all the sprites generated by this renderer. Normally 00048 // this is (0, 0), but it might be set to something else 00049 // to use only a portion of the texture. 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE void SpriteParticleRenderer:: 00052 set_ll_uv(const TexCoordf &ll_uv) { 00053 _sprite_primitive->set_ll_uv(ll_uv); 00054 } 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Function : SpriteParticleRenderer::set_ur_uv 00058 // Access : public 00059 // Description : Sets the UV coordinate of the upper-right corner of 00060 // all the sprites generated by this renderer. Normally 00061 // this is (1, 1), but it might be set to something else 00062 // to use only a portion of the texture. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE void SpriteParticleRenderer:: 00065 set_ur_uv(const TexCoordf &ur_uv) { 00066 _sprite_primitive->set_ur_uv(ur_uv); 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function : SpriteParticleRenderer::set_color 00071 // Access : public 00072 //////////////////////////////////////////////////////////////////// 00073 INLINE void SpriteParticleRenderer:: 00074 set_color(const Colorf &color) { 00075 _color = color; 00076 } 00077 00078 //////////////////////////////////////////////////////////////////// 00079 // Function : SpriteParticleRenderer::set_x_scale_flag 00080 // Access : public 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void SpriteParticleRenderer:: 00083 set_x_scale_flag(bool animate_x_ratio) { 00084 if (animate_x_ratio == true && _animate_x_ratio == false) { 00085 _x_texel_array = PTA_float::empty_array(_pool_size); 00086 _sprite_primitive->set_x_texel_ratio(_x_texel_array, G_PER_PRIM); 00087 } 00088 else if (animate_x_ratio == false && _animate_x_ratio == true) { 00089 _x_texel_array = PTA_float::empty_array(1); 00090 _sprite_primitive->set_x_texel_ratio(_x_texel_array, G_OVERALL); 00091 } 00092 00093 _animate_x_ratio = animate_x_ratio; 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function : SpriteParticleRenderer::set_y_scale_flag 00098 // Access : public 00099 //////////////////////////////////////////////////////////////////// 00100 INLINE void SpriteParticleRenderer:: 00101 set_y_scale_flag(bool animate_y_ratio) { 00102 if (animate_y_ratio == true && _animate_y_ratio == false) { 00103 _y_texel_array = PTA_float::empty_array(_pool_size); 00104 _sprite_primitive->set_y_texel_ratio(_y_texel_array, G_PER_PRIM); 00105 } 00106 else if (animate_y_ratio == false && _animate_y_ratio == true) { 00107 _y_texel_array = PTA_float::empty_array(1); 00108 _sprite_primitive->set_y_texel_ratio(_y_texel_array, G_OVERALL); 00109 } 00110 00111 _animate_y_ratio = animate_y_ratio; 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function : SpriteParticleRenderer::set_anim_angle_flag 00116 // Access : public 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE void SpriteParticleRenderer:: 00119 set_anim_angle_flag(bool animate_theta) { 00120 if (animate_theta == true && _animate_theta == false) { 00121 _theta_array = PTA_float::empty_array(_pool_size); 00122 _sprite_primitive->set_thetas(_theta_array, G_PER_PRIM); 00123 } 00124 else if (animate_theta == false && _animate_theta == true) { 00125 _theta_array = PTA_float::empty_array(_pool_size); 00126 _sprite_primitive->set_thetas(_theta_array, G_OVERALL); 00127 } 00128 00129 _animate_theta = animate_theta; 00130 } 00131 00132 //////////////////////////////////////////////////////////////////// 00133 // Function : SpriteParticleRenderer::set_initial_x_scale 00134 // Access : public 00135 //////////////////////////////////////////////////////////////////// 00136 INLINE void SpriteParticleRenderer:: 00137 set_initial_x_scale(float initial_x_scale) { 00138 _initial_x_texel_ratio = initial_x_scale; 00139 } 00140 00141 //////////////////////////////////////////////////////////////////// 00142 // Function : SpriteParticleRenderer::set_final_x_scale 00143 // Access : public 00144 //////////////////////////////////////////////////////////////////// 00145 INLINE void SpriteParticleRenderer:: 00146 set_final_x_scale(float final_x_scale) { 00147 _final_x_texel_ratio = final_x_scale; 00148 } 00149 00150 //////////////////////////////////////////////////////////////////// 00151 // Function : SpriteParticleRenderer::set_initial_y_scale 00152 // Access : public 00153 //////////////////////////////////////////////////////////////////// 00154 INLINE void SpriteParticleRenderer:: 00155 set_initial_y_scale(float initial_y_scale) { 00156 _initial_y_texel_ratio = initial_y_scale; 00157 } 00158 00159 //////////////////////////////////////////////////////////////////// 00160 // Function : SpriteParticleRenderer::set_final_y_scale 00161 // Access : public 00162 //////////////////////////////////////////////////////////////////// 00163 INLINE void SpriteParticleRenderer:: 00164 set_final_y_scale(float final_y_scale) { 00165 _final_y_texel_ratio = final_y_scale; 00166 } 00167 00168 //////////////////////////////////////////////////////////////////// 00169 // Function : SpriteParticleRenderer::set_nonanimated_theta 00170 // Access : public 00171 //////////////////////////////////////////////////////////////////// 00172 INLINE void SpriteParticleRenderer:: 00173 set_nonanimated_theta(float theta) { 00174 _theta = theta; 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function : SpriteParticleRenderer::set_alpha_blend_method 00179 // Access : public 00180 //////////////////////////////////////////////////////////////////// 00181 INLINE void SpriteParticleRenderer:: 00182 set_alpha_blend_method(ParticleRendererBlendMethod bm) { 00183 _blend_method = bm; 00184 } 00185 00186 //////////////////////////////////////////////////////////////////// 00187 // Function : SpriteParticleRenderer::set_alpha_disable 00188 // Access : public 00189 //////////////////////////////////////////////////////////////////// 00190 INLINE void SpriteParticleRenderer:: 00191 set_alpha_disable(bool ad) { 00192 _sprite_primitive->set_alpha_disable(ad); 00193 } 00194 00195 //////////////////////////////////////////////////////////////////// 00196 // Function : SpriteParticleRenderer::get_texture 00197 // Access : public 00198 //////////////////////////////////////////////////////////////////// 00199 INLINE Texture *SpriteParticleRenderer:: 00200 get_texture(void) const { 00201 return _sprite_primitive->get_texture(); 00202 } 00203 00204 //////////////////////////////////////////////////////////////////// 00205 // Function : SpriteParticleRenderer::get_ll_uv 00206 // Access : public 00207 // Description : Returns the UV coordinate of the lower-left corner; 00208 // see set_ll_uv(). 00209 //////////////////////////////////////////////////////////////////// 00210 INLINE const TexCoordf &SpriteParticleRenderer:: 00211 get_ll_uv() const { 00212 return _sprite_primitive->get_ll_uv(); 00213 } 00214 00215 //////////////////////////////////////////////////////////////////// 00216 // Function : SpriteParticleRenderer::get_ur_uv 00217 // Access : public 00218 // Description : Returns the UV coordinate of the upper-right corner; 00219 // see set_ur_uv(). 00220 //////////////////////////////////////////////////////////////////// 00221 INLINE const TexCoordf &SpriteParticleRenderer:: 00222 get_ur_uv() const { 00223 return _sprite_primitive->get_ur_uv(); 00224 } 00225 00226 //////////////////////////////////////////////////////////////////// 00227 // Function : SpriteParticleRenderer::get_color 00228 // Access : public 00229 //////////////////////////////////////////////////////////////////// 00230 INLINE Colorf SpriteParticleRenderer:: 00231 get_color(void) const { 00232 return _color; 00233 } 00234 00235 //////////////////////////////////////////////////////////////////// 00236 // Function : SpriteParticleRenderer::get_x_scale_flag 00237 // Access : public 00238 //////////////////////////////////////////////////////////////////// 00239 INLINE bool SpriteParticleRenderer:: 00240 get_x_scale_flag(void) const { 00241 return _animate_x_ratio; 00242 } 00243 00244 //////////////////////////////////////////////////////////////////// 00245 // Function : SpriteParticleRenderer::get_y_scale_flag 00246 // Access : public 00247 //////////////////////////////////////////////////////////////////// 00248 INLINE bool SpriteParticleRenderer:: 00249 get_y_scale_flag(void) const { 00250 return _animate_y_ratio; 00251 } 00252 00253 //////////////////////////////////////////////////////////////////// 00254 // Function : SpriteParticleRenderer::get_anim_angle_flag 00255 // Access : public 00256 //////////////////////////////////////////////////////////////////// 00257 INLINE bool SpriteParticleRenderer:: 00258 get_anim_angle_flag(void) const { 00259 return _animate_theta; 00260 } 00261 00262 //////////////////////////////////////////////////////////////////// 00263 // Function : SpriteParticleRenderer::get_initial_x_scale 00264 // Access : public 00265 //////////////////////////////////////////////////////////////////// 00266 INLINE float SpriteParticleRenderer:: 00267 get_initial_x_scale(void) const { 00268 return _initial_x_texel_ratio; 00269 } 00270 00271 //////////////////////////////////////////////////////////////////// 00272 // Function : SpriteParticleRenderer::get_final_x_scale 00273 // Access : public 00274 //////////////////////////////////////////////////////////////////// 00275 INLINE float SpriteParticleRenderer:: 00276 get_final_x_scale(void) const { 00277 return _final_x_texel_ratio; 00278 } 00279 00280 //////////////////////////////////////////////////////////////////// 00281 // Function : SpriteParticleRenderer::get_initial_y_scale 00282 // Access : public 00283 //////////////////////////////////////////////////////////////////// 00284 INLINE float SpriteParticleRenderer:: 00285 get_initial_y_scale(void) const { 00286 return _initial_y_texel_ratio; 00287 } 00288 00289 //////////////////////////////////////////////////////////////////// 00290 // Function : SpriteParticleRenderer::get_final_y_scale 00291 // Access : public 00292 //////////////////////////////////////////////////////////////////// 00293 INLINE float SpriteParticleRenderer:: 00294 get_final_y_scale(void) const { 00295 return _final_y_texel_ratio; 00296 } 00297 00298 //////////////////////////////////////////////////////////////////// 00299 // Function : SpriteParticleRenderer::get_nonanimated_theta 00300 // Access : public 00301 //////////////////////////////////////////////////////////////////// 00302 INLINE float SpriteParticleRenderer:: 00303 get_nonanimated_theta(void) const { 00304 return _theta; 00305 } 00306 00307 //////////////////////////////////////////////////////////////////// 00308 // Function : SpriteParticleRenderer::get_alpha_blend_method 00309 // Access : public 00310 //////////////////////////////////////////////////////////////////// 00311 INLINE BaseParticleRenderer::ParticleRendererBlendMethod SpriteParticleRenderer:: 00312 get_alpha_blend_method(void) const { 00313 return _blend_method; 00314 } 00315 00316 //////////////////////////////////////////////////////////////////// 00317 // Function : SpriteParticleRenderer::get_alpha_disable 00318 // Access : public 00319 //////////////////////////////////////////////////////////////////// 00320 INLINE bool SpriteParticleRenderer:: 00321 get_alpha_disable(void) const { 00322 return _sprite_primitive->get_alpha_disable(); 00323 }