Panda3D
baseParticleFactory.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 baseParticleFactory.cxx
10  * @author charles
11  * @date 2000-07-05
12  */
13 
14 #include "baseParticleFactory.h"
15 
16 /**
17  * constructor
18  */
19 BaseParticleFactory::
20 BaseParticleFactory() :
21  _lifespan_base(1.0),
22  _lifespan_spread(0.0),
23  _mass_base(1.0f),
24  _mass_spread(0.0f),
25  _terminal_velocity_base(PhysicsObject::_default_terminal_velocity),
26  _terminal_velocity_spread(0.0f)
27 {
28 }
29 
30 /**
31  * copy constructor
32  */
33 BaseParticleFactory::
34 BaseParticleFactory(const BaseParticleFactory &copy) :
35  _lifespan_base(copy._lifespan_base),
36  _lifespan_spread(copy._lifespan_spread),
37  _mass_base(copy._mass_base),
38  _mass_spread(copy._mass_spread),
39  _terminal_velocity_base(copy._terminal_velocity_base),
40  _terminal_velocity_spread(copy._terminal_velocity_spread)
41 {
42 }
43 
44 /**
45  * destructor
46  */
49 }
50 
51 /**
52  * public
53  */
56  bp->set_lifespan(_lifespan_base + SPREAD(_lifespan_spread));
57  bp->set_mass(_mass_base + SPREAD(_mass_spread));
58  bp->set_terminal_velocity(_terminal_velocity_base + SPREAD(_terminal_velocity_spread));
59 
60  bp->set_active(false);
61  bp->set_alive(false);
62  bp->set_age(0.0f);
63  bp->set_index(0);
64 
65  populate_child_particle(bp);
66 }
67 
68 /**
69  * Write a string representation of this instance to <out>.
70  */
72 output(std::ostream &out) const {
73  #ifndef NDEBUG //[
74  out<<"BaseParticleFactory";
75  #endif //] NDEBUG
76 }
77 
78 /**
79  * Write a string representation of this instance to <out>.
80  */
82 write(std::ostream &out, int indent) const {
83  #ifndef NDEBUG //[
84  out.width(indent); out<<""; out<<"BaseParticleFactory:\n";
85  out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n";
86  out.width(indent+2); out<<""; out<<"_lifespan_spread "<<_lifespan_spread<<"\n";
87  out.width(indent+2); out<<""; out<<"_mass_base "<<_mass_base<<"\n";
88  out.width(indent+2); out<<""; out<<"_mass_spread "<<_mass_spread<<"\n";
89  out.width(indent+2); out<<""; out<<"_terminal_velocity_base "<<_terminal_velocity_base<<"\n";
90  out.width(indent+2); out<<""; out<<"_terminal_velocity_spread "<<_terminal_velocity_spread<<"\n";
91  // ReferenceCount::write(out, indent+2);
92  #endif //] NDEBUG
93 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void populate_particle(BaseParticle *bp)
public
Pure Virtual base class for creating particles.
A body on which physics will be applied.
Definition: physicsObject.h:27
virtual ~BaseParticleFactory()
destructor
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
void set_active(bool flag)
Process Flag assignment.
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>.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:23
void set_mass(PN_stdfloat)
Set the mass in slugs (or kilograms).
Definition: physicsObject.I:18
void set_terminal_velocity(PN_stdfloat tv)
tv assignment