Panda3D
Loading...
Searching...
No Matches
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 */
20ArcEmitter() :
21 RingEmitter(), _start_theta(0.0f), _end_theta(MathNumbers::pi_f)
22{
23}
24
25/**
26 * copy constructor
27 */
29ArcEmitter(const ArcEmitter &copy) :
30 RingEmitter(copy) {
31 _start_theta = copy._start_theta;
32 _end_theta = copy._end_theta;
33}
34
35/**
36 * destructor
37 */
41
42/**
43 * copier
44 */
46make_copy() {
47 return new ArcEmitter(*this);
48}
49
50/**
51 * Generates a location for a new particle
52 */
53void ArcEmitter::
54assign_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 */
77output(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 */
87write(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";
93 #endif //] NDEBUG
94}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Describes a planar ring region in which particles are generated.
Definition arcEmitter.h:22
virtual BaseParticleEmitter * make_copy()
copier
virtual void write(std::ostream &out, int indent=0) const
Write a starc representation of this instance to <out>.
ArcEmitter()
constructor
virtual ~ArcEmitter()
destructor
virtual void output(std::ostream &out) const
Write a starc representation of this instance to <out>.
Describes a planar ring region in which particles are generated.
Definition ringEmitter.h:22
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