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