⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plane.h

📁 小型的3D游戏引擎
💻 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_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -