00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "ringEmitter.h"
00016
00017
00018
00019
00020
00021
00022 RingEmitter::
00023 RingEmitter() :
00024 _radius(1.0f), _radius_spread(0.0f), _aoe(0.0f), _uniform_emission(0), _theta(0.0f)
00025 {
00026 }
00027
00028
00029
00030
00031
00032
00033 RingEmitter::
00034 RingEmitter(const RingEmitter ©) :
00035 BaseParticleEmitter(copy) {
00036 _radius = copy._radius;
00037 _aoe = copy._aoe;
00038 _radius_spread = copy._radius_spread;
00039 _uniform_emission = copy._uniform_emission;
00040
00041 _theta = copy._theta;
00042 _sin_theta = copy._sin_theta;
00043 _cos_theta = copy._cos_theta;
00044 }
00045
00046
00047
00048
00049
00050
00051 RingEmitter::
00052 ~RingEmitter() {
00053 }
00054
00055
00056
00057
00058
00059
00060 BaseParticleEmitter *RingEmitter::
00061 make_copy() {
00062 return new RingEmitter(*this);
00063 }
00064
00065
00066
00067
00068
00069
00070 void RingEmitter::
00071 assign_initial_position(LPoint3& pos) {
00072 if (_uniform_emission > 0)
00073 {
00074 _theta = _theta + 1.0/_uniform_emission;
00075 if (_theta > 1.0)
00076 _theta = _theta - 1.0;
00077 }
00078 else
00079 {
00080 _theta = NORMALIZED_RAND();
00081 }
00082
00083 _cos_theta = cosf(_theta * 2.0f * MathNumbers::pi_f);
00084 _sin_theta = sinf(_theta * 2.0f * MathNumbers::pi_f);
00085
00086 PN_stdfloat new_radius_spread = SPREAD(_radius_spread);
00087 PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread);
00088 PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread);
00089
00090 pos.set(new_x, new_y, 0.0f);
00091 }
00092
00093
00094
00095
00096
00097
00098 void RingEmitter::
00099 assign_initial_velocity(LVector3& vel) {
00100 PN_stdfloat vel_z = sinf(deg_2_rad(_aoe));
00101 PN_stdfloat abs_diff = fabs(1.0f - (vel_z * vel_z));
00102 PN_stdfloat root_mag_minus_z_squared = sqrtf(abs_diff);
00103
00104 PN_stdfloat vel_x = _cos_theta * root_mag_minus_z_squared;
00105 PN_stdfloat vel_y = _sin_theta * root_mag_minus_z_squared;
00106
00107
00108 if((_aoe > 90.0f) && (_aoe < 270.0f))
00109 {
00110 vel_x = -vel_x;
00111 vel_y = -vel_y;
00112 }
00113
00114 vel.set(vel_x, vel_y, vel_z);
00115 }
00116
00117
00118
00119
00120
00121
00122
00123 void RingEmitter::
00124 output(ostream &out) const {
00125 #ifndef NDEBUG //[
00126 out<<"RingEmitter";
00127 #endif //] NDEBUG
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 void RingEmitter::
00137 write(ostream &out, int indent) const {
00138 #ifndef NDEBUG //[
00139 out.width(indent); out<<""; out<<"RingEmitter:\n";
00140 out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
00141 out.width(indent+2); out<<""; out<<"_radius_spread "<<_radius_spread<<"\n";
00142 out.width(indent+2); out<<""; out<<"_aoe "<<_aoe<<"\n";
00143 out.width(indent+2); out<<""; out<<"_sin_theta "<<_sin_theta<<"\n";
00144 out.width(indent+2); out<<""; out<<"_cos_theta "<<_cos_theta<<"\n";
00145 BaseParticleEmitter::write(out, indent+2);
00146 #endif //] NDEBUG
00147 }