Panda3D
zSpinParticleFactory.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file zSpinParticleFactory.cxx
10  * @author charles
11  * @date 2000-08-16
12  */
13 
14 #include "zSpinParticleFactory.h"
15 #include "zSpinParticle.h"
16 
17 /**
18  * constructor
19  */
23  _initial_angle = 0.0f;
24  _final_angle = 0.0f;
25  _initial_angle_spread = 0.0f;
26  _final_angle_spread = 0.0f;
27  _angular_velocity = 0.0f;
28  _angular_velocity_spread = 0.0f;
29  _bUseAngularVelocity = false;
30 }
31 
32 /**
33  * copy constructor
34  */
37  BaseParticleFactory(copy) {
38  _initial_angle = copy._initial_angle;
39  _final_angle = copy._final_angle;
40  _initial_angle_spread = copy._initial_angle_spread;
41  _final_angle_spread = copy._final_angle_spread;
42  _angular_velocity = copy._angular_velocity;
43  _angular_velocity_spread = copy._angular_velocity_spread;
44  _bUseAngularVelocity = copy._bUseAngularVelocity;
45 }
46 
47 /**
48  * destructor
49  */
52 }
53 
54 /**
55  * factory method
56  */
57 BaseParticle *ZSpinParticleFactory::
58 alloc_particle() const {
59  return new ZSpinParticle;
60 }
61 
62 /**
63  * factory populator
64  */
65 void ZSpinParticleFactory::
66 populate_child_particle(BaseParticle *bp) const {
67  ZSpinParticle *zsp = (ZSpinParticle *) bp;
68 
69  zsp->set_initial_angle(_initial_angle + SPREAD(_initial_angle_spread));
70  zsp->set_final_angle(_final_angle + SPREAD(_final_angle_spread));
71  zsp->set_angular_velocity(_angular_velocity + SPREAD(_angular_velocity_spread));
72  zsp->enable_angular_velocity(_bUseAngularVelocity);
73 }
74 
75 /**
76  * Write a string representation of this instance to <out>.
77  */
79 output(std::ostream &out) const {
80  #ifndef NDEBUG //[
81  out<<"ZSpinParticleFactory";
82  #endif //] NDEBUG
83 }
84 
85 /**
86  * Write a string representation of this instance to <out>.
87  */
89 write(std::ostream &out, int indent) const {
90  #ifndef NDEBUG //[
91  out.width(indent); out<<""; out<<"ZSpinParticleFactory:\n";
92  out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n";
93  out.width(indent+2); out<<""; out<<"_initial_angle_spread "<<_initial_angle_spread<<"\n";
94  out.width(indent+2); out<<""; out<<"_final_angle "<<_final_angle<<"\n";
95  out.width(indent+2); out<<""; out<<"_final_angle_spread "<<_final_angle_spread<<"\n";
96  out.width(indent+2); out<<""; out<<"_angular_velocity "<<_angular_velocity<<"\n";
97  out.width(indent+2); out<<""; out<<"_angular_velocity_spread "<<_angular_velocity_spread<<"\n";
98  out.width(indent+2); out<<""; out<<"_bUseAngularVelocity "<<_bUseAngularVelocity<<"\n";
100  #endif //] NDEBUG
101 }
void set_initial_angle(PN_stdfloat t)
accessor
Definition: zSpinParticle.I:18
void set_final_angle(PN_stdfloat t)
accessor
Definition: zSpinParticle.I:34
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Pure Virtual base class for creating particles.
describes a particle that spins along its z axis.
Definition: zSpinParticle.h:25
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:23
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual ~ZSpinParticleFactory()
destructor