Panda3D
|
00001 // Filename: zSpinParticleFactory.cxx 00002 // Created by: charles (16Aug00) 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 "zSpinParticleFactory.h" 00016 #include "zSpinParticle.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function : ZSpinParticleFactory 00020 // Access : public 00021 // Description : constructor 00022 //////////////////////////////////////////////////////////////////// 00023 ZSpinParticleFactory:: 00024 ZSpinParticleFactory() : 00025 BaseParticleFactory() { 00026 _initial_angle = 0.0f; 00027 _final_angle = 0.0f; 00028 _initial_angle_spread = 0.0f; 00029 _final_angle_spread = 0.0f; 00030 _angular_velocity = 0.0f; 00031 _angular_velocity_spread = 0.0f; 00032 _bUseAngularVelocity = false; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function : ZSpinParticleFactory 00037 // Access : public 00038 // Description : copy constructor 00039 //////////////////////////////////////////////////////////////////// 00040 ZSpinParticleFactory:: 00041 ZSpinParticleFactory(const ZSpinParticleFactory ©) : 00042 BaseParticleFactory(copy) { 00043 _initial_angle = copy._initial_angle; 00044 _final_angle = copy._final_angle; 00045 _initial_angle_spread = copy._initial_angle_spread; 00046 _final_angle_spread = copy._final_angle_spread; 00047 _angular_velocity = copy._angular_velocity; 00048 _angular_velocity_spread = copy._angular_velocity_spread; 00049 _bUseAngularVelocity = copy._bUseAngularVelocity; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function : ~ZSpinParticleFactory 00054 // Access : virtual, public 00055 // Description : destructor 00056 //////////////////////////////////////////////////////////////////// 00057 ZSpinParticleFactory:: 00058 ~ZSpinParticleFactory() { 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function : alloc_particle 00063 // Access : private, virtual 00064 // Description : factory method 00065 //////////////////////////////////////////////////////////////////// 00066 BaseParticle *ZSpinParticleFactory:: 00067 alloc_particle() const { 00068 return new ZSpinParticle; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function : populate_child_particle 00073 // Access : private, virtual 00074 // Description : factory populator 00075 //////////////////////////////////////////////////////////////////// 00076 void ZSpinParticleFactory:: 00077 populate_child_particle(BaseParticle *bp) const { 00078 ZSpinParticle *zsp = (ZSpinParticle *) bp; 00079 00080 zsp->set_initial_angle(_initial_angle + SPREAD(_initial_angle_spread)); 00081 zsp->set_final_angle(_final_angle + SPREAD(_final_angle_spread)); 00082 zsp->set_angular_velocity(_angular_velocity + SPREAD(_angular_velocity_spread)); 00083 zsp->enable_angular_velocity(_bUseAngularVelocity); 00084 } 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function : output 00088 // Access : Public 00089 // Description : Write a string representation of this instance to 00090 // <out>. 00091 //////////////////////////////////////////////////////////////////// 00092 void ZSpinParticleFactory:: 00093 output(ostream &out) const { 00094 #ifndef NDEBUG //[ 00095 out<<"ZSpinParticleFactory"; 00096 #endif //] NDEBUG 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function : write 00101 // Access : Public 00102 // Description : Write a string representation of this instance to 00103 // <out>. 00104 //////////////////////////////////////////////////////////////////// 00105 void ZSpinParticleFactory:: 00106 write(ostream &out, int indent) const { 00107 #ifndef NDEBUG //[ 00108 out.width(indent); out<<""; out<<"ZSpinParticleFactory:\n"; 00109 out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n"; 00110 out.width(indent+2); out<<""; out<<"_initial_angle_spread "<<_initial_angle_spread<<"\n"; 00111 out.width(indent+2); out<<""; out<<"_final_angle "<<_final_angle<<"\n"; 00112 out.width(indent+2); out<<""; out<<"_final_angle_spread "<<_final_angle_spread<<"\n"; 00113 out.width(indent+2); out<<""; out<<"_angular_velocity "<<_angular_velocity<<"\n"; 00114 out.width(indent+2); out<<""; out<<"_angular_velocity_spread "<<_angular_velocity_spread<<"\n"; 00115 out.width(indent+2); out<<""; out<<"_bUseAngularVelocity "<<_bUseAngularVelocity<<"\n"; 00116 BaseParticleFactory::write(out, indent+2); 00117 #endif //] NDEBUG 00118 }