15 #include "discEmitter.h" 25 _inner_aoe = _outer_aoe = 0.0f;
26 _inner_magnitude = _outer_magnitude = 1.0f;
27 _cubic_lerping =
false;
38 _radius = copy._radius;
39 _inner_aoe = copy._inner_aoe;
40 _outer_aoe = copy._outer_aoe;
41 _inner_magnitude = copy._inner_magnitude;
42 _outer_magnitude = copy._outer_magnitude;
43 _cubic_lerping = copy._cubic_lerping;
45 _distance_from_center = copy._distance_from_center;
46 _sinf_theta = copy._sinf_theta;
47 _cosf_theta = copy._cosf_theta;
75 assign_initial_position(
LPoint3& pos) {
77 PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
79 _distance_from_center = NORMALIZED_RAND();
80 PN_stdfloat r_scalar = _distance_from_center * _radius;
82 _sinf_theta = sinf(theta);
83 _cosf_theta = cosf(theta);
85 PN_stdfloat new_x = _cosf_theta * r_scalar;
86 PN_stdfloat new_y = _sinf_theta * r_scalar;
88 pos.set(new_x, new_y, 0.0f);
97 assign_initial_velocity(
LVector3& vel) {
101 if (_cubic_lerping ==
true) {
102 aoe = CLERP(_distance_from_center, _inner_aoe, _outer_aoe);
103 mag = CLERP(_distance_from_center, _inner_magnitude, _outer_magnitude);
106 aoe = LERP(_distance_from_center, _inner_aoe, _outer_aoe);
107 mag = LERP(_distance_from_center, _inner_magnitude, _outer_magnitude);
111 PN_stdfloat vel_z = mag * sinf(deg_2_rad(aoe));
112 PN_stdfloat abs_diff = fabs((mag * mag) - (vel_z * vel_z));
113 PN_stdfloat root_mag_minus_z_squared = sqrtf(abs_diff);
114 PN_stdfloat vel_x = _cosf_theta * root_mag_minus_z_squared;
115 PN_stdfloat vel_y = _sinf_theta * root_mag_minus_z_squared;
118 if((aoe > 90.0f) && (aoe < 270.0f))
124 vel.set(vel_x, vel_y, vel_z);
147 write(ostream &out,
int indent)
const {
149 out.width(indent); out<<
""; out<<
"DiscEmitter:\n";
150 out.width(indent+2); out<<
""; out<<
"_radius "<<_radius<<
"\n";
151 out.width(indent+2); out<<
""; out<<
"_outer_aoe "<<_outer_aoe<<
"\n";
152 out.width(indent+2); out<<
""; out<<
"_inner_aoe "<<_inner_aoe<<
"\n";
153 out.width(indent+2); out<<
""; out<<
"_outer_magnitude "<<_outer_magnitude<<
"\n";
154 out.width(indent+2); out<<
""; out<<
"_inner_magnitude "<<_inner_magnitude<<
"\n";
155 out.width(indent+2); out<<
""; out<<
"_cubic_lerping "<<_cubic_lerping<<
"\n";
156 out.width(indent+2); out<<
""; out<<
"_distance_from_center "<<_distance_from_center<<
"\n";
157 out.width(indent+2); out<<
""; out<<
"_sinf_theta "<<_sinf_theta<<
"\n";
158 out.width(indent+2); out<<
""; out<<
"_cosf_theta "<<_cosf_theta<<
"\n";
virtual ~DiscEmitter()
destructor
virtual BaseParticleEmitter * make_copy()
copier
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Describes a planar disc region from which particles are generated.
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Describes a physical region in space in which particles are randomly generated.