Particle.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be 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 CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_DPARTICLE_INCLUDED
34 #define H_DPARTICLE_INCLUDED
35 
36 #include <string>
37 #include <stack>
38 #include <Dynacoe/Modules/Assets.h>
39 #include <Dynacoe/Components/Shape2D.h>
40 
41 class EParticle;
42 
43 /* Basic structures representing particle data. */
44 /* Johnathan Corkery, 2014 */
45 namespace Dynacoe {
46 
56 
57 
58 
61 class Particle : public Asset {
62  public:
63 
64  Particle(const std::string & n);
65  std::string Image_name;
66 
67 
68 
69  float duration_max;
70  int alpha_max;
71  float xScale_max;
72  float yScale_max;
73  float multiScale_max;
74  float rotation_max;
75  float direction_max;
76  float speed_max;
77 
78  int red_max;
79  int blue_max;
80  int green_max;
81 
82  float duration_min;
83  int alpha_min;
84  float xScale_min;
85  float yScale_min;
86  float multiScale_min;
87  float rotation_min;
88  float direction_min;
89  float speed_min;
90 
91  int red_min;
92  int blue_min;
93  int green_min;
94 
95  int alpha_delta_min;
96  float xScale_delta_min;
97  float yScale_delta_min;
98  float multiScale_delta_min;
99  float rotation_delta_min;
100  float direction_delta_min;
101  float speed_delta_min;
102 
103  int red_delta_min;
104  int blue_delta_min;
105  int green_delta_min;
106 
107  int alpha_delta_max;
108  float xScale_delta_max;
109  float yScale_delta_max;
110  float multiScale_delta_max;
111  float rotation_delta_max;
112  float direction_delta_max;
113  float speed_delta_max;
114 
115  int red_delta_max;
116  int blue_delta_max;
117  int green_delta_max;
118 };
119 
120 
128 class ParticleEmitter2D : public Entity {
129  public:
131 
135  void EnableFiltering(bool doIt);
136 
140  void EnableTranslucency(bool doIt);
141 
151  void EmitParticle(AssetID p, int n = 1);
152 
153 
154 
155 
156 
157  void OnDraw();
158  private:
159  Shape2D shape;
160  void drawParticle(EParticle *);
161  EParticle * instantiateParticle(const Particle *);
162 
163 
164  bool filter;
165  bool translucent;
166 
167  std::vector<Entity::ID> particleActiveList;
168 
169  uint32_t numParticles;
170 };
171 
172 
174 
175 
176 }
177 
178 #endif
Basic interactive object.
Definition: Entity.h:62
A structure that holds the specification of a particle.
Definition: Particle.h:61
Definition: AssetID.h:37
Emits particles.
Definition: Particle.h:128
void EmitParticle(AssetID p, int n=1)
Instantiates a particle in 2D space based on a stored design.
void OnDraw()
Called when Draw() is called.
Assets are referred to by an AssetID. The AssetID uniquely refers to an Asset stored within memory...
Definition: AssetID.h:42
void EnableFiltering(bool doIt)
Enable texture filtering for each particle emitted. It is enabled by default.
void EnableTranslucency(bool doIt)
Enable translucency for each each particle drawn. It is enabled by default.
An aspect that can express basic 2D objects, such as images and shapes.
Definition: Shape2D.h:46