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