00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "baseParticleEmitter.h"
00016
00017 #include <stdlib.h>
00018
00019
00020
00021
00022
00023
00024 BaseParticleEmitter::
00025 BaseParticleEmitter() {
00026 _emission_type = ET_RADIATE;
00027 _explicit_launch_vector.set(1,0,0);
00028 _radiate_origin.set(0,0,0);
00029 _amplitude = 1.0f;
00030 _amplitude_spread = 0.0f;
00031 _offset_force.set(0,0,0);
00032 }
00033
00034
00035
00036
00037
00038
00039 BaseParticleEmitter::
00040 BaseParticleEmitter(const BaseParticleEmitter ©) {
00041 _emission_type = copy._emission_type;
00042 _explicit_launch_vector = copy._explicit_launch_vector;
00043 _radiate_origin = copy._radiate_origin;
00044 _amplitude = copy._amplitude;
00045 _amplitude_spread = copy._amplitude_spread;
00046 _offset_force = copy._offset_force;
00047 }
00048
00049
00050
00051
00052
00053
00054 BaseParticleEmitter::
00055 ~BaseParticleEmitter() {
00056 }
00057
00058
00059
00060
00061
00062
00063 void BaseParticleEmitter::
00064 generate(LPoint3& pos, LVector3& vel) {
00065 assign_initial_position(pos);
00066
00067 switch(_emission_type)
00068 {
00069 case ET_EXPLICIT:
00070 vel = _explicit_launch_vector;
00071 break;
00072
00073 case ET_RADIATE:
00074 vel = pos - _radiate_origin;
00075 vel.normalize();
00076 break;
00077
00078 case ET_CUSTOM:
00079 assign_initial_velocity(vel);
00080 break;
00081 }
00082
00083 vel *= _amplitude + SPREAD(_amplitude_spread);
00084 vel += _offset_force;
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 void BaseParticleEmitter::
00094 output(ostream &out) const {
00095 #ifndef NDEBUG //[
00096 out<<"BaseParticleEmitter";
00097 #endif //] NDEBUG
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 void BaseParticleEmitter::
00107 write(ostream &out, int indent) const {
00108 #ifndef NDEBUG //[
00109 out.width(indent); out<<""; out<<"BaseParticleEmitter:\n";
00110 out.width(indent+2); out<<""; out<<"_emission_type "<<_emission_type<<"\n";
00111 out.width(indent+2); out<<""; out<<"_amplitude "<<_amplitude<<"\n";
00112 out.width(indent+2); out<<""; out<<"_amplitude_spread "<<_amplitude_spread<<"\n";
00113 out.width(indent+2); out<<""; out<<"_offset_force "<<_offset_force<<"\n";
00114
00115 #endif //] NDEBUG
00116 }