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