www.pudn.com > Gimcrack-v0.0051-Source.zip > plane.h


#ifndef _PLANE_H_ 
#define _PLANE_H_ 
#include "vector.h" 
#include "aabb.h" 
 
class GcPlane 
{ 
	public: 
		enum Position { BehindPlane, OnPlane, FrontPlane }; 
		 
		GcPlane() { m_distance = 0.0f; } 
		GcPlane( const GcVector3 & normal, float distance ) : m_normal( normal ), m_distance( distance ) { } 
//		GcPlane( const GcVector3 & normal, const GcVector3 & point ) : m_normal( normal ), m_distance( -( point.DotProduct(m_normal) ) ) { } 
		GcPlane( const GcVector3 & normal, const GcVector3 & point ); 
 
		void SetPlane( const GcVector3 & normal, const GcVector3 & point ); 
		void SetPlane( const GcVector3 & normal, float distance ) { m_normal = normal; m_distance = distance; } 
 
		void RenderOutlines(); 
		bool Intersects( GcAABB & aabb ); 
//		const Position ClassifyAABB( GcAABB & aabb ); 
 
		float Distance( GcVector3 & point ) const 
		{ 
			//GcVector3 tmp = point; 
			//GcVector3 tmp1 = m_normal; 
 
			//return ( tmp1.DotProduct(tmp) + m_distance ); 
			return( (m_normal * point) + m_distance ); 
		}  
 
		Position ClassifyPoint( GcVector3 & point ) const 
		{ 
			float d = Distance( point ); 
 
			if( d == 0 ) 
				return OnPlane; 
			else if( d > 0 ) 
				return FrontPlane; 
			else 
				return BehindPlane; 
		}  
 
 
		GcVector3 m_normal; 
		float m_distance; 
	private: 
		 
 
 
}; 
 
#endif /* _PLANE_H_ */