Panda3D

baseParticleFactory.cxx

00001 // Filename: baseParticleFactory.cxx
00002 // Created by:  charles (05Jul00)
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 "baseParticleFactory.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //    Function : BaseParticleFactory
00019 //      Access : protected
00020 // Description : constructor
00021 ////////////////////////////////////////////////////////////////////
00022 BaseParticleFactory::
00023 BaseParticleFactory() : 
00024   _lifespan_base(1.0),
00025   _lifespan_spread(0.0),
00026   _mass_base(1.0f),
00027   _mass_spread(0.0f),
00028   _terminal_velocity_base(PhysicsObject::_default_terminal_velocity),
00029   _terminal_velocity_spread(0.0f)
00030 {
00031 }
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //    Function : BaseParticleFactory
00035 //      Access : protected
00036 // Description : copy constructor
00037 ////////////////////////////////////////////////////////////////////
00038 BaseParticleFactory::
00039 BaseParticleFactory(const BaseParticleFactory &copy) : 
00040   _lifespan_base(copy._lifespan_base),
00041   _lifespan_spread(copy._lifespan_spread),
00042   _mass_base(copy._mass_base),
00043   _mass_spread(copy._mass_spread),
00044   _terminal_velocity_base(copy._terminal_velocity_base),
00045   _terminal_velocity_spread(copy._terminal_velocity_spread)
00046 {
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //    Function : ~BaseParticleFactory
00051 //      Access : public virtual
00052 // Description : destructor
00053 ////////////////////////////////////////////////////////////////////
00054 BaseParticleFactory::
00055 ~BaseParticleFactory() {
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //    Function : make_particle
00060 // Description : public
00061 ////////////////////////////////////////////////////////////////////
00062 void BaseParticleFactory::
00063 populate_particle(BaseParticle *bp) {
00064   bp->set_lifespan(_lifespan_base + SPREAD(_lifespan_spread));
00065   bp->set_mass(_mass_base + SPREAD(_mass_spread));
00066   bp->set_terminal_velocity(_terminal_velocity_base + SPREAD(_terminal_velocity_spread));
00067 
00068   bp->set_active(false);
00069   bp->set_alive(false);
00070   bp->set_age(0.0f);
00071   bp->set_index(0);
00072 
00073   populate_child_particle(bp);
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function : output
00078 //       Access : Public
00079 //  Description : Write a string representation of this instance to
00080 //                <out>.
00081 ////////////////////////////////////////////////////////////////////
00082 void BaseParticleFactory::
00083 output(ostream &out) const {
00084   #ifndef NDEBUG //[
00085   out<<"BaseParticleFactory";
00086   #endif //] NDEBUG
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function : write
00091 //       Access : Public
00092 //  Description : Write a string representation of this instance to
00093 //                <out>.
00094 ////////////////////////////////////////////////////////////////////
00095 void BaseParticleFactory::
00096 write(ostream &out, int indent) const {
00097   #ifndef NDEBUG //[
00098   out.width(indent); out<<""; out<<"BaseParticleFactory:\n";
00099   out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n";
00100   out.width(indent+2); out<<""; out<<"_lifespan_spread "<<_lifespan_spread<<"\n";
00101   out.width(indent+2); out<<""; out<<"_mass_base "<<_mass_base<<"\n";
00102   out.width(indent+2); out<<""; out<<"_mass_spread "<<_mass_spread<<"\n";
00103   out.width(indent+2); out<<""; out<<"_terminal_velocity_base "<<_terminal_velocity_base<<"\n";
00104   out.width(indent+2); out<<""; out<<"_terminal_velocity_spread "<<_terminal_velocity_spread<<"\n";
00105   //ReferenceCount::write(out, indent+2);
00106   #endif //] NDEBUG
00107 }
 All Classes Functions Variables Enumerations