]> git.lizzy.rs Git - minetest.git/blob - src/particles.h
Merge remote branch 'origin/master'
[minetest.git] / src / particles.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef PARTICLES_HEADER
21 #define PARTICLES_HEADER
22
23 #define DIGGING_PARTICLES_AMOUNT 10
24
25 #include <iostream>
26 #include "irrlichttypes_extrabloated.h"
27 #include "tile.h"
28 #include "localplayer.h"
29 #include "environment.h"
30
31 class Particle : public scene::ISceneNode
32 {
33         public:
34         Particle(
35                 IGameDef* gamedef,
36                 scene::ISceneManager* mgr,
37                 LocalPlayer *player,
38                 s32 id,
39                 v3f pos,
40                 v3f velocity,
41                 v3f acceleration,
42                 float expirationtime,
43                 float size,
44                 AtlasPointer texture
45         );
46         ~Particle();
47
48         virtual const core::aabbox3d<f32>& getBoundingBox() const
49         {
50                 return m_box;
51         }
52
53         virtual u32 getMaterialCount() const
54         {
55                 return 1;
56         }
57
58         virtual video::SMaterial& getMaterial(u32 i)
59         {
60                 return m_material;
61         }
62
63         virtual void OnRegisterSceneNode();
64         virtual void render();
65
66         void step(float dtime, ClientEnvironment &env);
67
68         bool get_expired ()
69         { return m_expiration < m_time; }
70
71 private:
72         float m_time;
73         float m_expiration;
74
75         IGameDef *m_gamedef;
76         core::aabbox3d<f32> m_box;
77         core::aabbox3d<f32> m_collisionbox;
78         video::SMaterial m_material;
79         v3f m_pos;
80         v3f m_velocity;
81         v3f m_acceleration;
82         float tex_x0;
83         float tex_x1;
84         float tex_y0;
85         float tex_y1;
86         LocalPlayer *m_player;
87         float m_size;
88         AtlasPointer m_ap;
89         u8 m_light;
90 };
91
92 void allparticles_step (float dtime, ClientEnvironment &env);
93
94 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
95 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
96 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos, const TileSpec tiles[]);
97
98 #endif