SuperTuxKart
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 <aabbox3d.h>
24 #include <memory>
25 #include <SColor.h>
26 #include <vector>
27 
28 using namespace irr;
29 
30 class Material;
31 
32 namespace SP
33 {
34  class SPDynamicDrawCall;
35  class SPShader;
36 }
37 
38 #include "utils/no_copy.hpp"
39 #include "utils/vec3.hpp"
40 
41 class AbstractKart;
42 
46 class SkidMarks : public NoCopy
47 {
48 private:
51 
54 
56  float m_width;
57 
59  static const int m_start_alpha;
60 
62  static const int m_start_grey;
63 
66 
68  std::shared_ptr<SP::SPShader> m_shader;
69 
70  // ------------------------------------------------------------------------
71  class SkidMarkQuads : public NoCopy
72  {
76  float m_z_offset;
77 
79  float m_fade_out;
80 
81  video::SColor m_start_color;
82 
85 
86  std::shared_ptr<SP::SPDynamicDrawCall> m_dy_dc;
87 
88  public:
89  SkidMarkQuads (const Vec3 &left, const Vec3 &right,
90  const Vec3 &normal, Material* material,
91  std::shared_ptr<SP::SPShader> shader,
92  float z_offset, video::SColor* custom_color = NULL);
93  ~SkidMarkQuads();
94  void add (const Vec3 &left,
95  const Vec3 &right,
96  const Vec3 &normal,
97  float distance);
98  bool fade (float f);
99  const Vec3& getCenterStart() const { return m_center_start; }
100  }; // SkidMarkQuads
101 
102  // ------------------------------------------------------------------------
104  std::vector<std::unique_ptr<SkidMarkQuads> > m_left, m_right;
105 
108  static float m_avoid_z_fighting;
109 
110 public:
111  SkidMarks(const AbstractKart& kart, float width=0.32f);
112  ~SkidMarks();
113  void update (float dt, bool force_skid_marks=false,
114  video::SColor* custom_color = NULL);
115  void reset();
116 
117 }; // SkidMarks
118 
119 #endif
120 
121 /* EOF */
float m_width
Reduce effect of Z-fighting.
Definition: skid_marks.hpp:56
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
static const int m_start_grey
Initial grey value, same for the 3 channels.
Definition: skid_marks.hpp:62
Definition: skid_marks.hpp:71
std::shared_ptr< SP::SPShader > m_shader
Shader(alphablend) to use for the skid marks.
Definition: skid_marks.hpp:68
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:76
static const int m_start_alpha
Initial alpha value.
Definition: skid_marks.hpp:59
std::vector< std::unique_ptr< SkidMarkQuads > > m_left
Two skidmark objects for the left and right wheel.
Definition: skid_marks.hpp:104
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
This class is responsible for drawing skid marks for a kart.
Definition: skid_marks.hpp:46
Definition: material.hpp:46
static float m_avoid_z_fighting
Shared static so that consecutive skidmarks are at a slightly different height.
Definition: skid_marks.hpp:108
float m_fade_out
Fade out = alpha value.
Definition: skid_marks.hpp:79
Material * m_material
Material to use for the skid marks.
Definition: skid_marks.hpp:65
bool m_skid_marking
True if the kart was skidding in the previous frame.
Definition: skid_marks.hpp:53
Vec3 m_center_start
Vector marking the start of the skidmarks (located between left and right wheel)
Definition: skid_marks.hpp:84
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
const AbstractKart & m_kart
Reference to the kart to which these skidmarks belong.
Definition: skid_marks.hpp:50