BSP 分割空间实现.docVIP

  • 5
  • 0
  • 约6.44千字
  • 约 8页
  • 2017-01-09 发布于贵州
  • 举报
BSP: 二叉分割树,是一种分割场景的方法,下面代码是BSP树一种实现可运行: 运行例子中,将定义的16个空间面,分割为一个深度是3的BSP树,上图显示的是运行结果: #include stdafx.h #include map #include vector #include iostream using namespace std; //定义空间的点结构 struct point { float x,y,z; point():x(0.0f),y(0.0f),z(0.0f){}; point(float a,float b,float c):x(a),y(b),z(c){} void operator += (int n) { x += n; y += n; z += n; } void operator = (point p) { memcpy(this,(void*)p,sizeof(*this)); } }; //定义空间的面结构 struct face { point P[3]; void operator +=(int n) { P[0] += n; P[1] += n; P[2] += n; } }; //定义包围盒结构 struct BBox { point Min; point Max; BBox():

文档评论(0)

1亿VIP精品文档

相关文档