1 //
2 //  SuperTuxKart - a fun racing game with go-kart
3 //  Copyright (C) 2012-2015  Joerg Henrichs
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License
7 //  as published by the Free Software Foundation; either version 3
8 //  of the License, or (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 General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 #ifndef HEADER_KART_GFX_HPP
20 #define HEADER_KART_GFX_HPP
21 
22 /** \defgroup karts
23  *  This class implements all particle effects for a kart. */
24 
25 #include <vector>
26 #include <string>
27 
28 class AbstractKart;
29 class ParticleEmitter;
30 class ParticleKind;
31 class Vec3;
32 
33 namespace irr {
34     namespace scene {
35         class ISceneNode;
36     }
37 }
38 
39 class KartGFX
40 {
41 public:
42     /** All particle effects supported by this object.
43      *  Nitro, zipper, terrain, and skidding effects.  Three different
44      *  skid types are supported, but only one emitter node will be
45      *  created. So KGFX_SKID1/2/3 store the two types, and KGFX_SKID
46      *  = KGFX_SKID1 stores the actual emitter node. KGFX_COUNT
47      *  is the number of entries and must therefore be last. */
48     enum KartGFXType { KGFX_NITRO1=0,
49                        KGFX_NITRO2,
50                        KGFX_NITROSMOKE1,
51                        KGFX_NITROSMOKE2,
52                        KGFX_ZIPPER,
53                        KGFX_TERRAIN,
54                        KGFX_SKIDL,
55                        KGFX_SKIDR,
56                        KGFX_SKID1L = KGFX_SKIDL,
57                        KGFX_SKID1R = KGFX_SKIDR,
58                        KGFX_SKID2L,
59                        KGFX_SKID2R,
60                        KGFX_SKID0L,
61                        KGFX_SKID0R,
62                        KGFX_EXHAUST1,
63                        KGFX_EXHAUST2,
64                        KGFX_COUNT};
65 
66 private:
67     /** The particle kind for skidding bonus level 0. */
68     const ParticleKind *m_skid_kind0;
69 
70     /** The particle kind for skidding bonus level 1. */
71     const ParticleKind *m_skid_kind1;
72 
73     /** The particle kind for skidding bonus level 2. */
74     const ParticleKind *m_skid_kind2;
75 
76     /** Vector of all particle emitters. */
77     std::vector<ParticleEmitter*> m_all_emitters;
78 
79     /** Pointer to the owner of this kart. */
80     const AbstractKart *m_kart;
81 
82     /** Used to alternate particle effects from the rear wheels. */
83     int         m_wheel_toggle;
84 
85     /** A skid level that is currently in use */
86     int m_skid_level;
87 
88     /** A light that's shown when the kart uses nitro. */
89     irr::scene::ISceneNode* m_nitro_light;
90 
91     /** Light that is shown when the kart is skidding. */
92     irr::scene::ISceneNode* m_skidding_light_1;
93 
94     /** A light that's shown on the second skid-level with another color. */
95     irr::scene::ISceneNode* m_skidding_light_2;
96 
97     void addEffect(KartGFXType type, const std::string &file_name,
98                    const Vec3 &position, bool important);
99     void resizeBox(const KartGFXType type, float new_size);
100 
101 public:
102          KartGFX(const AbstractKart *kart, bool is_day);
103         ~KartGFX();
104     void reset();
105     void setSkidLevel(const unsigned int level);
106     void setParticleKind(const KartGFXType type, const ParticleKind *pk);
107     void setXYZ(const KartGFXType type, const Vec3 &xyz);
108     void setCreationRateAbsolute(const KartGFXType type, float f);
109     void setCreationRateRelative(const KartGFXType type, float f);
110     void updateTerrain(const ParticleKind *pk);
111     void update(float dt);
112     void updateNitroGraphics(float f);
113     void updateSkidLight(unsigned int level);
114     void getGFXStatus(int* nitro, bool* zipper,
115                       int* skidding, bool* red_skidding) const;
116     void setGFXFromReplay(int nitro, bool zipper,
117                           int skidding, bool red_skidding);
118     void setGFXInvisible();
119 
120 };   // KartWGFX
121 #endif
122