Panda3D

baseParticleRenderer.I

00001 // Filename: baseParticleRenderer.I
00002 // Created by:  charles (20Jun00)
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 //    Function : BaseParticleRender::get_render_node
00017 //       Class : Published
00018 // Description : Query the geomnode pointer
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE GeomNode *BaseParticleRenderer::
00021 get_render_node() const {
00022   return _render_node;
00023 }
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //    Function : BaseParticleRender::get_render_node_path
00027 //       Class : Published
00028 // Description : Query the geomnode pointer
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE NodePath BaseParticleRenderer::
00031 get_render_node_path() const {
00032   return _render_node_path;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //    Function : BaseParticleRender::set_alpha_mode
00037 //      Access : Published
00038 ////////////////////////////////////////////////////////////////////
00039 INLINE void BaseParticleRenderer::
00040 set_alpha_mode(BaseParticleRenderer::ParticleRendererAlphaMode am) {
00041   update_alpha_mode(am);
00042   init_geoms();
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //    Function : BaseParticleRender::get_alpha_mode
00047 //      Access : Published
00048 ////////////////////////////////////////////////////////////////////
00049 INLINE BaseParticleRenderer::ParticleRendererAlphaMode BaseParticleRenderer::
00050 get_alpha_mode() const {
00051   return _alpha_mode;
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //    Function : BaseParticleRender::set_user_alpha
00056 //      Access : Published
00057 // Description : sets alpha for "user" alpha mode
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE void BaseParticleRenderer::
00060 set_user_alpha(PN_stdfloat ua) {
00061   _user_alpha = ua;
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //    Function : BaseParticleRender::get_user_alpha
00066 //      Access : Published
00067 // Description : gets alpha for "user" alpha mode
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE PN_stdfloat BaseParticleRenderer::
00070 get_user_alpha() const {
00071   return _user_alpha;
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //    Function : BaseParticleRender::set_color_blend_mode
00076 //      Access : Published
00077 // Description : sets the ColorBlendAttrib on the _render_node
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE void BaseParticleRenderer::
00080 set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa, ColorBlendAttrib::Operand ob) {
00081   CPT(RenderAttrib) ra;
00082   if(bm == ColorBlendAttrib::M_add || bm == ColorBlendAttrib::M_subtract || bm == ColorBlendAttrib::M_inv_subtract) {
00083     ra = ColorBlendAttrib::make(bm,oa,ob);
00084   } else {
00085     ra = ColorBlendAttrib::make(bm);
00086   }
00087 
00088   _render_node->set_attrib(ra);
00089   return;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //    Function : BaseParticleRender::get_ignore_scale
00094 //      Access : Published
00095 // Description : Returns the "ignore scale" flag.  See
00096 //               set_ignore_scale().
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE bool BaseParticleRenderer::
00099 get_ignore_scale() const {
00100   return _ignore_scale;
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //    Function : BaseParticleRender::get_cur_alpha
00105 //      Access : Published
00106 // Description : gets current alpha for a particle
00107 ////////////////////////////////////////////////////////////////////
00108 INLINE PN_stdfloat BaseParticleRenderer::
00109 get_cur_alpha(BaseParticle* bp) {
00110   switch(_alpha_mode) {
00111   case PR_ALPHA_OUT:
00112     return 1.0f - bp->get_parameterized_age();
00113 
00114   case PR_ALPHA_IN:
00115     return bp->get_parameterized_age();
00116 
00117   case PR_ALPHA_IN_OUT:
00118     return 2.0 * min(bp->get_parameterized_age(),
00119                      1.0f - bp->get_parameterized_age());
00120 
00121   case PR_ALPHA_USER:
00122     return _user_alpha;
00123 
00124   default:
00125     return 1.0; // should not get here
00126   }
00127 }
 All Classes Functions Variables Enumerations