1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "../MathGeoLibFwd.h"21 #include "../Math/float3.h"22 23 24 #include <vector>25 #include <string>26 27 28 [MATH_BEGIN_NAMESPACE]29 30 31 class [Polyhedron]32 {33 public:34 35 struct [Face]36 {37 38 39 40 41 42 std::vector<int> [v];43 44 45 46 void [FlipWindingOrder]();47 48 49 std::string [ToString]() const;50 51 static [Face] [FromString](const char *str);52 };53 54 55 [VecArray] [v];56 57 58 59 60 std::vector<Face> [f];61 62 63 64 65 [Polyhedron]() {}66 67 68 69 70 int [NumVertices]() const { return (int)[v].size(); }71 72 73 74 75 int [NumFaces]() const { return (int)[f].size(); }76 77 78 79 80 81 int [NumEdges]() const;82 83 84 85 vec *[VertexArrayPtr]() { return ![v].empty() ? (vec*)&[v][0] : 0; }86 const vec *[VertexArrayPtr]() const { return ![v].empty() ? (vec*)&[v][0] : 0; }87 88 89 90 91 vec [Vertex](int vertexIndex) const;92 93 94 95 96 97 98 99 [LineSegment] [Edge](int edgeIndex) const;100 101 102 103 104 105 [LineSegmentArray] [Edges]() const;106 107 std::vector<Polygon> [Faces]() const;108 109 110 111 112 113 std::vector<std::pair<int, int> > [EdgeIndices]() const;114 115 116 117 118 119 120 121 122 [Polygon] [FacePolygon](int faceIndex) const;123 124 125 126 127 128 129 130 131 [Plane] [FacePlane](int faceIndex) const;132 133 134 vec [FaceNormal](int faceIndex) const;135 136 137 138 139 140 141 142 int [ExtremeVertex](const vec &direction) const;143 144 145 146 147 148 149 150 151 152 153 154 vec [ExtremePoint](const vec &direction) const;155 156 157 158 159 160 161 162 163 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;164 165 166 167 vec [ConvexCentroid]() const;168 169 170 171 172 173 174 175 vec [ApproximateConvexCentroid]() const;176 177 178 179 180 float [SurfaceArea]() const;181 182 183 184 float [Volume]() const;185 186 187 188 [AABB] [MinimalEnclosingAABB]() const;189 190 #ifdef MATH_CONTAINERLIB_SUPPORT191 [OBB] MinimalEnclosingOBB() const;192 #endif193 194 void [MergeAdjacentPlanarFaces]();195 196 197 198 199 200 201 202 203 204 205 206 207 bool [FaceIndicesValid]() const;208 209 210 void [FlipWindingOrder]();211 212 213 214 215 216 void [OrientNormalsOutsideConvex]();217 218 219 void [RemoveRedundantVertices]();220 221 222 223 bool [IsNull]() const { return [v].empty() && [f].empty(); }224 225 226 227 228 bool [IsClosed]() const;229 230 231 232 233 234 235 236 bool [IsConvex]() const;237 238 239 240 bool [EulerFormulaHolds]() const;241 242 243 244 bool [FacesAreNondegeneratePlanar](float [epsilon] = 1[e]-2[f]) const;245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 bool [ClipLineSegmentToConvexPolyhedron](const vec &ptA, const vec &dir, float &tFirst, float &tLast) const;263 264 265 266 int [NearestVertex](const vec &point) const;267 268 269 270 271 272 273 274 bool [Contains](const vec &point) const;275 bool [Contains](const [LineSegment] &lineSegment) const;276 bool [Contains](const [Triangle] &triangle) const;277 bool [Contains](const [Polygon] &polygon) const;278 bool [Contains](const [AABB] &aabb) const;279 bool [Contains](const [OBB] &obb) const;280 bool [Contains](const [Frustum] &frustum) const;281 bool [Contains](const [Polyhedron] &polyhedron) const;282 283 284 bool [FaceContains](int faceIndex, const vec &worldSpacePoint, float polygonThickness = 1[e]-3[f]) const;285 286 287 288 289 290 float [FaceContainmentDistance2D](int faceIndex, const vec &worldSpacePoint, float polygonThickness = 1[e]-3[f]) const;291 292 293 294 295 296 297 298 bool [ContainsConvex](const vec &point, float [epsilon] = 1[e]-4[f]) const;299 bool [ContainsConvex](const [LineSegment] &lineSegment) const;300 bool [ContainsConvex](const [Triangle] &triangle) const;301 302 303 304 305 306 307 308 309 310 311 312 vec [ClosestPoint](const [LineSegment] &lineSegment, vec *lineSegmentPt) const;313 vec [ClosestPoint](const [LineSegment] &lineSegment) const;314 315 vec [ClosestPoint](const vec &point) const;316 317 318 319 320 321 322 323 vec [ClosestPointConvex](const vec &point) const;324 325 326 327 328 329 330 331 float [Distance](const vec &point) const;332 333 334 335 336 337 338 339 340 341 bool [Intersects](const [LineSegment] &lineSegment) const;342 bool [Intersects](const [Line] &line) const;343 bool [Intersects](const [Ray] &ray) const;344 bool [Intersects](const [Plane] &plane) const;345 bool [Intersects](const [Polyhedron] &polyhedron) const;346 bool [Intersects](const [AABB] &aabb) const;347 bool [Intersects](const [OBB] &obb) const;348 bool [Intersects](const [Triangle] &triangle) const;349 bool [Intersects](const [Polygon] &polygon) const;350 bool [Intersects](const [Frustum] &frustum) const;351 bool [Intersects](const [Sphere] &sphere) const;352 bool [Intersects](const [Capsule] &capsule) const;353 354 355 356 357 358 359 360 361 bool [IntersectsConvex](const [Line] &line) const;362 bool [IntersectsConvex](const [Ray] &ray) const;363 bool [IntersectsConvex](const [LineSegment] &lineSegment) const;364 365 void [MergeConvex](const vec &point);366 367 368 369 370 void [Translate](const vec &offset);371 372 373 374 375 void [Transform](const [float3x3] &transform);376 void [Transform](const [float3x4] &transform);377 void [Transform](const [float4x4] &transform);378 void [Transform](const [Quat] &transform);379 380 381 382 static [Polyhedron] [ConvexHull](const vec *pointArray, int numPoints);383 384 static [Polyhedron] [Tetrahedron](const vec ¢erPos = [POINT_VEC_SCALAR](0.[f]), float scale = 1.[f], bool ccwIsFrontFacing = true);385 static [Polyhedron] [Octahedron](const vec ¢erPos = [POINT_VEC_SCALAR](0.[f]), float scale = 1.[f], bool ccwIsFrontFacing = true);386 static [Polyhedron] [Hexahedron](const vec ¢erPos = [POINT_VEC_SCALAR](0.[f]), float scale = 1.[f], bool ccwIsFrontFacing = true);387 static [Polyhedron] [Icosahedron](const vec ¢erPos = [POINT_VEC_SCALAR](0.[f]), float scale = 1.[f], bool ccwIsFrontFacing = true);388 static [Polyhedron] [Dodecahedron](const vec ¢erPos = [POINT_VEC_SCALAR](0.[f]), float scale = 1.[f], bool ccwIsFrontFacing = true);389 390 391 392 393 394 bool [SetEquals]([Polyhedron] &p2);395 396 397 398 void [SwapVertices](int i, int j);399 400 401 void [CanonicalizeFaceArray]();402 403 404 bool [ContainsFace](const Face &face) const;405 406 407 408 409 410 int [FindClosestVertex](const vec &pt, float &outDistanceSq) const;411 412 [TriangleArray] [Triangulate]() const;413 414 std::string [ToString]() const;415 416 #ifdef MATH_GRAPHICSENGINE_INTEROP417 void [Triangulate](VertexBuffer &vb, bool ccwIsFrontFacing, int faceStart = 0, int faceEnd = 0x7FFFFFFF) const;418 void ToLineList(VertexBuffer &vb) const;419 #endif420 };421 422 [Polyhedron] [operator *](const [float3x3] &transform, const [Polyhedron] &polyhedron);423 [Polyhedron] [operator *](const [float3x4] &transform, const [Polyhedron] &polyhedron);424 [Polyhedron] [operator *](const [float4x4] &transform, const [Polyhedron] &polyhedron);425 [Polyhedron] [operator *](const [Quat] &transform, const [Polyhedron] &polyhedron);426 427 #ifdef MATH_QT_INTEROP428 Q_DECLARE_METATYPE([Polyhedron])429 Q_DECLARE_METATYPE([Polyhedron]*)430 #endif431 432 433 434 435 436 437 438 439 440 441 442 [MATH_END_NAMESPACE] Go back to previous page