SuperTuxKart
Loading...
Searching...
No Matches
quad.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2009-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_QUAD_HPP
20#define HEADER_QUAD_HPP
21
22#include <SColor.h>
23
24#include "utils/leak_check.hpp"
25#include "utils/no_copy.hpp"
26#include "utils/vec3.hpp"
27
28namespace irr
29{
30 namespace video { struct S3DVertex; struct S3DVertexSkinnedMesh; }
31}
32using namespace irr;
33
37class Quad : public NoCopy
38{
39protected:
42
46
49
52
53private:
56
57 bool m_is_ignored;
58
61 float m_min_height, m_min_height_testing;
62
65 float m_max_height, m_max_height_testing;
66
67public:
68 LEAK_CHECK()
69 // ------------------------------------------------------------------------
70 Quad(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3,
71 const Vec3 & normal = Vec3(0, 1, 0), int index = -1,
72 bool invisible = false, bool ignored = false);
73 // ------------------------------------------------------------------------
74 virtual ~Quad() {}
75 // ------------------------------------------------------------------------
76 void getVertices(video::S3DVertex *v, const video::SColor &color) const;
77 // ------------------------------------------------------------------------
78 void getSPMVertices(video::S3DVertexSkinnedMesh *v,
79 const video::SColor &color) const;
80 // ------------------------------------------------------------------------
82 const Vec3& operator[](int i) const { return m_p[i]; }
83 // ------------------------------------------------------------------------
85 const Vec3& getCenter () const { return m_center; }
86 // ------------------------------------------------------------------------
88 void setQuad (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3);
89 // ------------------------------------------------------------------------
90 void setHeightTesting(float min, float max)
91 {
92 m_min_height_testing = min;
93 m_max_height_testing = max;
94 }
95 // ------------------------------------------------------------------------
97 float getMinHeight() const { return m_min_height; }
98 // ------------------------------------------------------------------------
100 int getIndex() const
101 {
102 // You should not call this if it has default value (like slipstream)
103 assert(m_index != -1);
104 return m_index;
105 }
106 // ------------------------------------------------------------------------
109 bool isInvisible() const { return m_invisible; }
110 // ------------------------------------------------------------------------
111 bool isIgnored() const { return m_is_ignored; }
112 // ------------------------------------------------------------------------
114 const Vec3& getNormal() const { return m_normal; }
115 // ------------------------------------------------------------------------
117 virtual bool pointInside(const Vec3& p,
118 bool ignore_vertical = false) const;
119 // ------------------------------------------------------------------------
122 virtual bool is3DQuad() const { return false; }
123 // ------------------------------------------------------------------------
124 virtual float getDistance2FromPoint(const Vec3 &xyz) const
125 {
126 // You should not call this in a bare quad
127 assert(false);
128 return 0.0f;
129 }
130
131}; // class Quad
132#endif
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: quad.hpp:38
int m_index
Index of this quad, used only with graph.
Definition: quad.hpp:48
void setQuad(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3)
Set new quad coordinates.
Definition: quad.cpp:46
const Vec3 & getCenter() const
Returns the center of a quad.
Definition: quad.hpp:85
float getMinHeight() const
Returns the minimum height of a quad.
Definition: quad.hpp:97
bool isInvisible() const
Returns true of this quad is invisible, i.e.
Definition: quad.hpp:109
float m_max_height
The maximum height of the quad, used together with m_min_height to distinguish between quads which ar...
Definition: quad.hpp:65
const Vec3 & getNormal() const
Returns the normal of this quad.
Definition: quad.hpp:114
Vec3 m_normal
Normal of the quad.
Definition: quad.hpp:51
int getIndex() const
Returns the index of this quad.
Definition: quad.hpp:100
void getSPMVertices(video::S3DVertexSkinnedMesh *v, const video::SColor &color) const
Sets the vertices in an spm vertex array to the 4 points of this quad.
Definition: quad.cpp:91
const Vec3 & operator[](int i) const
Returns the i-th.
Definition: quad.hpp:82
Vec3 m_center
The center of all four points, which is used by the AI.
Definition: quad.hpp:45
bool m_invisible
Set to true if this quad should not be shown in the minimap.
Definition: quad.hpp:55
virtual bool pointInside(const Vec3 &p, bool ignore_vertical=false) const
Returns true if a point is inside this quad.
Definition: quad.cpp:115
float m_min_height
The minimum height of the quad, used in case that several quads are on top of each other when determi...
Definition: quad.hpp:61
Vec3 m_p[4]
The four points of a quad.
Definition: quad.hpp:41
void getVertices(video::S3DVertex *v, const video::SColor &color) const
Sets the vertices in a irrlicht vertex array to the 4 points of this quad.
Definition: quad.cpp:64
virtual bool is3DQuad() const
Returns true if this quad is 3D, which additional 3D testing is used in pointInside.
Definition: quad.hpp:122
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35