00001 // Filename: tangentRingEmitter.cxx 00002 // Created by: charles (25Jul00) 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 "tangentRingEmitter.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function : tangentRingEmitter 00023 // Access : public 00024 // Description : constructor 00025 //////////////////////////////////////////////////////////////////// 00026 TangentRingEmitter:: 00027 TangentRingEmitter(void) { 00028 _radius = 1.0f; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function : tangentRingEmitter 00033 // Access : public 00034 // Description : copy constructor 00035 //////////////////////////////////////////////////////////////////// 00036 TangentRingEmitter:: 00037 TangentRingEmitter(const TangentRingEmitter ©) : 00038 BaseParticleEmitter(copy) { 00039 _radius = copy._radius; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function : ~tangentringemitter 00044 // Access : public, virtual 00045 // Description : destructor 00046 //////////////////////////////////////////////////////////////////// 00047 TangentRingEmitter:: 00048 ~TangentRingEmitter(void) { 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function : make_copy 00053 // Access : public, virtual 00054 // Description : child copier 00055 //////////////////////////////////////////////////////////////////// 00056 BaseParticleEmitter *TangentRingEmitter:: 00057 make_copy(void) { 00058 return new TangentRingEmitter(*this); 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function : TangentRingEmitter::assign_initial_position 00063 // Access : Public 00064 // Description : Generates a location for a new particle 00065 //////////////////////////////////////////////////////////////////// 00066 void TangentRingEmitter:: 00067 assign_initial_position(LPoint3f& pos) { 00068 float theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; 00069 00070 _x = cosf(theta); 00071 _y = sinf(theta); 00072 00073 pos.set(_radius * _x, _radius * _y, 0.0f); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function : TangentRingEmitter::assign_initial_velocity 00078 // Access : Public 00079 // Description : Generates a velocity for a new particle 00080 //////////////////////////////////////////////////////////////////// 00081 void TangentRingEmitter:: 00082 assign_initial_velocity(LVector3f& vel) { 00083 vel.set(-_y, _x, 0.0f); 00084 }