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,
123 video::ITexture *texture,
125 ParticleManager* p_manager);
129 void step(float dtime, ClientEnvironment *env);
132 { return (m_amount <= 0) && m_spawntime != 0; }
135 ParticleManager* m_particlemanager;
138 scene::ISceneManager *m_smgr;
139 LocalPlayer *m_player;
152 video::ITexture *m_texture;
153 std::vector<float> m_spawntimes;
154 bool m_collisiondetection;
155 bool m_collision_removal;
161 * Class doing particle as well as their spawners handling
163 class ParticleManager
165 friend class ParticleSpawner;
167 ParticleManager(ClientEnvironment* env);
170 void step (float dtime);
172 void handleParticleEvent(ClientEvent *event,IGameDef *gamedef,
173 scene::ISceneManager* smgr, LocalPlayer *player);
175 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
176 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
178 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
179 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
181 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
182 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
185 void addParticle(Particle* toadd);
189 void stepParticles (float dtime);
190 void stepSpawners (float dtime);
194 std::vector<Particle*> m_particles;
195 std::map<u32, ParticleSpawner*> m_particle_spawners;
197 ClientEnvironment* m_env;
198 Mutex m_particle_list_lock;
199 Mutex m_spawner_list_lock;