3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef PARTICLES_HEADER
21 #define PARTICLES_HEADER
23 #define DIGGING_PARTICLES_AMOUNT 10
26 #include "irrlichttypes_extrabloated.h"
27 #include "client/tile.h"
28 #include "localplayer.h"
29 #include "environment.h"
32 class ParticleManager;
33 class ClientEnvironment;
35 class Particle : public scene::ISceneNode
40 scene::ISceneManager* mgr,
42 ClientEnvironment *env,
48 bool collisiondetection,
49 bool collision_removal,
51 video::ITexture *texture,
54 u32 material_type_param,
55 u16 vertical_frame_num,
56 u16 horizontal_frame_num,
64 virtual const aabb3f &getBoundingBox() const
69 virtual u32 getMaterialCount() const
74 virtual video::SMaterial& getMaterial(u32 i)
79 virtual void OnRegisterSceneNode();
80 virtual void render();
82 void step(float dtime);
85 { return m_expiration < m_time; }
89 void updateVertices();
91 video::S3DVertex m_vertices[4];
95 ClientEnvironment *m_env;
98 aabb3f m_collisionbox;
99 video::SMaterial m_material;
105 LocalPlayer *m_player;
108 bool m_collisiondetection;
109 bool m_collision_removal;
111 v3s16 m_camera_offset;
112 u16 m_vertical_frame_num;
113 u16 m_horizontal_frame_num;
115 float m_frame_length;
116 bool m_loop_animation;
120 class ParticleSpawner
123 ParticleSpawner(IGameDef* gamedef,
124 scene::ISceneManager *smgr,
129 v3f minvel, v3f maxvel,
130 v3f minacc, v3f maxacc,
131 float minexptime, float maxexptime,
132 float minsize, float maxsize,
133 bool collisiondetection,
134 bool collision_removal,
137 video::ITexture *texture,
139 u32 material_type_param,
140 u16 vertical_frame_num,
141 u16 horizontal_frame_num,
147 ParticleManager* p_manager);
150 void step(float dtime, ClientEnvironment *env);
153 { return (m_amount <= 0) && m_spawntime != 0; }
156 ParticleManager* m_particlemanager;
159 scene::ISceneManager *m_smgr;
160 LocalPlayer *m_player;
173 video::ITexture *m_texture;
174 std::vector<float> m_spawntimes;
175 bool m_collisiondetection;
176 bool m_collision_removal;
179 u32 m_material_type_param;
180 u16 m_vertical_frame_num;
181 u16 m_horizontal_frame_num;
182 u16 m_min_first_frame;
183 u16 m_max_first_frame;
184 float m_frame_length;
185 bool m_loop_animation;
190 * Class doing particle as well as their spawners handling
192 class ParticleManager
194 friend class ParticleSpawner;
196 ParticleManager(ClientEnvironment* env);
199 void step (float dtime);
201 void handleParticleEvent(ClientEvent *event,IGameDef *gamedef,
202 scene::ISceneManager* smgr, LocalPlayer *player);
204 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
205 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
207 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
208 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
210 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
211 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
214 void addParticle(Particle* toadd);
218 void stepParticles (float dtime);
219 void stepSpawners (float dtime);
223 std::vector<Particle*> m_particles;
224 std::map<u32, ParticleSpawner*> m_particle_spawners;
226 ClientEnvironment* m_env;
227 Mutex m_particle_list_lock;
228 Mutex m_spawner_list_lock;