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;
34 class Particle : public scene::ISceneNode
39 scene::ISceneManager* mgr,
41 ClientEnvironment *env,
47 bool collisiondetection,
49 video::ITexture *texture,
55 virtual const core::aabbox3d<f32>& getBoundingBox() const
60 virtual u32 getMaterialCount() const
65 virtual video::SMaterial& getMaterial(u32 i)
70 virtual void OnRegisterSceneNode();
71 virtual void render();
73 void step(float dtime);
76 { return m_expiration < m_time; }
80 void updateVertices();
82 video::S3DVertex m_vertices[4];
86 ClientEnvironment *m_env;
88 core::aabbox3d<f32> m_box;
89 core::aabbox3d<f32> m_collisionbox;
90 video::SMaterial m_material;
96 LocalPlayer *m_player;
99 bool m_collisiondetection;
101 v3s16 m_camera_offset;
104 class ParticleSpawner
107 ParticleSpawner(IGameDef* gamedef,
108 scene::ISceneManager *smgr,
113 v3f minvel, v3f maxvel,
114 v3f minacc, v3f maxacc,
115 float minexptime, float maxexptime,
116 float minsize, float maxsize,
117 bool collisiondetection,
119 video::ITexture *texture,
121 ParticleManager* p_manager);
125 void step(float dtime, ClientEnvironment *env);
128 { return (m_amount <= 0) && m_spawntime != 0; }
131 ParticleManager* m_particlemanager;
134 scene::ISceneManager *m_smgr;
135 LocalPlayer *m_player;
148 video::ITexture *m_texture;
149 std::vector<float> m_spawntimes;
150 bool m_collisiondetection;
156 * Class doing particle as well as their spawners handling
158 class ParticleManager
160 friend class ParticleSpawner;
162 ParticleManager(ClientEnvironment* env);
165 void step (float dtime);
167 void handleParticleEvent(ClientEvent *event,IGameDef *gamedef,
168 scene::ISceneManager* smgr, LocalPlayer *player);
170 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
171 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
173 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
174 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
176 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
177 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
180 void addParticle(Particle* toadd);
184 void stepParticles (float dtime);
185 void stepSpawners (float dtime);
189 std::vector<Particle*> m_particles;
190 std::map<u32, ParticleSpawner*> m_particle_spawners;
192 ClientEnvironment* m_env;
193 JMutex m_particle_list_lock;
194 JMutex m_spawner_list_lock;