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