00001 // Filename: baseParticleRenderer.cxx 00002 // Created by: charles (20Jun00) 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 #include "pandabase.h" 00020 00021 #include "baseParticleRenderer.h" 00022 #include "transparencyAttrib.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function : BaseParticleRenderer 00026 // Access : Public 00027 // Description : Default Constructor 00028 //////////////////////////////////////////////////////////////////// 00029 BaseParticleRenderer:: 00030 BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) : 00031 _alpha_mode(PR_NOT_INITIALIZED_YET) { 00032 _render_node = new GeomNode("BaseParticleRenderer render node"); 00033 00034 _user_alpha = 1.0f; 00035 00036 update_alpha_mode(alpha_mode); 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function : BaseParticleRenderer 00041 // Access : Public 00042 // Description : Copy Constructor 00043 //////////////////////////////////////////////////////////////////// 00044 BaseParticleRenderer:: 00045 BaseParticleRenderer(const BaseParticleRenderer& copy) : 00046 _alpha_mode(PR_ALPHA_NONE) { 00047 _render_node = new GeomNode("BaseParticleRenderer render node"); 00048 00049 _user_alpha = copy._user_alpha; 00050 00051 update_alpha_mode(copy._alpha_mode); 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function : ~BaseParticleRenderer 00056 // Access : Public 00057 // Description : Destructor 00058 //////////////////////////////////////////////////////////////////// 00059 BaseParticleRenderer:: 00060 ~BaseParticleRenderer(void) { 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function : enable_alpha 00065 // Access : Private 00066 // Description : Builds an intermediate node and transition that 00067 // enables alpha channeling. 00068 //////////////////////////////////////////////////////////////////// 00069 void BaseParticleRenderer:: 00070 enable_alpha(void) { 00071 _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function : disable_alpha 00076 // Access : Private 00077 // Description : kills the intermediate alpha node/arc 00078 //////////////////////////////////////////////////////////////////// 00079 void BaseParticleRenderer:: 00080 disable_alpha(void) { 00081 _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none)); 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function : update_alpha_state 00086 // Access : Private 00087 // Description : handles the base class part of alpha updating. 00088 //////////////////////////////////////////////////////////////////// 00089 void BaseParticleRenderer:: 00090 update_alpha_mode(ParticleRendererAlphaMode am) { 00091 if (_alpha_mode == am) 00092 return; 00093 00094 if ((am == PR_ALPHA_NONE) && (_alpha_mode != PR_ALPHA_NONE)) 00095 disable_alpha(); 00096 else if ((am != PR_ALPHA_NONE) && (_alpha_mode == PR_ALPHA_NONE)) 00097 enable_alpha(); 00098 00099 _alpha_mode = am; 00100 }