Panda3D
|
00001 // Filename: tangentRingEmitter.cxx 00002 // Created by: charles (25Jul00) 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 #include "tangentRingEmitter.h" 00016 00017 //////////////////////////////////////////////////////////////////// 00018 // Function : tangentRingEmitter 00019 // Access : public 00020 // Description : constructor 00021 //////////////////////////////////////////////////////////////////// 00022 TangentRingEmitter:: 00023 TangentRingEmitter() { 00024 _radius = 1.0f; 00025 _radius_spread = 0.0f; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function : tangentRingEmitter 00030 // Access : public 00031 // Description : copy constructor 00032 //////////////////////////////////////////////////////////////////// 00033 TangentRingEmitter:: 00034 TangentRingEmitter(const TangentRingEmitter ©) : 00035 BaseParticleEmitter(copy) { 00036 _radius = copy._radius; 00037 _radius_spread = copy._radius_spread; 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function : ~tangentringemitter 00042 // Access : public, virtual 00043 // Description : destructor 00044 //////////////////////////////////////////////////////////////////// 00045 TangentRingEmitter:: 00046 ~TangentRingEmitter() { 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function : make_copy 00051 // Access : public, virtual 00052 // Description : child copier 00053 //////////////////////////////////////////////////////////////////// 00054 BaseParticleEmitter *TangentRingEmitter:: 00055 make_copy() { 00056 return new TangentRingEmitter(*this); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function : TangentRingEmitter::assign_initial_position 00061 // Access : Public 00062 // Description : Generates a location for a new particle 00063 //////////////////////////////////////////////////////////////////// 00064 void TangentRingEmitter:: 00065 assign_initial_position(LPoint3& pos) { 00066 PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; 00067 00068 _x = cosf(theta); 00069 _y = sinf(theta); 00070 00071 PN_stdfloat new_radius = _radius + SPREAD(_radius_spread); 00072 pos.set(new_radius * _x, new_radius * _y, 0.0f); 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function : TangentRingEmitter::assign_initial_velocity 00077 // Access : Public 00078 // Description : Generates a velocity for a new particle 00079 //////////////////////////////////////////////////////////////////// 00080 void TangentRingEmitter:: 00081 assign_initial_velocity(LVector3& vel) { 00082 vel.set(-_y, _x, 0.0f); 00083 } 00084 00085 //////////////////////////////////////////////////////////////////// 00086 // Function : output 00087 // Access : Public 00088 // Description : Write a string representation of this instance to 00089 // <out>. 00090 //////////////////////////////////////////////////////////////////// 00091 void TangentRingEmitter:: 00092 output(ostream &out) const { 00093 #ifndef NDEBUG //[ 00094 out<<"TangentRingEmitter"; 00095 #endif //] NDEBUG 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function : write 00100 // Access : Public 00101 // Description : Write a string representation of this instance to 00102 // <out>. 00103 //////////////////////////////////////////////////////////////////// 00104 void TangentRingEmitter:: 00105 write(ostream &out, int indent) const { 00106 #ifndef NDEBUG //[ 00107 out.width(indent); out<<""; out<<"TangentRingEmitter:\n"; 00108 out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; 00109 out.width(indent+2); out<<""; out<<"_radius_spread "<<_radius_spread<<"\n"; 00110 out.width(indent+2); out<<""; out<<"_x "<<_x<<"\n"; 00111 out.width(indent+2); out<<""; out<<"_y "<<_y<<"\n"; 00112 BaseParticleEmitter::write(out, indent+2); 00113 #endif //] NDEBUG 00114 }