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

📄 xgvolume.h

📁 XMathLib是一个通用的3D图形数学库。 其中包含两个部分: XMathLib和XGeomLib。分别处理数学和几何运算。 数学部分包含向量、矩阵、四元数的运算。以及其它的运算。 几何部分
💻 H
字号:
#include "XGeomLib.h"

/********************************************************************************
声明:
  这里的代码版权归潘李亮所有.你可以自由使用分发这些代码.但是不得用于商业用途.
  如有需要请于作者联系.
   在你使用本代码时候,请务必保留本声明
    潘李亮 2003-10
	Stanly Lee. 2003-10

	Email : xheartblue@etang.com


   常用包围体如,OBB AABB 等。


*******************************************************************************/

#include  "XMathLib.h"
#include  "XGeomLib.h"
#include  "XCamera.h"

using namespace XMathLib;


namespace XGeomLib
{

	/*
	*/
	class  _GEOM_LIB_EXPORT_ XGRect
	{
		float x;
        float y;
		float h;
        float w;
	};

	
	/*
	AABB盒子。
	*/
	class _GEOM_LIB_EXPORT_  XGAABB
	{
	public:
	    XGAABB(){};
		XGAABB(XPoint& Min,XPoint& Max){ Build(Min,Max); }
		void Build(XPoint& Min,XPoint& Max){};
		void Build(XPoint* points,int n){};
		void AddPoint(XPoint& point){};

	public:
		XPoint m_Min;
		XPoint m_Max;
	};

	/*
	Oreint-Bounding Box;
	*/
	class _GEOM_LIB_EXPORT_  XGOBB
	{
	public:
		XPoint    m_Point;
		XVector3D m_Orient;
	};
	/*
	平头锥体
	*/
	class _GEOM_LIB_EXPORT_  XGFrustum
	{
	public:
		void BuildFromMatrix(XMatrix& mViewTrans,XMatrix& mProjectTrans);
		void BuildFromCamera(XCamera& Camera);
	};


	/*
	包围球
	*/
	class  _GEOM_LIB_EXPORT_ XGShpere
	{
	public:
		XPoint m_Orign;
		float  m_R;
	};

	/*
	 *	包围圆柱
	 */
	class _GEOM_LIB_EXPORT_ XGCylinder
	{
	public:
		XPoint m_StartPoint;
		XPoint m_EndPoint;
		float  m_R;
	};

	/*
	 *	以下为所有的测试函数.
	 */

	//和ViewFrustum 测试函数
	float  InterSection(XGCylinder& cylinder, XGFrustum& frustum);
	float  InterSection(XGAABB& aabb, XGFrustum& frustum);
	float  InterSection(XGOBB& obb,XGFrustum& frutum);
	float  InterSection(XGShpere& shpere,XGFrustum& frustum);

	//BOX之间的测试

	float  InterSection(XGOBB& boxA,XGOBB& boxB);
	float  InterSection(XGAABB& aabbA,XGAABB& aabbB);

	//射线和体之间的测试.
	float  InterSection(XRay& ray, XGAABB& box,XPoint& pIn,XPoint& pOut);
	float  InterSection(XRay& ray, XGFrustum& frustum ,XPoint& pIn,XPoint& pOut);
	float  InterSection(XRay& ray, XGShpere& shpere,XPoint& pIn,XPoint& pOut);
	float  InterSection(XRay& ray, XGCylinder& cylinder,XPoint& pIn,XPoint& pOut);

	//线段和体之间的相交
	float  InterSection(XLineSegment& lineSeg, XGAABB& box,XPoint& pIn,XPoint& pOut);
	float  InterSection(XLineSegment& lineSeg, XGFrustum& frustum ,XPoint& pIn,XPoint& pOut);
	float  InterSection(XLineSegment& lineSeg, XGShpere& shpere,XPoint& pIn,XPoint& pOut);
	float  InterSection(XLineSegment& lineSeg, XGCylinder& cylinder,XPoint& pIn,XPoint& pOut);


	//平面和体之间相交

	float  InterSection(XTriangle& tri, XGAABB& box,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XTriangle& tri, XGFrustum& frustum ,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XTriangle& tri, XGShpere& shpere,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XTriangle& tri, XGCylinder& cylinder,XPoint& pStart,XPoint& pEnd);

	float  InterSection(XPlan& plan, XGAABB& box,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XPlan& plan, XGFrustum& frustum ,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XPlan& plan, XGShpere& shpere,XPoint& pStart,XPoint& pEnd);
	float  InterSection(XPlan& plan, XGCylinder& cylinder,XPoint& pStart,XPoint& pEnd);



};

⌨️ 快捷键说明

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