SuperTuxKart
Loading...
Searching...
No Matches
terrain_info.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2007-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// MERCHANTe ABILITY 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_TERRAIN_INFO_HPP
20#define HEADER_TERRAIN_INFO_HPP
21
22#include "utils/vec3.hpp"
23
24class btTransform;
25class Material;
26
32{
33private:
42
45
46public:
48 TerrainInfo(const Vec3 &pos);
49 virtual ~TerrainInfo() {};
50
51 bool getSurfaceInfo(const Vec3 &from, Vec3 *position,
52 const Material **m);
53 virtual void update(const btMatrix3x3 &rotation, const Vec3 &from);
54 virtual void update(const Vec3 &from);
55 virtual void update(const Vec3 &from, const Vec3 &towards);
56
57 // ------------------------------------------------------------------------
59 virtual void update(const btMatrix3x3 &rotation)
60 {
61 update(rotation, Vec3(0,0,0));
62 }
63 // ------------------------------------------------------------------------
65 float getHoT() const {return m_hit_point.getY(); }
66 // ------------------------------------------------------------------------
68 const Material *getMaterial() const {return m_material; }
69 // ------------------------------------------------------------------------
72 const Material *getLastMaterial() const {return m_last_material;}
73 // ------------------------------------------------------------------------
75 const Vec3 &getNormal() const {return m_normal; }
76 // ------------------------------------------------------------------------
78 float getTerrainPitch(float heading) const;
79 // ------------------------------------------------------------------------
81 const btVector3& getHitPoint() const { return m_hit_point; }
82 const Vec3& getOrigin() const { return m_origin_ray; }
83
84}; // TerrainInfo
85
86#endif // HEADER_TERRAIN_INFO_HPP
Definition: material.hpp:48
This class stores information about the triangle that's under an object, i.e.: the normal,...
Definition: terrain_info.hpp:32
Vec3 m_normal
Normal of the triangle under the object.
Definition: terrain_info.hpp:35
virtual void update(const btMatrix3x3 &rotation)
Simple wrapper with no offset.
Definition: terrain_info.hpp:59
const Material * m_material
Material of the triangle under the object.
Definition: terrain_info.hpp:37
Vec3 m_origin_ray
DEBUG only: origin of raycast.
Definition: terrain_info.hpp:44
const Vec3 & getNormal() const
Returns the normal of the terrain the kart is on.
Definition: terrain_info.hpp:75
virtual void update(const btMatrix3x3 &rotation, const Vec3 &from)
Update the terrain information based on the latest position.
Definition: terrain_info.cpp:74
TerrainInfo()
Constructor to initialise terrain data.
Definition: terrain_info.cpp:32
const Material * getMaterial() const
Returns the current material the kart is on.
Definition: terrain_info.hpp:68
float getTerrainPitch(float heading) const
Returns the pitch of the terrain depending on the heading.
Definition: terrain_info.cpp:129
bool getSurfaceInfo(const Vec3 &from, Vec3 *position, const Material **m)
Does a raycast upwards from the given position If the raycast indicated that the kart is 'under somet...
Definition: terrain_info.cpp:118
Vec3 m_hit_point
The point that was hit.
Definition: terrain_info.hpp:41
float getHoT() const
Returns the height of the terrain.
Definition: terrain_info.hpp:65
const btVector3 & getHitPoint() const
Returns the hit point of the raycast.
Definition: terrain_info.hpp:81
const Material * getLastMaterial() const
Returns the previous material the kart was one (which might be the same as getMaterial() ).
Definition: terrain_info.hpp:72
const Material * m_last_material
The previous material a kart was on.
Definition: terrain_info.hpp:39
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35