SuperTuxKart
kart_gfx.hpp
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 
25 #include <vector>
26 #include <string>
27 
28 class AbstractKart;
29 class ParticleKind;
30 class Vec3;
31 
32 #ifndef SERVER_ONLY
33 class ParticleEmitter;
34 #endif
35 
36 namespace irr {
37  namespace scene {
38  class ISceneNode;
39  }
40 }
41 
42 class KartGFX
43 {
44 public:
51  enum KartGFXType { KGFX_NITRO1=0,
52  KGFX_NITRO2,
53  KGFX_NITROSMOKE1,
54  KGFX_NITROSMOKE2,
55  KGFX_ZIPPER,
56  KGFX_TERRAIN,
57  KGFX_SKIDL,
58  KGFX_SKIDR,
59  KGFX_SKID1L = KGFX_SKIDL,
60  KGFX_SKID1R = KGFX_SKIDR,
61  KGFX_SKID2L,
62  KGFX_SKID2R,
63  KGFX_SKID0L,
64  KGFX_SKID0R,
65  KGFX_EXHAUST1,
66  KGFX_EXHAUST2,
67  KGFX_COUNT};
68 
69 private:
72 
75 
78 
79 #ifndef SERVER_ONLY
81  std::vector<ParticleEmitter*> m_all_emitters;
82 #endif
83 
86 
89 
92 
94  irr::scene::ISceneNode* m_nitro_light;
95 
97  irr::scene::ISceneNode* m_skidding_light_1;
98 
100  irr::scene::ISceneNode* m_skidding_light_2;
101 
102  void addEffect(KartGFXType type, const std::string &file_name,
103  const Vec3 &position, bool important);
104  void resizeBox(const KartGFXType type, float new_size);
105 
106  bool supportsLight() const;
107 public:
108  KartGFX(const AbstractKart *kart, bool is_day);
109  ~KartGFX();
110  void reset();
111  void setSkidLevel(const unsigned int level);
112  void setParticleKind(const KartGFXType type, const ParticleKind *pk);
113  void setXYZ(const KartGFXType type, const Vec3 &xyz);
114  void setCreationRateAbsolute(const KartGFXType type, float f);
115  void setCreationRateRelative(const KartGFXType type, float f);
116  void updateTerrain(const ParticleKind *pk);
117  void update(float dt);
118  void updateNitroGraphics(float f);
119  void updateSkidLight(unsigned int level);
120  void getGFXStatus(int* nitro, bool* zipper,
121  int* skidding, bool* red_skidding) const;
122  void setGFXFromReplay(int nitro, bool zipper,
123  int skidding, bool red_skidding);
124  void setGFXInvisible();
125 
126 }; // KartWGFX
127 #endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: kart_gfx.hpp:43
int m_wheel_toggle
Used to alternate particle effects from the rear wheels.
Definition: kart_gfx.hpp:88
void setSkidLevel(const unsigned int level)
Selects the correct skidding particle type depending on skid bonus level.
Definition: kart_gfx.cpp:255
irr::scene::ISceneNode * m_skidding_light_2
A light that's shown on the second skid-level with another color.
Definition: kart_gfx.hpp:100
const ParticleKind * m_skid_kind2
The particle kind for skidding bonus level 2.
Definition: kart_gfx.hpp:77
const ParticleKind * m_skid_kind1
The particle kind for skidding bonus level 1.
Definition: kart_gfx.hpp:74
void updateNitroGraphics(float f)
Updates nitro dependent particle effects.
Definition: kart_gfx.cpp:460
const AbstractKart * m_kart
Pointer to the owner of this kart.
Definition: kart_gfx.hpp:85
const ParticleKind * m_skid_kind0
The particle kind for skidding bonus level 0.
Definition: kart_gfx.hpp:71
void setCreationRateRelative(const KartGFXType type, float f)
Sets the creation rate for the specified particle type relative to the given minimum and maximum part...
Definition: kart_gfx.cpp:355
void updateSkidLight(unsigned int level)
Updates the skiddng light (including disabling it).
Definition: kart_gfx.cpp:501
void update(float dt)
Updates all gfx.
Definition: kart_gfx.cpp:442
void setCreationRateAbsolute(const KartGFXType type, float f)
Sets the absolute creation rate for the specified particle type.
Definition: kart_gfx.cpp:331
irr::scene::ISceneNode * m_skidding_light_1
Light that is shown when the kart is skidding.
Definition: kart_gfx.hpp:97
int m_skid_level
A skid level that is currently in use.
Definition: kart_gfx.hpp:91
void resizeBox(const KartGFXType type, float new_size)
Resize the area from which the particles are emitted: the emitter box should spread from last frame's...
Definition: kart_gfx.cpp:379
void setXYZ(const KartGFXType type, const Vec3 &xyz)
Defines the new position of the specified emitter.
Definition: kart_gfx.cpp:313
irr::scene::ISceneNode * m_nitro_light
A light that's shown when the kart uses nitro.
Definition: kart_gfx.hpp:94
void reset()
Resets all particle emitters.
Definition: kart_gfx.cpp:233
void addEffect(KartGFXType type, const std::string &file_name, const Vec3 &position, bool important)
Creates a new particle node with the specified particle kind read from the given file.
Definition: kart_gfx.cpp:169
std::vector< ParticleEmitter * > m_all_emitters
Vector of all particle emitters.
Definition: kart_gfx.hpp:81
KartGFXType
All particle effects supported by this object.
Definition: kart_gfx.hpp:51
~KartGFX()
Destructor.
Definition: kart_gfx.cpp:143
void setParticleKind(const KartGFXType type, const ParticleKind *pk)
Sets a new particle type to be used.
Definition: kart_gfx.cpp:295
void updateTerrain(const ParticleKind *pk)
If necessary defines a new particle type for the terrain emitter.
Definition: kart_gfx.cpp:397
manages smoke particle effects
Definition: particle_emitter.hpp:44
type of particles
Definition: particle_kind.hpp:42
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35