Panda3D
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
panda
src
particlesystem
sphereSurfaceEmitter.cxx
1
// Filename: sphereSurfaceEmitter.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 "sphereSurfaceEmitter.h"
16
17
////////////////////////////////////////////////////////////////////
18
// Function : SphereSurfaceEmitter
19
// Access : Public
20
// Description : constructor
21
////////////////////////////////////////////////////////////////////
22
SphereSurfaceEmitter::
23
SphereSurfaceEmitter
() {
24
_radius = 1.0f;
25
}
26
27
////////////////////////////////////////////////////////////////////
28
// Function : SphereSurfaceEmitter
29
// Access : Public
30
// Description : copy constructor
31
////////////////////////////////////////////////////////////////////
32
SphereSurfaceEmitter::
33
SphereSurfaceEmitter
(
const
SphereSurfaceEmitter
©) :
34
BaseParticleEmitter
(copy) {
35
_radius = copy._radius;
36
}
37
38
////////////////////////////////////////////////////////////////////
39
// Function : ~SphereSurfaceEmitter
40
// Access : Public
41
// Description : destructor
42
////////////////////////////////////////////////////////////////////
43
SphereSurfaceEmitter::
44
~SphereSurfaceEmitter
() {
45
}
46
47
////////////////////////////////////////////////////////////////////
48
// Function : make_copy
49
// Access : Public
50
// Description : copier
51
////////////////////////////////////////////////////////////////////
52
BaseParticleEmitter
*
SphereSurfaceEmitter::
53
make_copy
() {
54
return
new
SphereSurfaceEmitter
(*
this
);
55
}
56
57
////////////////////////////////////////////////////////////////////
58
// Function : SphereSurfaceEmitter::assign_initial_position
59
// Access : Public
60
// Description : Generates a location for a new particle
61
////////////////////////////////////////////////////////////////////
62
void
SphereSurfaceEmitter::
63
assign_initial_position(
LPoint3
& pos) {
64
PN_stdfloat z, theta, r;
65
66
z = SPREAD(_radius);
67
r = sqrtf((_radius * _radius) - (z * z));
68
theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f;
69
70
pos.set(r * cosf(theta), r * sinf(theta), z);
71
}
72
73
////////////////////////////////////////////////////////////////////
74
// Function : SphereSurfaceEmitter::assign_initial_velocity
75
// Access : Public
76
// Description : Generates a velocity for a new particle
77
////////////////////////////////////////////////////////////////////
78
void
SphereSurfaceEmitter::
79
assign_initial_velocity(
LVector3
& vel) {
80
vel.set(0,0,0);
81
}
82
83
////////////////////////////////////////////////////////////////////
84
// Function : output
85
// Access : Public
86
// Description : Write a string representation of this instance to
87
// <out>.
88
////////////////////////////////////////////////////////////////////
89
void
SphereSurfaceEmitter::
90
output
(ostream &out)
const
{
91
#ifndef NDEBUG //[
92
out<<
"SphereSurfaceEmitter"
;
93
#endif //] NDEBUG
94
}
95
96
////////////////////////////////////////////////////////////////////
97
// Function : write
98
// Access : Public
99
// Description : Write a string representation of this instance to
100
// <out>.
101
////////////////////////////////////////////////////////////////////
102
void
SphereSurfaceEmitter::
103
write
(ostream &out,
int
indent)
const
{
104
#ifndef NDEBUG //[
105
out.width(indent); out<<
""
; out<<
"SphereSurfaceEmitter:\n"
;
106
out.width(indent+2); out<<
""
; out<<
"_radius "
<<_radius<<
"\n"
;
107
BaseParticleEmitter::write
(out, indent+2);
108
#endif //] NDEBUG
109
}
SphereSurfaceEmitter::make_copy
virtual BaseParticleEmitter * make_copy()
copier
Definition:
sphereSurfaceEmitter.cxx:53
SphereSurfaceEmitter
Describes a curved space in which particles are generated.
Definition:
sphereSurfaceEmitter.h:25
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
SphereSurfaceEmitter::write
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
sphereSurfaceEmitter.cxx:103
SphereSurfaceEmitter::SphereSurfaceEmitter
SphereSurfaceEmitter()
constructor
Definition:
sphereSurfaceEmitter.cxx:23
BaseParticleEmitter::write
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition:
baseParticleEmitter.cxx:107
SphereSurfaceEmitter::~SphereSurfaceEmitter
virtual ~SphereSurfaceEmitter()
destructor
Definition:
sphereSurfaceEmitter.cxx:44
SphereSurfaceEmitter::output
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
Definition:
sphereSurfaceEmitter.cxx:90
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