Panda3D

Loading...
Searching...
No Matches
lineEmitter.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 lineEmitter.cxx
10 * @author charles
11 * @date 2000-06-22
12 */
13
14#include "lineEmitter.h"
15
16/**
17 * constructor
18 */
19 LineEmitter::
20 LineEmitter() :
21 BaseParticleEmitter() {
22 _endpoint1.set(1.0f, 0.0f, 0.0f);
23 _endpoint2.set(0.0f, 0.0f, 0.0f);
24}
25
26/**
27 * constructor
28 */
29 LineEmitter::
30 LineEmitter(const LineEmitter &copy) :
31 BaseParticleEmitter(copy) {
32 _endpoint1 = copy._endpoint1;
33 _endpoint2 = copy._endpoint2;
34}
35
36/**
37 * constructor
38 */
39 LineEmitter::
40~LineEmitter() {
41}
42
43/**
44 * copier
45 */
46BaseParticleEmitter *LineEmitter::
47 make_copy() {
48 return new LineEmitter(*this);
49}
50
51/**
52 * Generates a location for a new particle
53 */
54 void LineEmitter::
55assign_initial_position(LPoint3& pos) {
56 PN_stdfloat t = NORMALIZED_RAND();
57
58 LVector3 v_diff = _endpoint2 - _endpoint1;
59
60 PN_stdfloat lerp_x = _endpoint1[0] + t * v_diff[0];
61 PN_stdfloat lerp_y = _endpoint1[1] + t * v_diff[1];
62 PN_stdfloat lerp_z = _endpoint1[2] + t * v_diff[2];
63
64 pos.set(lerp_x, lerp_y, lerp_z);
65}
66
67/**
68 * Generates a velocity for a new particle
69 */
70 void LineEmitter::
71assign_initial_velocity(LVector3& vel) {
72 vel.set(0,0,0);
73}
74
75/**
76 * Write a string representation of this instance to <out>.
77 */
78 void LineEmitter::
79 output(std::ostream &out) const {
80 #ifndef NDEBUG //[
81 out<<"LineEmitter";
82 #endif //] NDEBUG
83}
84
85/**
86 * Write a string representation of this instance to <out>.
87 */
88 void LineEmitter::
89 write(std::ostream &out, int indent) const {
90 #ifndef NDEBUG //[
91 out.width(indent); out<<""; out<<"LineEmitter:\n";
92 out.width(indent+2); out<<""; out<<"_endpoint1 "<<_endpoint1<<"\n";
93 out.width(indent+2); out<<""; out<<"_endpoint2 "<<_endpoint2<<"\n";
94 BaseParticleEmitter::write(out, indent+2);
95 #endif //] NDEBUG
96}
BaseParticleEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition baseParticleEmitter.cxx:92
LineEmitter::LineEmitter
LineEmitter()
constructor
Definition lineEmitter.cxx:20
LineEmitter::output
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition lineEmitter.cxx:79
LineEmitter::~LineEmitter
virtual ~LineEmitter()
constructor
Definition lineEmitter.cxx:40
LineEmitter::make_copy
virtual BaseParticleEmitter * make_copy()
copier
Definition lineEmitter.cxx:47
LineEmitter::write
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition lineEmitter.cxx:89
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
lineEmitter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.