Main Page
Related Pages
Classes
Files
File List
scene
2d
particles_2d.h
1
/*************************************************************************/
2
/* particles_2d.h */
3
/*************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* http://www.godotengine.org */
7
/*************************************************************************/
8
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9
/* */
10
/* Permission is hereby granted, free of charge, to any person obtaining */
11
/* a copy of this software and associated documentation files (the */
12
/* "Software"), to deal in the Software without restriction, including */
13
/* without limitation the rights to use, copy, modify, merge, publish, */
14
/* distribute, sublicense, and/or sell copies of the Software, and to */
15
/* permit persons to whom the Software is furnished to do so, subject to */
16
/* the following conditions: */
17
/* */
18
/* The above copyright notice and this permission notice shall be */
19
/* included in all copies or substantial portions of the Software. */
20
/* */
21
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28
/*************************************************************************/
29
#ifndef PARTICLES_FRAME_H
30
#define PARTICLES_FRAME_H
31
32
#include "scene/2d/node_2d.h"
33
#include "scene/resources/texture.h"
34
#include "scene/resources/color_ramp.h"
35
36
class
Particles2D
;
37
class
ParticleAttractor2D
:
public
Node2D
{
38
39
OBJ_TYPE(
ParticleAttractor2D
,
Node2D
);
40
41
42
friend
class
Particles2D
;
43
bool
enabled;
44
float
radius;
45
float
disable_radius;
46
float
gravity;
47
float
absorption;
48
NodePath
path;
49
50
Particles2D
*owner;
51
52
void
_update_owner();
53
void
_owner_exited();
54
void
_set_owner(
Particles2D
* p_owner);
55
56
void
_notification(
int
p_what);
57
static
void
_bind_methods();
58
public
:
59
60
void
set_enabled(
bool
p_enabled);
61
bool
is_enabled()
const
;
62
63
void
set_radius(
float
p_radius);
64
float
get_radius()
const
;
65
66
void
set_disable_radius(
float
p_disable_radius);
67
float
get_disable_radius()
const
;
68
69
void
set_gravity(
float
p_gravity);
70
float
get_gravity()
const
;
71
72
void
set_absorption(
float
p_absorption);
73
float
get_absorption()
const
;
74
75
void
set_particles_path(
NodePath
p_path);
76
NodePath
get_particles_path()
const
;
77
78
ParticleAttractor2D
();
79
};
80
81
82
83
class
Particles2D
:
public
Node2D
{
84
85
OBJ_TYPE(
Particles2D
,
Node2D
);
86
public
:
87
88
enum
Parameter {
89
PARAM_DIRECTION,
90
PARAM_SPREAD,
91
PARAM_LINEAR_VELOCITY,
92
PARAM_SPIN_VELOCITY,
93
PARAM_ORBIT_VELOCITY,
94
PARAM_GRAVITY_DIRECTION,
95
PARAM_GRAVITY_STRENGTH,
96
PARAM_RADIAL_ACCEL,
97
PARAM_TANGENTIAL_ACCEL,
98
PARAM_DAMPING,
99
PARAM_INITIAL_ANGLE,
100
PARAM_INITIAL_SIZE,
101
PARAM_FINAL_SIZE,
102
PARAM_HUE_VARIATION,
103
PARAM_ANIM_SPEED_SCALE,
104
PARAM_ANIM_INITIAL_POS,
105
PARAM_MAX
106
};
107
108
enum
{
109
MAX_COLOR_PHASES=4
110
};
111
112
private
:
113
114
float
param[PARAM_MAX];
115
float
randomness[PARAM_MAX];
116
117
struct
Particle {
118
119
bool
active;
120
Point2
pos;
121
Vector2
velocity;
122
float
rot;
123
float
frame;
124
uint32_t seed;
125
Particle() { active=
false
; seed=123465789; rot=0; frame=0;}
126
};
127
128
Vector<Particle>
particles;
129
130
struct
AttractorCache {
131
132
Vector2
pos;
133
ParticleAttractor2D
*attractor;
134
};
135
136
Vector<AttractorCache>
attractor_cache;
137
138
float
explosiveness;
139
float
preprocess;
140
float
lifetime;
141
bool
emitting;
142
bool
local_space;
143
float
emit_timeout;
144
float
time_to_live;
145
float
time_scale;
146
bool
flip_h;
147
bool
flip_v;
148
int
h_frames;
149
int
v_frames;
150
Point2
emissor_offset;
151
Vector2
initial_velocity;
152
Vector2
extents;
153
DVector<Vector2>
emission_points;
154
155
float
time;
156
int
active_count;
157
158
Ref<Texture>
texture;
159
160
//If no color ramp is set then default color is used. Created as simple alternative to color_ramp.
161
Color
default_color;
162
Ref<ColorRamp>
color_ramp;
163
164
void
testee(
int
a,
int
b,
int
c,
int
d,
int
e);
165
void
_process_particles(
float
p_delta);
166
friend
class
ParticleAttractor2D
;
167
168
Set<ParticleAttractor2D*>
attractors;
169
170
protected
:
171
172
void
_notification(
int
p_what);
173
static
void
_bind_methods();
174
175
public
:
176
177
void
set_emitting(
bool
p_emitting);
178
bool
is_emitting()
const
;
179
180
void
set_amount(
int
p_amount);
181
int
get_amount()
const
;
182
183
void
set_lifetime(
float
p_lifetime);
184
float
get_lifetime()
const
;
185
186
void
set_time_scale(
float
p_time_scale);
187
float
get_time_scale()
const
;
188
189
void
set_pre_process_time(
float
p_pre_process_time);
190
float
get_pre_process_time()
const
;
191
192
void
set_emit_timeout(
float
p_timeout);
193
float
get_emit_timeout()
const
;
194
195
void
set_emission_half_extents(
const
Vector2
& p_extents);
196
Vector2
get_emission_half_extents()
const
;
197
198
void
set_param(Parameter p_param,
float
p_value);
199
float
get_param(Parameter p_param)
const
;
200
201
void
set_randomness(Parameter p_randomness,
float
p_value);
202
float
get_randomness(Parameter p_randomness)
const
;
203
204
void
set_explosiveness(
float
p_value);
205
float
get_explosiveness()
const
;
206
207
void
set_flip_h(
bool
p_flip);
208
bool
is_flipped_h()
const
;
209
210
void
set_flip_v(
bool
p_flip);
211
bool
is_flipped_v()
const
;
212
213
214
void
set_h_frames(
int
p_frames);
215
int
get_h_frames()
const
;
216
217
void
set_v_frames(
int
p_frames);
218
int
get_v_frames()
const
;
219
220
void
set_color_phases(
int
p_phases);
221
int
get_color_phases()
const
;
222
223
void
set_color_phase_color(
int
p_phase,
const
Color
& p_color);
224
Color
get_color_phase_color(
int
p_phase)
const
;
225
226
void
set_color_phase_pos(
int
p_phase,
float
p_pos);
227
float
get_color_phase_pos(
int
p_phase)
const
;
228
229
void
set_texture(
const
Ref<Texture>
& p_texture);
230
Ref<Texture>
get_texture()
const
;
231
232
void
set_color(
const
Color
& p_color);
233
Color
get_color()
const
;
234
235
void
set_color_ramp(
const
Ref<ColorRamp>
& p_texture);
236
Ref<ColorRamp>
get_color_ramp()
const
;
237
238
void
set_emissor_offset(
const
Point2
& p_offset);
239
Point2
get_emissor_offset()
const
;
240
241
void
set_use_local_space(
bool
p_use);
242
bool
is_using_local_space()
const
;
243
244
void
set_initial_velocity(
const
Vector2
& p_velocity);
245
Vector2
get_initial_velocity()
const
;
246
247
void
set_emission_points(
const
DVector<Vector2>
& p_points);
248
DVector<Vector2>
get_emission_points()
const
;
249
250
void
pre_process(
float
p_delta);
251
void
reset();
252
253
Particles2D
();
254
};
255
256
VARIANT_ENUM_CAST( Particles2D::Parameter );
257
258
#endif // PARTICLES_FRAME_H
Ref< Texture >
NodePath
Definition:
path_db.h:41
Set< ParticleAttractor2D * >
ParticleAttractor2D
Definition:
particles_2d.h:37
Color
Definition:
color.h:37
Vector2
Definition:
math_2d.h:65
Node2D
Definition:
node_2d.h:34
DVector< Vector2 >
Vector< Particle >
Particles2D
Definition:
particles_2d.h:83
Generated on Wed Jul 13 2016 13:21:00 by
1.8.11