00001 // Filename: rectangleEmitter.cxx 00002 // Created by: charles (22Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "rectangleEmitter.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function : RectangleEmitter 00023 // Access : Public 00024 // Description : constructor 00025 //////////////////////////////////////////////////////////////////// 00026 RectangleEmitter:: 00027 RectangleEmitter(void) : 00028 BaseParticleEmitter() { 00029 _vmin.set(-0.5f, -0.5f); 00030 _vmax.set( 0.5f, 0.5f); 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function : RectangleEmitter 00035 // Access : Public 00036 // Description : copy constructor 00037 //////////////////////////////////////////////////////////////////// 00038 RectangleEmitter:: 00039 RectangleEmitter(const RectangleEmitter ©) : 00040 BaseParticleEmitter(copy) { 00041 _vmin = copy._vmin; 00042 _vmax = copy._vmax; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function : RectangleEmitter 00047 // Access : Public 00048 // Description : destructor 00049 //////////////////////////////////////////////////////////////////// 00050 RectangleEmitter:: 00051 ~RectangleEmitter(void) { 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function : make_copy 00056 // Access : Public 00057 // Description : copier 00058 //////////////////////////////////////////////////////////////////// 00059 BaseParticleEmitter *RectangleEmitter:: 00060 make_copy(void) { 00061 return new RectangleEmitter(*this); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function : RectangleEmitter::assign_initial_position 00066 // Access : Public 00067 // Description : Generates a location for a new particle 00068 //////////////////////////////////////////////////////////////////// 00069 void RectangleEmitter:: 00070 assign_initial_position(LPoint3f& pos) { 00071 float t_x = NORMALIZED_RAND(); 00072 float t_y = NORMALIZED_RAND(); 00073 00074 LVector2f v_diff = _vmax - _vmin; 00075 00076 float lerp_x = _vmin[0] + t_x * v_diff[0]; 00077 float lerp_y = _vmin[1] + t_y * v_diff[1]; 00078 00079 pos.set(lerp_x, lerp_y, 0.0f); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function : RectangleEmitter::assign_initial_velocity 00084 // Access : Public 00085 // Description : Generates a velocity for a new particle 00086 //////////////////////////////////////////////////////////////////// 00087 void RectangleEmitter:: 00088 assign_initial_velocity(LVector3f& vel) { 00089 vel.set(0.0f,0.0f,0.0f); 00090 }