Panda3D
 All Classes Functions Variables Enumerations
zSpinParticleFactory.cxx
1 // Filename: zSpinParticleFactory.cxx
2 // Created by: charles (16Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "zSpinParticleFactory.h"
16 #include "zSpinParticle.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function : ZSpinParticleFactory
20 // Access : public
21 // Description : constructor
22 ////////////////////////////////////////////////////////////////////
26  _initial_angle = 0.0f;
27  _final_angle = 0.0f;
28  _initial_angle_spread = 0.0f;
29  _final_angle_spread = 0.0f;
30  _angular_velocity = 0.0f;
31  _angular_velocity_spread = 0.0f;
32  _bUseAngularVelocity = false;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function : ZSpinParticleFactory
37 // Access : public
38 // Description : copy constructor
39 ////////////////////////////////////////////////////////////////////
42  BaseParticleFactory(copy) {
43  _initial_angle = copy._initial_angle;
44  _final_angle = copy._final_angle;
45  _initial_angle_spread = copy._initial_angle_spread;
46  _final_angle_spread = copy._final_angle_spread;
47  _angular_velocity = copy._angular_velocity;
48  _angular_velocity_spread = copy._angular_velocity_spread;
49  _bUseAngularVelocity = copy._bUseAngularVelocity;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function : ~ZSpinParticleFactory
54 // Access : virtual, public
55 // Description : destructor
56 ////////////////////////////////////////////////////////////////////
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function : alloc_particle
63 // Access : private, virtual
64 // Description : factory method
65 ////////////////////////////////////////////////////////////////////
66 BaseParticle *ZSpinParticleFactory::
67 alloc_particle() const {
68  return new ZSpinParticle;
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function : populate_child_particle
73 // Access : private, virtual
74 // Description : factory populator
75 ////////////////////////////////////////////////////////////////////
76 void ZSpinParticleFactory::
77 populate_child_particle(BaseParticle *bp) const {
78  ZSpinParticle *zsp = (ZSpinParticle *) bp;
79 
80  zsp->set_initial_angle(_initial_angle + SPREAD(_initial_angle_spread));
81  zsp->set_final_angle(_final_angle + SPREAD(_final_angle_spread));
82  zsp->set_angular_velocity(_angular_velocity + SPREAD(_angular_velocity_spread));
83  zsp->enable_angular_velocity(_bUseAngularVelocity);
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function : output
88 // Access : Public
89 // Description : Write a string representation of this instance to
90 // <out>.
91 ////////////////////////////////////////////////////////////////////
93 output(ostream &out) const {
94  #ifndef NDEBUG //[
95  out<<"ZSpinParticleFactory";
96  #endif //] NDEBUG
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function : write
101 // Access : Public
102 // Description : Write a string representation of this instance to
103 // <out>.
104 ////////////////////////////////////////////////////////////////////
106 write(ostream &out, int indent) const {
107  #ifndef NDEBUG //[
108  out.width(indent); out<<""; out<<"ZSpinParticleFactory:\n";
109  out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n";
110  out.width(indent+2); out<<""; out<<"_initial_angle_spread "<<_initial_angle_spread<<"\n";
111  out.width(indent+2); out<<""; out<<"_final_angle "<<_final_angle<<"\n";
112  out.width(indent+2); out<<""; out<<"_final_angle_spread "<<_final_angle_spread<<"\n";
113  out.width(indent+2); out<<""; out<<"_angular_velocity "<<_angular_velocity<<"\n";
114  out.width(indent+2); out<<""; out<<"_angular_velocity_spread "<<_angular_velocity_spread<<"\n";
115  out.width(indent+2); out<<""; out<<"_bUseAngularVelocity "<<_bUseAngularVelocity<<"\n";
116  BaseParticleFactory::write(out, indent+2);
117  #endif //] NDEBUG
118 }
void set_initial_angle(PN_stdfloat t)
accessor
Definition: zSpinParticle.I:20
void set_final_angle(PN_stdfloat t)
accessor
Definition: zSpinParticle.I:38
Pure Virtual base class for creating particles.
virtual void output(ostream &out) const
Write a string representation of this instance to &lt;out&gt;.
describes a particle that spins along its z axis.
Definition: zSpinParticle.h:28
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to &lt;out&gt;.
ZSpinParticleFactory()
constructor
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
virtual ~ZSpinParticleFactory()
destructor
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to &lt;out&gt;.