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