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"
30 #include "tileanimation.h"
33 class ParticleManager;
34 class ClientEnvironment;
36 class Particle : public scene::ISceneNode
41 scene::ISceneManager* mgr,
43 ClientEnvironment *env,
49 bool collisiondetection,
50 bool collision_removal,
52 video::ITexture *texture,
55 const struct TileAnimationParams &anim,
60 virtual const aabb3f &getBoundingBox() const
65 virtual u32 getMaterialCount() const
70 virtual video::SMaterial& getMaterial(u32 i)
75 virtual void OnRegisterSceneNode();
76 virtual void render();
78 void step(float dtime);
81 { return m_expiration < m_time; }
85 void updateVertices();
87 video::S3DVertex m_vertices[4];
91 ClientEnvironment *m_env;
94 aabb3f m_collisionbox;
95 video::SMaterial m_material;
101 LocalPlayer *m_player;
104 bool m_collisiondetection;
105 bool m_collision_removal;
107 v3s16 m_camera_offset;
108 struct TileAnimationParams m_animation;
109 float m_animation_time;
110 int m_animation_frame;
114 class ParticleSpawner
117 ParticleSpawner(IGameDef* gamedef,
118 scene::ISceneManager *smgr,
123 v3f minvel, v3f maxvel,
124 v3f minacc, v3f maxacc,
125 float minexptime, float maxexptime,
126 float minsize, float maxsize,
127 bool collisiondetection,
128 bool collision_removal,
131 video::ITexture *texture,
133 const struct TileAnimationParams &anim, u8 glow,
134 ParticleManager* p_manager);
138 void step(float dtime, ClientEnvironment *env);
141 { return (m_amount <= 0) && m_spawntime != 0; }
144 ParticleManager* m_particlemanager;
147 scene::ISceneManager *m_smgr;
148 LocalPlayer *m_player;
161 video::ITexture *m_texture;
162 std::vector<float> m_spawntimes;
163 bool m_collisiondetection;
164 bool m_collision_removal;
167 struct TileAnimationParams m_animation;
172 * Class doing particle as well as their spawners handling
174 class ParticleManager
176 friend class ParticleSpawner;
178 ParticleManager(ClientEnvironment* env);
181 void step (float dtime);
183 void handleParticleEvent(ClientEvent *event, Client *client,
184 scene::ISceneManager* smgr, LocalPlayer *player);
186 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
187 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
189 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
190 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
192 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
193 LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
196 void addParticle(Particle* toadd);
200 void stepParticles (float dtime);
201 void stepSpawners (float dtime);
205 std::vector<Particle*> m_particles;
206 std::map<u32, ParticleSpawner*> m_particle_spawners;
208 ClientEnvironment* m_env;
209 Mutex m_particle_list_lock;
210 Mutex m_spawner_list_lock;