Panda3D

lineEmitter.cxx

00001 // Filename: lineEmitter.cxx
00002 // Created by:  charles (22Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "lineEmitter.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //    Function : LineEmitter
00019 //      Access : Public
00020 // Description : constructor
00021 ////////////////////////////////////////////////////////////////////
00022 LineEmitter::
00023 LineEmitter() :
00024   BaseParticleEmitter() {
00025   _endpoint1.set(1.0f, 0.0f, 0.0f);
00026   _endpoint2.set(0.0f, 0.0f, 0.0f);
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //    Function : LineEmitter
00031 //      Access : Public
00032 // Description : constructor
00033 ////////////////////////////////////////////////////////////////////
00034 LineEmitter::
00035 LineEmitter(const LineEmitter &copy) :
00036   BaseParticleEmitter(copy) {
00037   _endpoint1 = copy._endpoint1;
00038   _endpoint2 = copy._endpoint2;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //    Function : ~LineEmitter
00043 //      Access : Public
00044 // Description : constructor
00045 ////////////////////////////////////////////////////////////////////
00046 LineEmitter::
00047 ~LineEmitter() {
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //    Function : make_copy
00052 //      Access : Public
00053 // Description : copier
00054 ////////////////////////////////////////////////////////////////////
00055 BaseParticleEmitter *LineEmitter::
00056 make_copy() {
00057   return new LineEmitter(*this);
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //    Function : LineEmitter::assign_initial_position
00062 //      Access : Public
00063 // Description : Generates a location for a new particle
00064 ////////////////////////////////////////////////////////////////////
00065 void LineEmitter::
00066 assign_initial_position(LPoint3& pos) {
00067   PN_stdfloat t = NORMALIZED_RAND();
00068 
00069   LVector3 v_diff = _endpoint2 - _endpoint1;
00070 
00071   PN_stdfloat lerp_x = _endpoint1[0] + t * v_diff[0];
00072   PN_stdfloat lerp_y = _endpoint1[1] + t * v_diff[1];
00073   PN_stdfloat lerp_z = _endpoint1[2] + t * v_diff[2];
00074 
00075   pos.set(lerp_x, lerp_y, lerp_z);
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //    Function : LineEmitter::assign_initial_velocity
00080 //      Access : Public
00081 // Description : Generates a velocity for a new particle
00082 ////////////////////////////////////////////////////////////////////
00083 void LineEmitter::
00084 assign_initial_velocity(LVector3& vel) {
00085   vel.set(0,0,0);
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function : output
00090 //       Access : Public
00091 //  Description : Write a string representation of this instance to
00092 //                <out>.
00093 ////////////////////////////////////////////////////////////////////
00094 void LineEmitter::
00095 output(ostream &out) const {
00096   #ifndef NDEBUG //[
00097   out<<"LineEmitter";
00098   #endif //] NDEBUG
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function : write
00103 //       Access : Public
00104 //  Description : Write a string representation of this instance to
00105 //                <out>.
00106 ////////////////////////////////////////////////////////////////////
00107 void LineEmitter::
00108 write(ostream &out, int indent) const {
00109   #ifndef NDEBUG //[
00110   out.width(indent); out<<""; out<<"LineEmitter:\n";
00111   out.width(indent+2); out<<""; out<<"_endpoint1 "<<_endpoint1<<"\n";
00112   out.width(indent+2); out<<""; out<<"_endpoint2 "<<_endpoint2<<"\n";
00113   BaseParticleEmitter::write(out, indent+2);
00114   #endif //] NDEBUG
00115 }
 All Classes Functions Variables Enumerations