2019-05-24 19:28:27 +08:00
|
|
|
|
#ifndef HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/graph/vulkan/VK.h>
|
|
|
|
|
#include<hgl/math/Vector.h>
|
|
|
|
|
#include<hgl/type/RectScope.h>
|
2019-05-29 21:48:56 +08:00
|
|
|
|
#include<hgl/type/Color4f.h>
|
2019-05-24 19:28:27 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
2019-05-27 15:15:39 +08:00
|
|
|
|
class SceneDB;
|
|
|
|
|
|
2019-05-24 19:28:27 +08:00
|
|
|
|
/**
|
2019-06-24 20:16:50 +08:00
|
|
|
|
* 矩形创建信息(扇形/三角形条)
|
2019-05-24 19:28:27 +08:00
|
|
|
|
*/
|
|
|
|
|
struct RectangleCreateInfo
|
|
|
|
|
{
|
|
|
|
|
RectScope2f scope;
|
2019-05-27 22:48:01 +08:00
|
|
|
|
};//struct RectangleCreateInfo
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
2019-06-17 23:51:17 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableRectangle(SceneDB *db,vulkan::Material *mtl,const RectangleCreateInfo *rci);
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
2019-07-17 16:51:42 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建延迟渲染用全屏平面
|
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableGBufferComposition(SceneDB *db,vulkan::Material *mtl);
|
|
|
|
|
|
2019-05-24 19:28:27 +08:00
|
|
|
|
/**
|
2019-06-25 23:40:09 +08:00
|
|
|
|
* 圆角矩形创建信息(扇形/线圈)
|
2019-05-24 19:28:27 +08:00
|
|
|
|
*/
|
|
|
|
|
struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
|
|
|
|
{
|
2019-05-27 22:48:01 +08:00
|
|
|
|
float radius; ///<圆角半径
|
|
|
|
|
uint32_t round_per; ///<圆角精度
|
|
|
|
|
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
2019-06-17 23:51:17 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableRoundRectangle(SceneDB *db,vulkan::Material *mtl,const RoundRectangleCreateInfo *rci);
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 圆形创建信息
|
|
|
|
|
*/
|
2019-05-27 22:48:01 +08:00
|
|
|
|
struct CircleCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Vector2f center; ///<圆心坐标
|
|
|
|
|
Vector2f radius; ///<半径
|
|
|
|
|
uint field_count; ///<分段次数
|
|
|
|
|
};//struct CircleCreateInfo
|
|
|
|
|
|
2019-06-24 20:16:50 +08:00
|
|
|
|
/**
|
2019-06-25 23:40:09 +08:00
|
|
|
|
* 创建一个2D圆形(扇形/线圈)
|
2019-06-24 20:16:50 +08:00
|
|
|
|
*/
|
2019-06-17 23:51:17 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableCircle(SceneDB *db,vulkan::Material *mtl,const CircleCreateInfo *rci);
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 平面网格创建信息
|
|
|
|
|
*/
|
|
|
|
|
struct PlaneGridCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Vector3f coord[4];
|
|
|
|
|
vec2<uint> step;
|
2019-05-29 21:48:56 +08:00
|
|
|
|
|
|
|
|
|
vec2<uint> side_step; //到边界的步数
|
|
|
|
|
|
|
|
|
|
Color4f color; //一般线条颜色
|
|
|
|
|
Color4f side_color; //边界线条颜色
|
2019-05-27 22:48:01 +08:00
|
|
|
|
};//struct PlaneGridCreateInfo
|
|
|
|
|
|
2019-06-24 20:16:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个平面网格(线条)
|
|
|
|
|
*/
|
2019-06-17 21:59:54 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderablePlaneGrid(SceneDB *db,vulkan::Material *mtl,const PlaneGridCreateInfo *pgci);
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
|
|
|
|
struct PlaneCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Vector2f tile;
|
2019-07-17 16:51:42 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
PlaneCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
tile.Set(1,1);
|
|
|
|
|
}
|
2019-05-27 22:48:01 +08:00
|
|
|
|
};//struct PlaneCreateInfo
|
|
|
|
|
|
2019-06-24 20:16:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个平面(三角形)
|
|
|
|
|
*/
|
2019-06-17 23:51:17 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderablePlane(SceneDB *db,vulkan::Material *mtl,const PlaneCreateInfo *pci);
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
|
|
|
|
struct CubeCreateInfo
|
|
|
|
|
{
|
2019-06-24 20:16:50 +08:00
|
|
|
|
Vector3f center;
|
|
|
|
|
Vector3f size;
|
2019-05-27 22:48:01 +08:00
|
|
|
|
Vector2f tile;
|
2019-06-24 20:16:50 +08:00
|
|
|
|
|
|
|
|
|
public:
|
2020-06-03 17:39:36 +08:00
|
|
|
|
|
|
|
|
|
void Set(const AABB &box)
|
|
|
|
|
{
|
|
|
|
|
center=box.CenterPoint().xyz();
|
|
|
|
|
size=box.HalfSize().xyz();
|
|
|
|
|
}
|
2019-06-24 20:16:50 +08:00
|
|
|
|
|
|
|
|
|
CubeCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
center.Set(0,0,0);
|
2019-07-06 16:46:19 +08:00
|
|
|
|
size.Set(1,1,1);
|
2019-06-24 20:16:50 +08:00
|
|
|
|
tile.Set(1,1);
|
|
|
|
|
}
|
2020-06-03 17:39:36 +08:00
|
|
|
|
|
|
|
|
|
CubeCreateInfo(const AABB &box)
|
|
|
|
|
{
|
|
|
|
|
Set(box);
|
|
|
|
|
tile.Set(1,1);
|
|
|
|
|
}
|
2019-05-27 22:48:01 +08:00
|
|
|
|
};//struct CubeCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
2019-06-24 20:16:50 +08:00
|
|
|
|
* 创建一个立方体(三角形)
|
2019-05-27 22:48:01 +08:00
|
|
|
|
*/
|
2019-06-17 21:59:54 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableCube(SceneDB *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
2019-06-17 10:37:59 +08:00
|
|
|
|
|
2019-05-27 22:48:01 +08:00
|
|
|
|
/**
|
2019-06-24 20:16:50 +08:00
|
|
|
|
* 创建一个绑定盒(线条)
|
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableBoundingBox(SceneDB *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个球心坐标为0,0,0,半径为1的球体(三角形)
|
2019-05-27 22:48:01 +08:00
|
|
|
|
*/
|
2019-06-17 10:37:59 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableSphere(SceneDB *db,vulkan::Material *mtl,const uint numberSlices);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
|
|
|
|
struct DomeCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float radius;
|
|
|
|
|
uint numberSlices;
|
|
|
|
|
};//struct DomeCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
2019-06-24 20:16:50 +08:00
|
|
|
|
* 创建一个穹顶(三角形)
|
2019-06-17 20:25:44 +08:00
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableDome(SceneDB *db,vulkan::Material *mtl, const DomeCreateInfo *);
|
|
|
|
|
|
|
|
|
|
struct TorusCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float innerRadius,
|
|
|
|
|
outerRadius;
|
|
|
|
|
|
|
|
|
|
uint numberSlices,
|
|
|
|
|
numberStacks;
|
|
|
|
|
};//struct TorusCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
2019-06-24 20:16:50 +08:00
|
|
|
|
* 创建一个圆环(三角形)
|
2019-06-17 20:25:44 +08:00
|
|
|
|
*/
|
2019-06-24 20:16:50 +08:00
|
|
|
|
vulkan::Renderable *CreateRenderableTorus(SceneDB *db,vulkan::Material *mtl,const TorusCreateInfo *tci);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
|
|
|
|
struct CylinderCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float halfExtend, //高度
|
|
|
|
|
radius; //半径
|
|
|
|
|
uint numberSlices;
|
|
|
|
|
};//struct CylinderCreateInfo
|
|
|
|
|
|
2019-06-24 20:16:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个圆柱(三角形)
|
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableCylinder(SceneDB *db,vulkan::Material *mtl,const CylinderCreateInfo *cci);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
|
|
|
|
struct ConeCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float halfExtend, //高度
|
|
|
|
|
radius; //半径
|
|
|
|
|
uint numberSlices, //圆切分精度
|
|
|
|
|
numberStacks; //柱高层数
|
|
|
|
|
};//struct ConeCreateInfo
|
|
|
|
|
|
2019-06-24 20:16:50 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个圆锥(三角形)
|
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableCone(SceneDB *db,vulkan::Material *mtl,const ConeCreateInfo *cci);
|
|
|
|
|
|
|
|
|
|
struct AxisCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Vector3f root;
|
|
|
|
|
Vector3f size;
|
|
|
|
|
Color4f color[3];
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-06-03 17:39:36 +08:00
|
|
|
|
void RestartColor()
|
2019-06-24 20:16:50 +08:00
|
|
|
|
{
|
|
|
|
|
color[0].Set(1,0,0,1);
|
|
|
|
|
color[1].Set(0,1,0,1);
|
|
|
|
|
color[2].Set(0,0,1,1);
|
|
|
|
|
}
|
2020-06-03 17:39:36 +08:00
|
|
|
|
|
|
|
|
|
void Set(const AABB &box)
|
|
|
|
|
{
|
|
|
|
|
root=box.CenterPoint().xyz();
|
|
|
|
|
size=box.HalfSize().xyz();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AxisCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
root.Set(0,0,0);
|
|
|
|
|
size.Set(1,1,1);
|
|
|
|
|
RestartColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AxisCreateInfo(const AABB &box)
|
|
|
|
|
{
|
|
|
|
|
Set(box);
|
|
|
|
|
RestartColor();
|
|
|
|
|
}
|
2019-06-24 20:16:50 +08:00
|
|
|
|
};//struct AxisCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个坐标线(线条)
|
|
|
|
|
*/
|
|
|
|
|
vulkan::Renderable *CreateRenderableAxis(SceneDB *db,vulkan::Material *mtl,const AxisCreateInfo *aci);
|
2019-05-24 19:28:27 +08:00
|
|
|
|
}//namespace graph
|
|
|
|
|
};//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|