Panda3D

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