SuperTuxKart
slip_stream.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2010-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_SLIP_STREAM_HPP
20 #define HEADER_SLIP_STREAM_HPP
21 
22 #include <matrix4.h>
23 namespace irr
24 {
25  namespace video { class SMaterial; class SColor; }
26  namespace scene { class ISceneNode; }
27 }
28 using namespace irr;
29 
30 namespace SP
31 {
32  class SPDynamicDrawCall;
33  class SPMesh;
34 }
35 
36 #include "graphics/moving_texture.hpp"
37 #include "utils/no_copy.hpp"
38 #include <memory>
39 
40 class AbstractKart;
41 class Quad;
42 class Material;
43 
48 {
49 private:
52 
56 
60 
64 
66  scene::ISceneNode *m_node;
67 
69  scene::ISceneNode *m_node_fast;
70 
72  scene::ISceneNode *m_bonus_node;
73 
75  std::shared_ptr<SP::SPDynamicDrawCall> m_debug_dc;
76 
78  std::shared_ptr<SP::SPDynamicDrawCall> m_debug_dc2;
79 
82  float m_length;
83 
86 
88  float m_bonus_time;
89 
92 
96  int m_previous_target_id;
97  int m_speed_increase_ticks;
98  int m_speed_increase_duration;
99 
102  enum {SS_NONE, SS_COLLECT} m_slipstream_mode;
103 
106 
109 
113 
117 
118  SP::SPMesh* createMesh(Material* material, bool bonus_mesh);
119  void setDebugColor(const video::SColor &color, bool inner);
120  void updateQuad();
121  void updateSlipstreamingTextures(float f, const AbstractKart* kart);
122  void updateBonusTexture();
123 public:
124  SlipStream (AbstractKart* kart);
125  ~SlipStream ();
126  void reset();
127  void update(int ticks);
128  bool isSlipstreamReady() const;
129  void updateSpeedIncrease();
130  // ------------------------------------------------------------------------
133  const Quad& getSlipstreamQuad() const { return *m_slipstream_quad; }
134  // ------------------------------------------------------------------------
136  const AbstractKart* getSlipstreamTarget() const {return m_target_kart;}
137  // ------------------------------------------------------------------------
139  bool inUse() const {return m_bonus_time>0.0f; }
140 }; // SlipStream
141 #endif
MovingTexture * m_moving
The moving texture for the normal node.
Definition: slip_stream.hpp:55
Definition: sp_mesh.hpp:39
int m_current_target_id
Used to trigger automatically the slipstreaming bonus.
Definition: slip_stream.hpp:95
bool inUse() const
Returns if slipstream is being used.
Definition: slip_stream.hpp:139
Quad * m_slipstream_outer_quad
This is the outer slipstream area if the kart is at 0,0,0 without rotation.
Definition: slip_stream.hpp:112
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dc2
For debugging: a simple quad to display where inner slipstream works.
Definition: slip_stream.hpp:78
AbstractKart * m_kart
The kart to which this smoke belongs.
Definition: slip_stream.hpp:51
MovingTexture * m_moving_fast
The moving texture for the fast node.
Definition: slip_stream.hpp:59
MovingTexture * m_moving_bonus
The moving texture for the fast node.
Definition: slip_stream.hpp:63
Definition: quad.hpp:37
AbstractKart * m_target_kart
The kart from which this kart gets slipstream.
Definition: slip_stream.hpp:116
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dc
For debugging: a simple quad to display where slipstream works.
Definition: slip_stream.hpp:75
float m_length
The length of the slipstream cylinder.
Definition: slip_stream.hpp:82
Definition: material.hpp:46
Quad * m_slipstream_quad
This is slipstream area if the kart is at 0,0,0 without rotation.
Definition: slip_stream.hpp:105
scene::ISceneNode * m_node
The scene node.
Definition: slip_stream.hpp:66
float m_bonus_time
The remaining active time bonus.
Definition: slip_stream.hpp:88
Handles animated textures (textures that move)
Definition: moving_texture.hpp:33
float m_slipstream_time
The time a kart was in slipstream.
Definition: slip_stream.hpp:85
Quad * m_slipstream_inner_quad
This is the inner slipstream area if the kart is at 0,0,0 without rotation.
Definition: slip_stream.hpp:108
scene::ISceneNode * m_node_fast
The fast scene node.
Definition: slip_stream.hpp:69
scene::ISceneNode * m_bonus_node
The node used when the bonus is active.
Definition: slip_stream.hpp:72
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
bool m_bonus_active
This bool is used to know the first time we're going out of the slipstreaming area.
Definition: slip_stream.hpp:91
const Quad & getSlipstreamQuad() const
Returns the quad in which slipstreaming is effective for this kart.
Definition: slip_stream.hpp:133
Definition: slip_stream.hpp:47
const AbstractKart * getSlipstreamTarget() const
Returns the kart from which slipstream is 'collected'.
Definition: slip_stream.hpp:136