stk-code_catmod/src/tracks/quad_set.hpp
mbjornstk 6042c2cb63 Remove exec prop/bit.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3526 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2009-05-20 00:05:01 +00:00

68 lines
2.7 KiB
C++

// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_QUAD_SET_HPP
#define HEADER_QUAD_SET_HPP
#include <vector>
#include <string>
#include "tracks/quad.hpp"
class Vec3;
class XMLNode;
class QuadSet {
private:
/** The 2d bounding box, used for hashing. */
// FIXME: named with z being the forward axis
float m_xMin, m_xMax, m_zMin, m_zMax;
/** The list of all quads. */
std::vector<Quad*> m_all_quads;
void load (const std::string &filename);
void getPoint(const XMLNode *xml, const std::string &attribute_name,
Vec3 *result) const;
float sideOfLine2D(const Vec3 &l1, const Vec3 &l2, const Vec3 &p) const;
public:
static const int QUAD_NONE=-1;
QuadSet (const std::string& filename);
int getQuadAtPos (const Vec3& p) const;
const Quad& getQuad(int n) const {return *(m_all_quads[n]); }
int getCurrentQuad(const Vec3& p, int oldQuad) const;
bool pointInQuad (const Quad& q, const btVector3& p) const;
/** Returns true if the point p is in the n-th. quad. */
bool pointInQuad (int n, const btVector3& p) const
{return pointInQuad(*m_all_quads[n],p);}
void getBoundingBox(float* xMin, float* xMax,
float* zMin, float* zMax) const
{ *xMin=m_xMin; *xMax=m_xMax;
*zMin=m_zMin; *zMax=m_zMax;}
/** Returns the number of quads. */
unsigned int getNumberOfQuads() const
{return (unsigned int)m_all_quads.size(); }
/** Returns the center of quad n. */
const Vec3& getCenterOfQuad(int n) const
{return m_all_quads[n]->getCenter(); }
/** Returns the n-th. quad. */
const Quad& getQuad(int n) {return *(m_all_quads[n]); }
}; // QuadSet
#endif