部分内置几何体增加BoundingBox数据计算
This commit is contained in:
parent
585fd41966
commit
15da48eede
@ -28,6 +28,12 @@ public:
|
||||
Primitive(const AnsiString &pn,PrimitiveData *pd);
|
||||
virtual ~Primitive();
|
||||
|
||||
void SetBoundingBox(const AABB &bb) { bounding_box=bb; } ///<设置包围盒
|
||||
void SetBoundingBox(const Vector3f &box_min,const Vector3f &box_max)
|
||||
{
|
||||
bounding_box.SetMinMax(box_min,box_max);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
const AnsiString & GetName ()const{ return prim_name; }
|
||||
|
@ -7,12 +7,8 @@
|
||||
#include<hgl/graph/VKShaderModule.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
|
||||
namespace hgl
|
||||
namespace hgl::graph::inline_geometry
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
namespace inline_geometry
|
||||
{
|
||||
Primitive *CreateRectangle(PrimitiveCreater *pc,const RectangleCreateInfo *rci)
|
||||
{
|
||||
if(!pc)return(nullptr);
|
||||
@ -451,7 +447,17 @@ namespace hgl
|
||||
|
||||
pc->WriteIBO(indices);
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
{
|
||||
AABB aabb;
|
||||
|
||||
aabb.SetMinMax(Vector3f(-0.5f,-0.5f,0.0f),Vector3f(0.5f,0.5f,0.0f));
|
||||
|
||||
p->SetBoundingBox(aabb);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
Primitive *CreateCube(PrimitiveCreater *pc,const CubeCreateInfo *cci)
|
||||
@ -551,9 +557,13 @@ namespace hgl
|
||||
}
|
||||
}
|
||||
|
||||
//pc->CreateIBO16(6*2*3,indices);
|
||||
pc->WriteIBO(indices);
|
||||
return pc->Create();
|
||||
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
p->SetBoundingBox(Vector3f(-0.5f,-0.5f,-0.5f),Vector3f(0.5f,0.5f,0.5f));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -734,7 +744,15 @@ namespace hgl
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
{
|
||||
AABB aabb;
|
||||
aabb.SetMinMax(Vector3f(-1.0f,-1.0f,-1.0f),Vector3f(1.0f,1.0f,1.0f));
|
||||
p->SetBoundingBox(aabb);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
Primitive *CreateDome(PrimitiveCreater *pc,const uint numberSlices)
|
||||
@ -828,7 +846,17 @@ namespace hgl
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
{
|
||||
AABB box;
|
||||
|
||||
box.SetMinMax(Vector3f(-1.0f,-1.0f,-1.0f),Vector3f(1.0f,1.0f,1.0f)); //这个不对,待查
|
||||
|
||||
p->SetBoundingBox(box);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -979,7 +1007,23 @@ namespace hgl
|
||||
if(index_type==IndexType::U8 )CreateTorusIndices<uint8 >(pc,tci->numberSlices,tci->numberStacks);else
|
||||
return(nullptr);
|
||||
}
|
||||
return pc->Create();
|
||||
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
{
|
||||
AABB aabb;
|
||||
|
||||
// Calculate bounding box for the torus
|
||||
float maxExtent = centerRadius + torusRadius;
|
||||
float minExtent = centerRadius - torusRadius;
|
||||
|
||||
aabb.SetMinMax(Vector3f(-maxExtent, -maxExtent, -torusRadius),
|
||||
Vector3f( maxExtent, maxExtent, torusRadius)); //也许不对,待测试
|
||||
|
||||
p->SetBoundingBox(aabb);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -1216,7 +1260,12 @@ namespace hgl
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
p->SetBoundingBox( Vector3f(-cci->radius,-cci->radius,-cci->halfExtend),
|
||||
Vector3f( cci->radius, cci->radius, cci->halfExtend));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -1391,7 +1440,12 @@ namespace hgl
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
p->SetBoundingBox(Vector3f(-cci->radius,-cci->radius,-cci->halfExtend),
|
||||
Vector3f( cci->radius, cci->radius, cci->halfExtend));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
Primitive *CreateAxis(PrimitiveCreater *pc,const AxisCreateInfo *aci)
|
||||
@ -1418,7 +1472,11 @@ namespace hgl
|
||||
vertex->Write(0,0,0);color->Write(aci->color[2]);
|
||||
vertex->Write(0,0,s);color->Write(aci->color[2]);
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
p->SetBoundingBox(Vector3f(0,0,0),Vector3f(s,s,s));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
Primitive *CreateBoundingBox(PrimitiveCreater *pc,const BoundingBoxCreateInfo *cci)
|
||||
@ -1469,8 +1527,11 @@ namespace hgl
|
||||
|
||||
pc->WriteIBO<uint16>(indices);
|
||||
|
||||
return pc->Create();
|
||||
Primitive *p=pc->Create();
|
||||
|
||||
p->SetBoundingBox( Vector3f(-0.5,-0.5,-0.5),
|
||||
Vector3f( 0.5, 0.5, 0.5));
|
||||
|
||||
return p;
|
||||
}
|
||||
}//namespace inline_geometry
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
}//namespace hgl::graph::inline_geometry
|
||||
|
Loading…
x
Reference in New Issue
Block a user