Panda3D
 All Classes Functions Variables Enumerations
sphereSurfaceEmitter.cxx
00001 // Filename: sphereSurfaceEmitter.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 "sphereSurfaceEmitter.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //    Function : SphereSurfaceEmitter
00019 //      Access : Public
00020 // Description : constructor
00021 ////////////////////////////////////////////////////////////////////
00022 SphereSurfaceEmitter::
00023 SphereSurfaceEmitter() {
00024   _radius = 1.0f;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //    Function : SphereSurfaceEmitter
00029 //      Access : Public
00030 // Description : copy constructor
00031 ////////////////////////////////////////////////////////////////////
00032 SphereSurfaceEmitter::
00033 SphereSurfaceEmitter(const SphereSurfaceEmitter &copy) :
00034   BaseParticleEmitter(copy) {
00035   _radius = copy._radius;
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //    Function : ~SphereSurfaceEmitter
00040 //      Access : Public
00041 // Description : destructor
00042 ////////////////////////////////////////////////////////////////////
00043 SphereSurfaceEmitter::
00044 ~SphereSurfaceEmitter() {
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //    Function : make_copy
00049 //      Access : Public
00050 // Description : copier
00051 ////////////////////////////////////////////////////////////////////
00052 BaseParticleEmitter *SphereSurfaceEmitter::
00053 make_copy() {
00054   return new SphereSurfaceEmitter(*this);
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //    Function : SphereSurfaceEmitter::assign_initial_position
00059 //      Access : Public
00060 // Description : Generates a location for a new particle
00061 ////////////////////////////////////////////////////////////////////
00062 void SphereSurfaceEmitter::
00063 assign_initial_position(LPoint3& pos) {
00064   PN_stdfloat z, theta, r;
00065 
00066   z = SPREAD(_radius);
00067   r = sqrtf((_radius * _radius) - (z * z));
00068   theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
00069 
00070   pos.set(r * cosf(theta), r * sinf(theta), z);
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //    Function : SphereSurfaceEmitter::assign_initial_velocity
00075 //      Access : Public
00076 // Description : Generates a velocity for a new particle
00077 ////////////////////////////////////////////////////////////////////
00078 void SphereSurfaceEmitter::
00079 assign_initial_velocity(LVector3& vel) {
00080   vel.set(0,0,0);
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function : output
00085 //       Access : Public
00086 //  Description : Write a string representation of this instance to
00087 //                <out>.
00088 ////////////////////////////////////////////////////////////////////
00089 void SphereSurfaceEmitter::
00090 output(ostream &out) const {
00091   #ifndef NDEBUG //[
00092   out<<"SphereSurfaceEmitter";
00093   #endif //] NDEBUG
00094 }
00095 
00096 ////////////////////////////////////////////////////////////////////
00097 //     Function : write
00098 //       Access : Public
00099 //  Description : Write a string representation of this instance to
00100 //                <out>.
00101 ////////////////////////////////////////////////////////////////////
00102 void SphereSurfaceEmitter::
00103 write(ostream &out, int indent) const {
00104   #ifndef NDEBUG //[
00105   out.width(indent); out<<""; out<<"SphereSurfaceEmitter:\n";
00106   out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
00107   BaseParticleEmitter::write(out, indent+2);
00108   #endif //] NDEBUG
00109 }
 All Classes Functions Variables Enumerations