Kochol Game Engine  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Plane.h
Go to the documentation of this file.
1 // File name: math.h
2 // Des: Class safhe(Plane)
3 // Date: 17/10/1385
4 // Programmer: Ali Akbar Mohammadi(Kochol)
5 
6 #ifndef PLANE_H
7 #define PLANE_H
8 
9 #include "Vector.h"
10 #include "Matrix.h"
11 
12 namespace kge
13 {
14 namespace math
15 {
16 class Sphere;
17 class AABB;
18 struct Ray;
19 
21 {
22 public:
23  Vector m_vNormal; // plane normal vector
24  float m_fDistance; // distance to origin
25  float m_fA , m_fB , m_fC , m_fD; // ax + by + cz + d = 0
26 
28  Plane() { /* nothing to do */ }
29 
31  CollisionType Collision(const Sphere* pSphere) const;
32 
34  CollisionType Collision(const AABB* pBox) const;
35 
40  void Set(const Vector &vNormal, const Vector &vPoint);
41 
47  void Set(const Vector &vNormal, const Vector &vPoint, float fDistance);
48 
54  void Set(const Vector &v0, const Vector &v1, const Vector &v2);
55 
57  void Set( float a , float b , float c , float d );
58 
63  inline float GetDistance(const Vector& vPoint ) const;
64 
66  Matrix* GetReflectMatrix();
67 
69  Matrix* GetShadowMatrix( Vector &vLightDir );
70 
72  void Normalize();
73 
75  bool GetIntersectionWithPlane(Plane *Other, Ray &outRay);
76 
78  bool GetIntersectionWithLine(Ray *Other, Vector &outPoint);
79 
81  bool GetIntersectionWithPlanes(Plane *o1, Plane *o2, Vector &outPoint);
82 
84  float DotCoord(const Vector& v) const;
85 
87  float DotNormal(const Vector& v) const;
88 
89 protected:
90  Vector m_vPoint; // point on plane
91 
93  inline void CalcABCD();
94 
95 }; // Plane
96 
97 } // math
98 
99 } // kge
100 
101 #endif // PLANE_H