SuperTuxKart
Loading...
Searching...
No Matches
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>
23namespace irr
24{
25 namespace video { class SMaterial; class SColor; }
26 namespace scene { class ISceneNode; class IAnimatedMesh; }
27}
28using namespace irr;
29
30namespace 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
40class AbstractKart;
41class Quad;
42class Material;
43
48{
49private:
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
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* createMeshSP(unsigned material_id, bool bonus_mesh);
119 scene::IAnimatedMesh* createMesh(unsigned material_id, bool bonus_mesh);
120
121 void setDebugColor(const video::SColor &color, bool inner);
122 void updateQuad();
123 void updateSlipstreamingTextures(float f, const AbstractKart* kart);
124 void updateBonusTexture();
125 void hideAllNodes();
126public:
127 SlipStream (AbstractKart* kart);
128 ~SlipStream ();
129 void reset();
130 void update(int ticks);
131 bool isSlipstreamReady() const;
132 void updateSpeedIncrease();
133 // ------------------------------------------------------------------------
136 const Quad& getSlipstreamQuad() const { return *m_slipstream_quad; }
137 // ------------------------------------------------------------------------
140 // ------------------------------------------------------------------------
142 bool inUse() const {return m_bonus_time>0.0f; }
143}; // SlipStream
144#endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: material.hpp:48
Handles animated textures (textures that move)
Definition: moving_texture.hpp:34
Definition: quad.hpp:38
Definition: sp_mesh.hpp:44
Definition: slip_stream.hpp:48
enum SlipStream::@7 m_slipstream_mode
Slipstream mode: either nothing happening, or the kart is collecting 'slipstream credits'.
MovingTexture * m_moving
The moving texture for the normal node.
Definition: slip_stream.hpp:55
int m_current_target_id
Used to trigger automatically the slipstreaming bonus.
Definition: slip_stream.hpp:95
void updateQuad()
UpdateQuad.
Definition: slip_stream.cpp:712
AbstractKart * m_target_kart
The kart from which this kart gets slipstream.
Definition: slip_stream.hpp:116
SP::SPMesh * createMeshSP(unsigned material_id, bool bonus_mesh)
Creates the mesh for the slipstream effect.
Definition: slip_stream.cpp:424
scene::ISceneNode * m_node
The scene node.
Definition: slip_stream.hpp:66
const AbstractKart * getSlipstreamTarget() const
Returns the kart from which slipstream is 'collected'.
Definition: slip_stream.hpp:139
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dc2
For debugging: a simple quad to display where inner slipstream works.
Definition: slip_stream.hpp:78
std::shared_ptr< SP::SPDynamicDrawCall > m_debug_dc
For debugging: a simple quad to display where slipstream works.
Definition: slip_stream.hpp:75
bool isSlipstreamReady() const
Returns true if enough slipstream credits have been accumulated to get a boost when leaving the slips...
Definition: slip_stream.cpp:662
void setDebugColor(const video::SColor &color, bool inner)
Sets the color of the debug mesh (which shows the area in which slipstream can be accumulated).
Definition: slip_stream.cpp:677
Quad * m_slipstream_quad
This is slipstream area if the kart is at 0,0,0 without rotation.
Definition: slip_stream.hpp:105
MovingTexture * m_moving_fast
The moving texture for the fast node.
Definition: slip_stream.hpp:59
float m_bonus_time
The remaining active time bonus.
Definition: slip_stream.hpp:88
scene::ISceneNode * m_node_fast
The fast scene node.
Definition: slip_stream.hpp:69
AbstractKart * m_kart
The kart to which this smoke belongs.
Definition: slip_stream.hpp:51
scene::IAnimatedMesh * createMesh(unsigned material_id, bool bonus_mesh)
Creates the mesh for the slipstream effect.
Definition: slip_stream.cpp:283
scene::ISceneNode * m_bonus_node
The node used when the bonus is active.
Definition: slip_stream.hpp:72
float m_length
The length of the slipstream cylinder.
Definition: slip_stream.hpp:82
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
void reset()
Called at re-start of a race.
Definition: slip_stream.cpp:265
MovingTexture * m_moving_bonus
The moving texture for the fast node.
Definition: slip_stream.hpp:63
void update(int ticks)
Update, called once per timestep.
Definition: slip_stream.cpp:853
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
const Quad & getSlipstreamQuad() const
Returns the quad in which slipstreaming is effective for this kart.
Definition: slip_stream.hpp:136
bool inUse() const
Returns if slipstream is being used.
Definition: slip_stream.hpp:142
float m_slipstream_time
The time a kart was in slipstream.
Definition: slip_stream.hpp:85
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
~SlipStream()
Removes the node from the scene graph.
Definition: slip_stream.cpp:221