00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "discEmitter.h"
00020
00021
00022
00023
00024
00025
00026 DiscEmitter::
00027 DiscEmitter(void) {
00028 _radius = 1.0f;
00029 _inner_aoe = _outer_aoe = 0.0f;
00030 _inner_magnitude = _outer_magnitude = 1.0f;
00031 _cubic_lerping = false;
00032 }
00033
00034
00035
00036
00037
00038
00039 DiscEmitter::
00040 DiscEmitter(const DiscEmitter ©) :
00041 BaseParticleEmitter(copy) {
00042 _radius = copy._radius;
00043 _inner_aoe = copy._inner_aoe;
00044 _outer_aoe = copy._outer_aoe;
00045 _inner_magnitude = copy._inner_magnitude;
00046 _outer_magnitude = copy._outer_magnitude;
00047 _cubic_lerping = copy._cubic_lerping;
00048
00049 _distance_from_center = copy._distance_from_center;
00050 _sinf_theta = copy._sinf_theta;
00051 _cosf_theta = copy._cosf_theta;
00052 }
00053
00054
00055
00056
00057
00058
00059 DiscEmitter::
00060 ~DiscEmitter(void) {
00061 }
00062
00063
00064
00065
00066
00067
00068 BaseParticleEmitter *DiscEmitter::
00069 make_copy(void) {
00070 return new DiscEmitter(*this);
00071 }
00072
00073
00074
00075
00076
00077
00078 void DiscEmitter::
00079 assign_initial_position(LPoint3f& pos) {
00080
00081 float theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
00082
00083 _distance_from_center = NORMALIZED_RAND();
00084 float r_scalar = _distance_from_center * _radius;
00085
00086 _sinf_theta = sinf(theta);
00087 _cosf_theta = cosf(theta);
00088
00089 float new_x = _cosf_theta * r_scalar;
00090 float new_y = _sinf_theta * r_scalar;
00091
00092 pos.set(new_x, new_y, 0.0f);
00093 }
00094
00095
00096
00097
00098
00099
00100 void DiscEmitter::
00101 assign_initial_velocity(LVector3f& vel) {
00102 float aoe, mag;
00103
00104
00105 if (_cubic_lerping == true) {
00106 aoe = CLERP(_distance_from_center, _inner_aoe, _outer_aoe);
00107 mag = CLERP(_distance_from_center, _inner_magnitude, _outer_magnitude);
00108 }
00109 else {
00110 aoe = LERP(_distance_from_center, _inner_aoe, _outer_aoe);
00111 mag = LERP(_distance_from_center, _inner_magnitude, _outer_magnitude);
00112 }
00113
00114
00115 float vel_z = mag * sinf(deg_2_rad(aoe));
00116 float abs_diff = fabs((mag * mag) - (vel_z * vel_z));
00117 float root_mag_minus_z_squared = sqrtf(abs_diff);
00118 float vel_x = _cosf_theta * root_mag_minus_z_squared;
00119 float vel_y = _sinf_theta * root_mag_minus_z_squared;
00120
00121
00122 if((aoe > 90.0f) && (aoe < 270.0f))
00123 {
00124 vel_x = -vel_x;
00125 vel_y = -vel_y;
00126 }
00127
00128 vel.set(vel_x, vel_y, vel_z);
00129 }