Panda3D
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
panda
src
particlesystem
tangentRingEmitter.cxx
1
// Filename: tangentRingEmitter.cxx
2
// Created by: charles (25Jul00)
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 "tangentRingEmitter.h"
16
17
////////////////////////////////////////////////////////////////////
18
// Function : tangentRingEmitter
19
// Access : public
20
// Description : constructor
21
////////////////////////////////////////////////////////////////////
22
TangentRingEmitter::
23
TangentRingEmitter
() {
24
_radius = 1.0f;
25
_radius_spread = 0.0f;
26
}
27
28
////////////////////////////////////////////////////////////////////
29
// Function : tangentRingEmitter
30
// Access : public
31
// Description : copy constructor
32
////////////////////////////////////////////////////////////////////
33
TangentRingEmitter::
34
TangentRingEmitter
(
const
TangentRingEmitter
©) :
35
BaseParticleEmitter
(copy) {
36
_radius = copy._radius;
37
_radius_spread = copy._radius_spread;
38
}
39
40
////////////////////////////////////////////////////////////////////
41
// Function : ~tangentringemitter
42
// Access : public, virtual
43
// Description : destructor
44
////////////////////////////////////////////////////////////////////
45
TangentRingEmitter::
46
~TangentRingEmitter
() {
47
}
48
49
////////////////////////////////////////////////////////////////////
50
// Function : make_copy
51
// Access : public, virtual
52
// Description : child copier
53
////////////////////////////////////////////////////////////////////
54
BaseParticleEmitter
*
TangentRingEmitter::
55
make_copy
() {
56
return
new
TangentRingEmitter
(*
this
);
57
}
58
59
////////////////////////////////////////////////////////////////////
60
// Function : TangentRingEmitter::assign_initial_position
61
// Access : Public
62
// Description : Generates a location for a new particle
63
////////////////////////////////////////////////////////////////////
64
void
TangentRingEmitter::
65
assign_initial_position(
LPoint3
& pos) {
66
PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
67
68
_x = cosf(theta);
69
_y = sinf(theta);
70
71
PN_stdfloat new_radius = _radius + SPREAD(_radius_spread);
72
pos.set(new_radius * _x, new_radius * _y, 0.0f);
73
}
74
75
////////////////////////////////////////////////////////////////////
76
// Function : TangentRingEmitter::assign_initial_velocity
77
// Access : Public
78
// Description : Generates a velocity for a new particle
79
////////////////////////////////////////////////////////////////////
80
void
TangentRingEmitter::
81
assign_initial_velocity(
LVector3
& vel) {
82
vel.set(-_y, _x, 0.0f);
83
}
84
85
////////////////////////////////////////////////////////////////////
86
// Function : output
87
// Access : Public
88
// Description : Write a string representation of this instance to
89
// <out>.
90
////////////////////////////////////////////////////////////////////
91
void
TangentRingEmitter::
92
output
(ostream &out)
const
{
93
#ifndef NDEBUG //[
94
out<<
"TangentRingEmitter"
;
95
#endif //] NDEBUG
96
}
97
98
////////////////////////////////////////////////////////////////////
99
// Function : write
100
// Access : Public
101
// Description : Write a string representation of this instance to
102
// <out>.
103
////////////////////////////////////////////////////////////////////
104
void
TangentRingEmitter::
105
write
(ostream &out,
int
indent)
const
{
106
#ifndef NDEBUG //[
107
out.width(indent); out<<
""
; out<<
"TangentRingEmitter:\n"
;
108
out.width(indent+2); out<<
""
; out<<
"_radius "
<<_radius<<
"\n"
;
109
out.width(indent+2); out<<
""
; out<<
"_radius_spread "
<<_radius_spread<<
"\n"
;
110
out.width(indent+2); out<<
""
; out<<
"_x "
<<_x<<
"\n"
;
111
out.width(indent+2); out<<
""
; out<<
"_y "
<<_y<<
"\n"
;
112
BaseParticleEmitter::write
(out, indent+2);
113
#endif //] NDEBUG
114
}
TangentRingEmitter::write
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
tangentRingEmitter.cxx:105
LVector3f
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition:
lvector3.h:100
TangentRingEmitter::make_copy
virtual BaseParticleEmitter * make_copy()
child copier
Definition:
tangentRingEmitter.cxx:55
LPoint3f
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition:
lpoint3.h:99
TangentRingEmitter::output
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
Definition:
tangentRingEmitter.cxx:92
TangentRingEmitter::TangentRingEmitter
TangentRingEmitter()
constructor
Definition:
tangentRingEmitter.cxx:23
TangentRingEmitter
Describes a planar ring region in which tangent particles are generated, and particles fly off tangen...
Definition:
tangentRingEmitter.h:26
BaseParticleEmitter::write
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
baseParticleEmitter.cxx:107
BaseParticleEmitter
Describes a physical region in space in which particles are randomly generated.
Definition:
baseParticleEmitter.h:31
TangentRingEmitter::~TangentRingEmitter
virtual ~TangentRingEmitter()
destructor
Definition:
tangentRingEmitter.cxx:46
Generated on Mon Feb 1 2016 13:44:31 for Panda3D by
1.8.5