Panda3D
sphereSurfaceEmitter.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 sphereSurfaceEmitter.cxx
10  * @author charles
11  * @date 2000-06-22
12  */
13 
14 #include "sphereSurfaceEmitter.h"
15 
16 /**
17  * constructor
18  */
21  _radius = 1.0f;
22 }
23 
24 /**
25  * copy constructor
26  */
29  BaseParticleEmitter(copy) {
30  _radius = copy._radius;
31 }
32 
33 /**
34  * destructor
35  */
38 }
39 
40 /**
41  * copier
42  */
45  return new SphereSurfaceEmitter(*this);
46 }
47 
48 /**
49  * Generates a location for a new particle
50  */
51 void SphereSurfaceEmitter::
52 assign_initial_position(LPoint3& pos) {
53  PN_stdfloat z, theta, r;
54 
55  z = SPREAD(_radius);
56  r = sqrtf((_radius * _radius) - (z * z));
57  theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
58 
59  pos.set(r * cosf(theta), r * sinf(theta), z);
60 }
61 
62 /**
63  * Generates a velocity for a new particle
64  */
65 void SphereSurfaceEmitter::
66 assign_initial_velocity(LVector3& vel) {
67  vel.set(0,0,0);
68 }
69 
70 /**
71  * Write a string representation of this instance to <out>.
72  */
74 output(std::ostream &out) const {
75  #ifndef NDEBUG //[
76  out<<"SphereSurfaceEmitter";
77  #endif //] NDEBUG
78 }
79 
80 /**
81  * Write a string representation of this instance to <out>.
82  */
84 write(std::ostream &out, int indent) const {
85  #ifndef NDEBUG //[
86  out.width(indent); out<<""; out<<"SphereSurfaceEmitter:\n";
87  out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n";
89  #endif //] NDEBUG
90 }
virtual void output(std::ostream &out) 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>.
virtual BaseParticleEmitter * make_copy()
copier
Describes a curved space in which particles are generated.
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
virtual ~SphereSurfaceEmitter()
destructor
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.