Panda3D
baseParticleFactory.cxx
1 // Filename: baseParticleFactory.cxx
2 // Created by: charles (05Jul00)
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 "baseParticleFactory.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function : BaseParticleFactory
19 // Access : protected
20 // Description : constructor
21 ////////////////////////////////////////////////////////////////////
22 BaseParticleFactory::
23 BaseParticleFactory() :
24  _lifespan_base(1.0),
25  _lifespan_spread(0.0),
26  _mass_base(1.0f),
27  _mass_spread(0.0f),
28  _terminal_velocity_base(PhysicsObject::_default_terminal_velocity),
29  _terminal_velocity_spread(0.0f)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function : BaseParticleFactory
35 // Access : protected
36 // Description : copy constructor
37 ////////////////////////////////////////////////////////////////////
38 BaseParticleFactory::
39 BaseParticleFactory(const BaseParticleFactory &copy) :
40  _lifespan_base(copy._lifespan_base),
41  _lifespan_spread(copy._lifespan_spread),
42  _mass_base(copy._mass_base),
43  _mass_spread(copy._mass_spread),
44  _terminal_velocity_base(copy._terminal_velocity_base),
45  _terminal_velocity_spread(copy._terminal_velocity_spread)
46 {
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function : ~BaseParticleFactory
51 // Access : public virtual
52 // Description : destructor
53 ////////////////////////////////////////////////////////////////////
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function : make_particle
60 // Description : public
61 ////////////////////////////////////////////////////////////////////
64  bp->set_lifespan(_lifespan_base + SPREAD(_lifespan_spread));
65  bp->set_mass(_mass_base + SPREAD(_mass_spread));
66  bp->set_terminal_velocity(_terminal_velocity_base + SPREAD(_terminal_velocity_spread));
67 
68  bp->set_active(false);
69  bp->set_alive(false);
70  bp->set_age(0.0f);
71  bp->set_index(0);
72 
73  populate_child_particle(bp);
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function : output
78 // Access : Public
79 // Description : Write a string representation of this instance to
80 // <out>.
81 ////////////////////////////////////////////////////////////////////
83 output(ostream &out) const {
84  #ifndef NDEBUG //[
85  out<<"BaseParticleFactory";
86  #endif //] NDEBUG
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function : write
91 // Access : Public
92 // Description : Write a string representation of this instance to
93 // <out>.
94 ////////////////////////////////////////////////////////////////////
96 write(ostream &out, int indent) const {
97  #ifndef NDEBUG //[
98  out.width(indent); out<<""; out<<"BaseParticleFactory:\n";
99  out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n";
100  out.width(indent+2); out<<""; out<<"_lifespan_spread "<<_lifespan_spread<<"\n";
101  out.width(indent+2); out<<""; out<<"_mass_base "<<_mass_base<<"\n";
102  out.width(indent+2); out<<""; out<<"_mass_spread "<<_mass_spread<<"\n";
103  out.width(indent+2); out<<""; out<<"_terminal_velocity_base "<<_terminal_velocity_base<<"\n";
104  out.width(indent+2); out<<""; out<<"_terminal_velocity_spread "<<_terminal_velocity_spread<<"\n";
105  //ReferenceCount::write(out, indent+2);
106  #endif //] NDEBUG
107 }
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
void populate_particle(BaseParticle *bp)
public
Pure Virtual base class for creating particles.
A body on which physics will be applied.
Definition: physicsObject.h:29
virtual ~BaseParticleFactory()
destructor
void set_active(bool flag)
Process Flag assignment.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
void set_mass(PN_stdfloat)
Set the mass in slugs (or kilograms).
Definition: physicsObject.I:21
void set_terminal_velocity(PN_stdfloat tv)
tv assignment