00001 // Filename: lineEmitter.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 "lineEmitter.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function : LineEmitter 00023 // Access : Public 00024 // Description : constructor 00025 //////////////////////////////////////////////////////////////////// 00026 LineEmitter:: 00027 LineEmitter(void) : 00028 BaseParticleEmitter() { 00029 _endpoint1.set(1.0f, 0.0f, 0.0f); 00030 _endpoint2.set(0.0f, 0.0f, 0.0f); 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function : LineEmitter 00035 // Access : Public 00036 // Description : constructor 00037 //////////////////////////////////////////////////////////////////// 00038 LineEmitter:: 00039 LineEmitter(const LineEmitter ©) : 00040 BaseParticleEmitter(copy) { 00041 _endpoint1 = copy._endpoint1; 00042 _endpoint2 = copy._endpoint2; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function : ~LineEmitter 00047 // Access : Public 00048 // Description : constructor 00049 //////////////////////////////////////////////////////////////////// 00050 LineEmitter:: 00051 ~LineEmitter(void) { 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function : make_copy 00056 // Access : Public 00057 // Description : copier 00058 //////////////////////////////////////////////////////////////////// 00059 BaseParticleEmitter *LineEmitter:: 00060 make_copy(void) { 00061 return new LineEmitter(*this); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function : LineEmitter::assign_initial_position 00066 // Access : Public 00067 // Description : Generates a location for a new particle 00068 //////////////////////////////////////////////////////////////////// 00069 void LineEmitter:: 00070 assign_initial_position(LPoint3f& pos) { 00071 float t = NORMALIZED_RAND(); 00072 00073 LVector3f v_diff = _endpoint2 - _endpoint1; 00074 00075 float lerp_x = _endpoint1[0] + t * v_diff[0]; 00076 float lerp_y = _endpoint1[1] + t * v_diff[1]; 00077 float lerp_z = _endpoint1[2] + t * v_diff[2]; 00078 00079 pos.set(lerp_x, lerp_y, lerp_z); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function : LineEmitter::assign_initial_velocity 00084 // Access : Public 00085 // Description : Generates a velocity for a new particle 00086 //////////////////////////////////////////////////////////////////// 00087 void LineEmitter:: 00088 assign_initial_velocity(LVector3f& vel) { 00089 vel.set(0,0,0); 00090 }