24 #include "StelOBJ.hpp" 31 typedef QVector<unsigned int> IdxList;
32 typedef QVector<Vec3f> PosList;
41 void setMeshData(
const IdxList& indexList,
const PosList& posList,
const AABBox *bbox = Q_NULLPTR);
48 float getHeight(
const float x,
const float y)
const;
52 float getNullHeight()
const {
return nullHeight;}
58 static const int GRID_LENGTH = 60;
60 typedef QVector<const unsigned int*> FaceVector;
65 QuadTreeNode(
const Vec2f& min,
const Vec2f& max);
70 enum Quadrant { MinMin, MinMax, MaxMin, MaxMax, INVALID };
73 void putTriangle(
const unsigned int* pTriangle,
const PosList& posList,
int maxLevel = 7);
75 float getHeightAtPoint(
const Vec2f& point,
const PosList &posList)
const;
78 FaceVector getTriangleCandidatesAtPoint(
const Vec2f& point)
const;
83 void init(QuadTreeNode* parent,
const Vec2f& min,
const Vec2f& max);
89 Quadrant getQuadrantForPoint(
const Vec2f& point)
const;
94 QuadTreeNode* children;
110 float getHeight(
const PosList &posList,
const float x,
const float y)
const;
114 Vec2f min, max, range;
119 GridSpace* getSpace(
const float x,
const float y)
const ;
120 static bool triangle_intersects_bbox(
const Vec2f &t1,
const Vec2f &t2,
const Vec2f &t3,
const Vec2f &rMin,
const Vec2f &rMax);
123 static bool line_intersects_triangle(
const Vec2f &t1,
const Vec2f &t2,
const Vec2f &t3,
const Vec2f &p0,
const Vec2f &p1);
125 static void cartesian_to_barycentric(
const Vec2f& t1,
const Vec2f& t2,
const Vec2f& t3,
const Vec2f& p,
float* l1,
float* l2,
float* l3);
126 static float face_height_at(
const PosList &obj,
const unsigned int *pTriangle,
const float x,
const float y);
129 #endif // HEIGHTMAP_HPP This represents a heightmap for viewer-ground collision.
float getHeight(const float x, const float y) const
Get z Value at (x,y) coordinates.
void setMeshData(const IdxList &indexList, const PosList &posList, const AABBox *bbox=Q_NULLPTR)
Sets the mesh data to use. If the bbox is given, min/max calculation is skipped and its values are ta...
Heightmap()
Construct a heightmap from a loaded OBJ mesh.
An axis-aligned bounding-box class.
void setNullHeight(float h)
set/retrieve default height