00001 // Filename: baseParticleEmitter.cxx 00002 // Created by: charles (14Jun00) 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 "baseParticleEmitter.h" 00020 00021 #include <stdlib.h> 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function : BaseParticleEmitter 00025 // Access : Protected 00026 // Description : constructor 00027 //////////////////////////////////////////////////////////////////// 00028 BaseParticleEmitter:: 00029 BaseParticleEmitter(void) { 00030 _emission_type = ET_RADIATE; 00031 _explicit_launch_vector.set(1,0,0); 00032 _radiate_origin.set(0,0,0); 00033 _amplitude = 1.0f; 00034 _amplitude_spread = 0.0f; 00035 _offset_force.set(0,0,0); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function : BaseParticleEmitter 00040 // Access : Protected 00041 // Description : copy constructor 00042 //////////////////////////////////////////////////////////////////// 00043 BaseParticleEmitter:: 00044 BaseParticleEmitter(const BaseParticleEmitter ©) { 00045 _emission_type = copy._emission_type; 00046 _explicit_launch_vector = copy._explicit_launch_vector; 00047 _radiate_origin = copy._radiate_origin; 00048 _amplitude = copy._amplitude; 00049 _amplitude_spread = copy._amplitude_spread; 00050 _offset_force = copy._offset_force; 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function : BaseParticleEmitter 00055 // Access : Protected 00056 // Description : destructor 00057 //////////////////////////////////////////////////////////////////// 00058 BaseParticleEmitter:: 00059 ~BaseParticleEmitter(void) { 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function : generate 00064 // Access : Public 00065 // Description : parent generation function 00066 //////////////////////////////////////////////////////////////////// 00067 void BaseParticleEmitter:: 00068 generate(LPoint3f& pos, LVector3f& vel) { 00069 assign_initial_position(pos); 00070 00071 switch(_emission_type) 00072 { 00073 case ET_EXPLICIT: 00074 vel = _explicit_launch_vector; 00075 break; 00076 00077 case ET_RADIATE: 00078 vel = pos - _radiate_origin; 00079 vel.normalize(); 00080 break; 00081 00082 case ET_CUSTOM: 00083 assign_initial_velocity(vel); 00084 break; 00085 } 00086 00087 vel *= _amplitude + SPREAD(_amplitude_spread); 00088 vel += _offset_force; 00089 }