Panda3D
panda
src
particlesystem
rectangleEmitter.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 rectangleEmitter.cxx
10
* @author charles
11
* @date 2000-06-22
12
*/
13
14
#include "
rectangleEmitter.h
"
15
16
/**
17
* constructor
18
*/
19
RectangleEmitter::
20
RectangleEmitter
() :
21
BaseParticleEmitter
() {
22
_vmin.set(-0.5f, -0.5f);
23
_vmax.set( 0.5f, 0.5f);
24
}
25
26
/**
27
* copy constructor
28
*/
29
RectangleEmitter::
30
RectangleEmitter
(
const
RectangleEmitter
©) :
31
BaseParticleEmitter
(copy) {
32
_vmin = copy._vmin;
33
_vmax = copy._vmax;
34
}
35
36
/**
37
* destructor
38
*/
39
RectangleEmitter::
40
~RectangleEmitter
() {
41
}
42
43
/**
44
* copier
45
*/
46
BaseParticleEmitter
*
RectangleEmitter::
47
make_copy
() {
48
return
new
RectangleEmitter
(*
this
);
49
}
50
51
/**
52
* Generates a location for a new particle
53
*/
54
void
RectangleEmitter::
55
assign_initial_position(LPoint3& pos) {
56
PN_stdfloat t_x = NORMALIZED_RAND();
57
PN_stdfloat t_y = NORMALIZED_RAND();
58
59
LVector2 v_diff = _vmax - _vmin;
60
61
PN_stdfloat lerp_x = _vmin[0] + t_x * v_diff[0];
62
PN_stdfloat lerp_y = _vmin[1] + t_y * v_diff[1];
63
64
pos.set(lerp_x, lerp_y, 0.0f);
65
}
66
67
/**
68
* Generates a velocity for a new particle
69
*/
70
void
RectangleEmitter::
71
assign_initial_velocity(LVector3& vel) {
72
vel.set(0.0f,0.0f,0.0f);
73
}
74
75
/**
76
* Write a string representation of this instance to <out>.
77
*/
78
void
RectangleEmitter::
79
output
(std::ostream &out)
const
{
80
#ifndef NDEBUG //[
81
out<<
"RectangleEmitter"
;
82
#endif //] NDEBUG
83
}
84
85
/**
86
* Write a string representation of this instance to <out>.
87
*/
88
void
RectangleEmitter::
89
write
(std::ostream &out,
int
indent
)
const
{
90
#ifndef NDEBUG //[
91
out.width(
indent
); out<<
""
; out<<
"RectangleEmitter:\n"
;
92
out.width(
indent
+2); out<<
""
; out<<
"_vmin "
<<_vmin<<
"\n"
;
93
out.width(
indent
+2); out<<
""
; out<<
"_vmax "
<<_vmax<<
"\n"
;
94
BaseParticleEmitter::write
(out,
indent
+2);
95
#endif //] NDEBUG
96
}
RectangleEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
rectangleEmitter.cxx:89
RectangleEmitter::make_copy
virtual BaseParticleEmitter * make_copy()
copier
Definition:
rectangleEmitter.cxx:47
BaseParticleEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
baseParticleEmitter.cxx:92
RectangleEmitter::output
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition:
rectangleEmitter.cxx:79
RectangleEmitter::~RectangleEmitter
virtual ~RectangleEmitter()
destructor
Definition:
rectangleEmitter.cxx:40
RectangleEmitter::RectangleEmitter
RectangleEmitter()
constructor
Definition:
rectangleEmitter.cxx:20
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition:
indent.cxx:20
RectangleEmitter
Describes a planar square region in which particles are generated.
Definition:
rectangleEmitter.h:22
rectangleEmitter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BaseParticleEmitter
Definition:
baseParticleEmitter.h:25
Generated on Wed Jan 23 2019 21:40:08 for Panda3D by
1.8.15