Panda3D

arcEmitter.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 arcEmitter.cxx
10 * @author charles
11 * @date 2000-06-22
12 */
13
14 #include "arcEmitter.h"
15
16 /**
17 * constructor
18 */
19 ArcEmitter::
20 ArcEmitter() :
21 RingEmitter(), _start_theta(0.0f), _end_theta(MathNumbers::pi_f)
22 {
23 }
24
25 /**
26 * copy constructor
27 */
28 ArcEmitter::
29 ArcEmitter(const ArcEmitter &copy) :
30 RingEmitter(copy) {
31 _start_theta = copy._start_theta;
32 _end_theta = copy._end_theta;
33 }
34
35 /**
36 * destructor
37 */
38 ArcEmitter::
39 ~ArcEmitter() {
40 }
41
42 /**
43 * copier
44 */
45 BaseParticleEmitter *ArcEmitter::
46 make_copy() {
47 return new ArcEmitter(*this);
48 }
49
50 /**
51 * Generates a location for a new particle
52 */
53 void ArcEmitter::
54 assign_initial_position(LPoint3& pos) {
55 PN_stdfloat theta;
56 if ( _start_theta < _end_theta ) {
57 theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta);
58 } else {
59 theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta + 2.0f * MathNumbers::pi_f);
60 }
61
62 theta += (MathNumbers::pi_f / 2.0);
63 this->_cos_theta = cosf(theta);
64 this->_sin_theta = sinf(theta);
65
66 PN_stdfloat new_radius_spread = SPREAD(_radius_spread);
67 PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread);
68 PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread);
69
70 pos.set(new_x, new_y, 0.0f);
71 }
72
73 /**
74 * Write a starc representation of this instance to <out>.
75 */
76 void ArcEmitter::
77 output(std::ostream &out) const {
78 #ifndef NDEBUG //[
79 out<<"ArcEmitter";
80 #endif //] NDEBUG
81 }
82
83 /**
84 * Write a starc representation of this instance to <out>.
85 */
86 void ArcEmitter::
87 write(std::ostream &out, int indent) const {
88 #ifndef NDEBUG //[
89 out.width(indent); out<<""; out<<"ArcEmitter:\n";
90 out.width(indent+2); out<<""; out<<"_start_angle "<<rad_2_deg(_start_theta)<<"\n";
91 out.width(indent+2); out<<""; out<<"_end_angle "<<rad_2_deg(_end_theta)<<"\n";
92 RingEmitter::write(out, indent+2);
93 #endif //] NDEBUG
94 }
arcEmitter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ArcEmitter
Describes a planar ring region in which particles are generated.
Definition: arcEmitter.h:22
ArcEmitter::make_copy
virtual BaseParticleEmitter * make_copy()
copier
Definition: arcEmitter.cxx:46
ArcEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a starc representation of this instance to <out>.
Definition: arcEmitter.cxx:87
ArcEmitter::ArcEmitter
ArcEmitter()
constructor
Definition: arcEmitter.cxx:20
ArcEmitter::~ArcEmitter
virtual ~ArcEmitter()
destructor
Definition: arcEmitter.cxx:39
ArcEmitter::output
virtual void output(std::ostream &out) const
Write a starc representation of this instance to <out>.
Definition: arcEmitter.cxx:77
BaseParticleEmitter
Definition: baseParticleEmitter.h:25
MathNumbers
Definition: mathNumbers.h:20
RingEmitter
Describes a planar ring region in which particles are generated.
Definition: ringEmitter.h:22
RingEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition: ringEmitter.cxx:118
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20