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,
57 virtual const aabb3f &getBoundingBox() const
62 virtual u32 getMaterialCount() const
67 virtual video::SMaterial& getMaterial(u32 i)
72 virtual void OnRegisterSceneNode();
73 virtual void render();
75 void step(float dtime);
78 { return m_expiration < m_time; }
82 void updateVertices();
84 video::S3DVertex m_vertices[4];
88 ClientEnvironment *m_env;
91 aabb3f m_collisionbox;
92 video::SMaterial m_material;
98 LocalPlayer *m_player;
101 bool m_collisiondetection;
102 bool m_collision_removal;
104 v3s16 m_camera_offset;
107 class ParticleSpawner
110 ParticleSpawner(IGameDef* gamedef,
111 scene::ISceneManager *smgr,
116 v3f minvel, v3f maxvel,
117 v3f minacc, v3f maxacc,
118 float minexptime, float maxexptime,
119 float minsize, float maxsize,
120 bool collisiondetection,
121 bool collision_removal,
124 video::ITexture *texture,
126 ParticleManager* p_manager);
130 void step(float dtime, ClientEnvironment *env);
133 { return (m_amount <= 0) && m_spawntime != 0; }
136 ParticleManager* m_particlemanager;
139 scene::ISceneManager *m_smgr;
140 LocalPlayer *m_player;
153 video::ITexture *m_texture;
154 std::vector<float> m_spawntimes;
155 bool m_collisiondetection;
156 bool m_collision_removal;
162 * Class doing particle as well as their spawners handling
164 class ParticleManager
166 friend class ParticleSpawner;
168 ParticleManager(ClientEnvironment* env);
171 void step (float dtime);
173 void handleParticleEvent(ClientEvent *event, Client *client,
174 scene::ISceneManager* smgr, LocalPlayer *player);
176 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
177 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
179 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
180 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
182 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
183 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
186 void addParticle(Particle* toadd);
190 void stepParticles (float dtime);
191 void stepSpawners (float dtime);
195 std::vector<Particle*> m_particles;
196 std::map<u32, ParticleSpawner*> m_particle_spawners;
198 ClientEnvironment* m_env;
199 Mutex m_particle_list_lock;
200 Mutex m_spawner_list_lock;