Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Plane.h
Go to the documentation of this file.
1#ifndef ULT_MATH_PLANE_H_INCLUDED
2#define ULT_MATH_PLANE_H_INCLUDED
3
4#include <Ult/Math/Vector3D.h>
5
6namespace Ult
7{
8
9class OBB;
10
21
26class Plane
27{
28public:
32 Plane();
36 Plane(const float a, const float b, const float c, const float d);
37
42 void CreatePlaneFromTri(const Vector3D& t1, const Vector3D& t2, const Vector3D& t3);
43
48 bool Intersect(const Plane& pl, Vector3D* intersectPoint) const;
53 bool Intersect(const Vector3D& bbMin, const Vector3D& bbMax) const;
58 bool Intersect(const Vector3D& position, const float radius) const;
62 bool Intersect(const OBB& obb);
63
65 PlaneStatus ClassifyPoint(const Vector3D& v) const;
70 PlaneStatus ClassifyPoint(const Vector3D& v, float* dist) const;
72 PlaneStatus ClassifyPoint(const float x, const float y, const float z) const;
77 PlaneStatus ClassifyPoint(const float x, const float y, const float z, float* dist) const;
78
80 float GetDistance(const Vector3D& v) const;
82 float GetDistance(const float x, const float y, const float z) const;
83
88 Vector3D Reflect(const Vector3D& vec, const float e) const;
89
93 bool ClipTriangle(
94 Vector3D* inVerts, const int totalInVerts,
95 Vector3D* outFrontVerts, int* totalOutFrontVerts,
96 Vector3D* outBackVerts, int* totalOutBackVerts
97 );
98
100 Vector3D GetNormal() const { return Vector3D(mA, mB, mC); }
102 void SetNormal(const Vector3D& n) { mA = n.x, mB = n.y, mC = n.z; }
103
105 void SetPointOnPlane(const Vector3D& p) { mPointOnPlane = p; }
106
111 bool operator==(const Plane& p) {
112 return
113 mA == p.mA &&
114 mB == p.mB &&
115 mC == p.mC &&
116 mD == p.mD;
117 }
118
121 Plane& operator=(const Plane& p) {
122 mA = p.mA;
123 mB = p.mB;
124 mC = p.mC;
125 mD = p.mD;
126 return *this;
127 }
128
130 float mA, mB, mC, mD;
133};
134
135} // namespace Ult
136
137#endif // ULT_MATH_PLANE_H_INCLUDED
Definition OBB.h:16
void SetNormal(const Vector3D &n)
Definition Plane.h:102
Plane()
Definition Plane.cpp:9
Vector3D mPointOnPlane
Definition Plane.h:132
Plane & operator=(const Plane &p)
Definition Plane.h:121
Vector3D Reflect(const Vector3D &vec, const float e) const
Definition Plane.cpp:151
bool operator==(const Plane &p)
Definition Plane.h:111
float mB
Definition Plane.h:130
bool Intersect(const Plane &pl, Vector3D *intersectPoint) const
Definition Plane.cpp:41
PlaneStatus ClassifyPoint(const Vector3D &v) const
Definition Plane.cpp:120
Vector3D GetNormal() const
Definition Plane.h:100
bool ClipTriangle(Vector3D *inVerts, const int totalInVerts, Vector3D *outFrontVerts, int *totalOutFrontVerts, Vector3D *outBackVerts, int *totalOutBackVerts)
Definition Plane.cpp:166
bool Intersect(const OBB &obb)
void CreatePlaneFromTri(const Vector3D &t1, const Vector3D &t2, const Vector3D &t3)
Definition Plane.cpp:25
void SetPointOnPlane(const Vector3D &p)
Definition Plane.h:105
float mD
Definition Plane.h:130
float mA
Definition Plane.h:130
float GetDistance(const Vector3D &v) const
Definition Plane.cpp:141
float mC
Definition Plane.h:130
Definition Vector3D.h:12
float y
Definition Vector3D.h:116
float x
Definition Vector3D.h:116
float z
Definition Vector3D.h:116
PlaneStatus
Definition Plane.h:13
@ Back
Definition Plane.h:15
@ Front
Definition Plane.h:14
@ Culled
Definition Plane.h:18
@ Clipped
Definition Plane.h:17
@ OnPlane
Definition Plane.h:16
@ Visible
Definition Plane.h:19
Definition Archive.h:13