Panda3D
 All Classes Functions Variables Enumerations
arcEmitter.cxx
1 // Filename: arcEmitter.cxx
2 // Created by: charles (22Jun00)
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 "arcEmitter.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function : ArcEmitter
19 // Access : Public
20 // Description : constructor
21 ////////////////////////////////////////////////////////////////////
24  RingEmitter(), _start_theta(0.0f), _end_theta(MathNumbers::pi_f)
25 {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function : ArcEmitter
30 // Access : Public
31 // Description : copy constructor
32 ////////////////////////////////////////////////////////////////////
34 ArcEmitter(const ArcEmitter &copy) :
35  RingEmitter(copy) {
36  _start_theta = copy._start_theta;
37  _end_theta = copy._end_theta;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function : ~ArcEmitter
42 // Access : Public
43 // Description : destructor
44 ////////////////////////////////////////////////////////////////////
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function : make_copy
51 // Access : Public
52 // Description : copier
53 ////////////////////////////////////////////////////////////////////
56  return new ArcEmitter(*this);
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function : ArcEmitter::assign_initial_position
61 // Access : Public
62 // Description : Generates a location for a new particle
63 ////////////////////////////////////////////////////////////////////
64 void ArcEmitter::
65 assign_initial_position(LPoint3& pos) {
66  PN_stdfloat theta;
67  if ( _start_theta < _end_theta ) {
68  theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta);
69  } else {
70  theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta + 2.0f * MathNumbers::pi_f);
71  }
72 
73  theta += (MathNumbers::pi_f / 2.0);
74  this->_cos_theta = cosf(theta);
75  this->_sin_theta = sinf(theta);
76 
77  PN_stdfloat new_radius_spread = SPREAD(_radius_spread);
78  PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread);
79  PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread);
80 
81  pos.set(new_x, new_y, 0.0f);
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function : output
86 // Access : Public
87 // Description : Write a starc representation of this instance to
88 // <out>.
89 ////////////////////////////////////////////////////////////////////
90 void ArcEmitter::
91 output(ostream &out) const {
92  #ifndef NDEBUG //[
93  out<<"ArcEmitter";
94  #endif //] NDEBUG
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function : write
99 // Access : Public
100 // Description : Write a starc representation of this instance to
101 // <out>.
102 ////////////////////////////////////////////////////////////////////
103 void ArcEmitter::
104 write(ostream &out, int indent) const {
105  #ifndef NDEBUG //[
106  out.width(indent); out<<""; out<<"ArcEmitter:\n";
107  out.width(indent+2); out<<""; out<<"_start_angle "<<rad_2_deg(_start_theta)<<"\n";
108  out.width(indent+2); out<<""; out<<"_end_angle "<<rad_2_deg(_end_theta)<<"\n";
109  RingEmitter::write(out, indent+2);
110  #endif //] NDEBUG
111 }
Describes a planar ring region in which particles are generated.
Definition: arcEmitter.h:25
virtual void write(ostream &out, int indent=0) const
Write a starc representation of this instance to &lt;out&gt;.
Definition: arcEmitter.cxx:104
ArcEmitter()
constructor
Definition: arcEmitter.cxx:23
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
virtual BaseParticleEmitter * make_copy()
copier
Definition: arcEmitter.cxx:55
Describes a planar ring region in which particles are generated.
Definition: ringEmitter.h:25
virtual void output(ostream &out) const
Write a starc representation of this instance to &lt;out&gt;.
Definition: arcEmitter.cxx:91
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to &lt;out&gt;.
virtual ~ArcEmitter()
destructor
Definition: arcEmitter.cxx:46
Describes a physical region in space in which particles are randomly generated.