Panda3D
tangentRingEmitter.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 tangentRingEmitter.cxx
10  * @author charles
11  * @date 2000-07-25
12  */
13 
14 #include "tangentRingEmitter.h"
15 
16 /**
17  * constructor
18  */
21  _radius = 1.0f;
22  _radius_spread = 0.0f;
23 }
24 
25 /**
26  * copy constructor
27  */
30  BaseParticleEmitter(copy) {
31  _radius = copy._radius;
32  _radius_spread = copy._radius_spread;
33 }
34 
35 /**
36  * destructor
37  */
40 }
41 
42 /**
43  * child copier
44  */
47  return new TangentRingEmitter(*this);
48 }
49 
50 /**
51  * Generates a location for a new particle
52  */
53 void TangentRingEmitter::
54 assign_initial_position(LPoint3& pos) {
55  PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
56 
57  _x = cosf(theta);
58  _y = sinf(theta);
59 
60  PN_stdfloat new_radius = _radius + SPREAD(_radius_spread);
61  pos.set(new_radius * _x, new_radius * _y, 0.0f);
62 }
63 
64 /**
65  * Generates a velocity for a new particle
66  */
67 void TangentRingEmitter::
68 assign_initial_velocity(LVector3& vel) {
69  vel.set(-_y, _x, 0.0f);
70 }
71 
72 /**
73  * Write a string representation of this instance to <out>.
74  */
76 output(std::ostream &out) const {
77  #ifndef NDEBUG //[
78  out<<"TangentRingEmitter";
79  #endif //] NDEBUG
80 }
81 
82 /**
83  * Write a string representation of this instance to <out>.
84  */
86 write(std::ostream &out, int indent) const {
87  #ifndef NDEBUG //[
88  out.width(indent); out<<""; out<<"TangentRingEmitter:\n";
89  out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
90  out.width(indent+2); out<<""; out<<"_radius_spread "<<_radius_spread<<"\n";
91  out.width(indent+2); out<<""; out<<"_x "<<_x<<"\n";
92  out.width(indent+2); out<<""; out<<"_y "<<_y<<"\n";
94  #endif //] NDEBUG
95 }
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual BaseParticleEmitter * make_copy()
child copier
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.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
TangentRingEmitter()
constructor
Describes a planar ring region in which tangent particles are generated, and particles fly off tangen...
virtual ~TangentRingEmitter()
destructor