SuperTuxKart
Loading...
Searching...
No Matches
skid_marks.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2004-2015 Ingo Ruhnke <grumbel@gmx.de>
4// Copyright (C) 2013-2015 Joerg Henrichs
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU General Public License
8// as published by the Free Software Foundation; either version 3
9// of the License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20#ifndef HEADER_SKID_MARK_HPP
21#define HEADER_SKID_MARK_HPP
22
23#include <memory>
24#include <SColor.h>
25#include <vector>
26
27using namespace irr;
28
29class Material;
30
31namespace SP
32{
33 class SPDynamicDrawCall;
34 class SPShader;
35}
36
37namespace irr
38{
39 namespace scene
40 {
41 class IMeshSceneNode;
42 }
43}
44
45#include "utils/no_copy.hpp"
46#include "utils/vec3.hpp"
47
48class AbstractKart;
49
53class SkidMarks : public NoCopy
54{
55private:
58
61
63 float m_width;
64
66 static const int m_start_alpha;
67
69 static const int m_start_grey;
70
73
75 std::shared_ptr<SP::SPShader> m_shader;
76
77 // ------------------------------------------------------------------------
78 class SkidMarkQuads : public NoCopy
79 {
84
87
88 video::SColor m_start_color;
89
92
93 std::shared_ptr<SP::SPDynamicDrawCall> m_dy_dc;
94
95 irr::scene::IMeshSceneNode* m_node;
96
97 void addSP (const Vec3 &left,
98 const Vec3 &right,
99 const Vec3 &normal,
100 float distance);
101
102 void addLegacy (const Vec3 &left,
103 const Vec3 &right,
104 const Vec3 &normal,
105 float distance);
106 public:
107 SkidMarkQuads (const Vec3 &left, const Vec3 &right,
108 const Vec3 &normal, Material* material,
109 std::shared_ptr<SP::SPShader> shader,
110 float z_offset, video::SColor* custom_color = NULL);
112
113 void add (const Vec3 &left,
114 const Vec3 &right,
115 const Vec3 &normal,
116 float distance);
117 bool fade (float f);
118 const Vec3& getCenterStart() const { return m_center_start; }
119 }; // SkidMarkQuads
120
121 // ------------------------------------------------------------------------
123 std::vector<std::unique_ptr<SkidMarkQuads> > m_left, m_right;
124
127 static float m_avoid_z_fighting;
128
129public:
130 SkidMarks(const AbstractKart& kart, float width=0.32f);
131 ~SkidMarks();
132 void update (float dt, bool force_skid_marks=false,
133 video::SColor* custom_color = NULL);
134 void reset();
135
136}; // SkidMarks
137
138#endif
139
140/* EOF */
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: material.hpp:48
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: skid_marks.hpp:79
float m_z_offset
Used to move skid marks at the same location slightly on top of each other to avoid a 'wobbling' effe...
Definition: skid_marks.hpp:83
float m_fade_out
Fade out = alpha value.
Definition: skid_marks.hpp:86
bool fade(float f)
Fades the current skid marks.
Definition: skid_marks.cpp:451
Vec3 m_center_start
Vector marking the start of the skidmarks (located between left and right wheel)
Definition: skid_marks.hpp:91
void add(const Vec3 &left, const Vec3 &right, const Vec3 &normal, float distance)
Adds the two points to this SkidMarkQuads.
Definition: skid_marks.cpp:435
This class is responsible for drawing skid marks for a kart.
Definition: skid_marks.hpp:54
static float m_avoid_z_fighting
Shared static so that consecutive skidmarks are at a slightly different height.
Definition: skid_marks.hpp:127
Material * m_material
Material to use for the skid marks.
Definition: skid_marks.hpp:72
std::shared_ptr< SP::SPShader > m_shader
Shader(alphablend) to use for the skid marks.
Definition: skid_marks.hpp:75
bool m_skid_marking
True if the kart was skidding in the previous frame.
Definition: skid_marks.hpp:60
std::vector< std::unique_ptr< SkidMarkQuads > > m_left
Two skidmark objects for the left and right wheel.
Definition: skid_marks.hpp:123
float m_width
Reduce effect of Z-fighting.
Definition: skid_marks.hpp:63
static const int m_start_alpha
Initial alpha value.
Definition: skid_marks.hpp:66
static const int m_start_grey
Initial grey value, same for the 3 channels.
Definition: skid_marks.hpp:69
const AbstractKart & m_kart
Reference to the kart to which these skidmarks belong.
Definition: skid_marks.hpp:57
void update(float dt, bool force_skid_marks=false, video::SColor *custom_color=NULL)
Either adds to an existing skid mark quad, or (if the kart is skidding) starts a new skid mark quad.
Definition: skid_marks.cpp:91
void reset()
Removes all skid marks, called when a race is restarted.
Definition: skid_marks.cpp:79
~SkidMarks()
Removes all skid marks from the scene graph and frees the state.
Definition: skid_marks.cpp:71
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35