#ifndef PLANE_H
#define PLANE_H

struct IDirect3DDevice9;

namespace cbk
{
	class Vector;
	class Line;
	class BoundingBox;

	class Plane
	{
	public:
		enum Direction
		{
			DIR_Behind = -1,
			DIR_Equal = 0,
			DIR_Front = 1,
		};

		Plane(void);
		Plane(const Vector& abc, const float& d);
		Plane(const Vector& n, const Vector& p);
		Plane(const Vector& p1, const Vector& p2, const Vector& p3);

		Plane& CreatePlaneFromABCD(const Vector& abc, const float& d);
		Plane& CreatePlaneFromABCD(const float& a, const float& b, const float& c, const float& d);
		Plane& CreatePlaneFromPointNormal(const Vector& n, const Vector& p);
		Plane& CreatePlaneFromPoints(const Vector& p1, const Vector& p2, const Vector& p3);

		const Vector getNormal(void) const;
		Plane& setNormal(const Vector& normal);

		const float& getD(void) const;
		Plane& setD(const float& d);

		const Vector getPoint(void) const;

		const Direction pointInFront(const Vector& p) const;
		const Direction boundingBoxInFront(const BoundingBox& p) const;

		const Direction Intersection(const Plane& p) const;
		const Direction Intersection(const Line& l) const;

		void draw(IDirect3DDevice9* device) const;

	protected:
		void normalize(void);

	private:
		float pos[4];
	};
}

#endif //PLANE_H