2019-05-24 19:28:27 +08:00
|
|
|
|
#ifndef HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2019-05-24 19:28:27 +08:00
|
|
|
|
#include<hgl/math/Vector.h>
|
|
|
|
|
#include<hgl/type/RectScope.h>
|
2023-09-29 02:59:10 +08:00
|
|
|
|
#include<hgl/type/Size2.h>
|
2023-02-19 19:28:47 +08:00
|
|
|
|
#include<hgl/color/Color4f.h>
|
2021-09-24 01:53:44 +08:00
|
|
|
|
#include<hgl/graph/AABB.h>
|
2019-05-24 19:28:27 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
2024-05-25 04:11:38 +08:00
|
|
|
|
class PrimitiveCreater;
|
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
namespace inline_geometry
|
2019-05-24 19:28:27 +08:00
|
|
|
|
{
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 矩形创建信息(扇形/三角形条)
|
|
|
|
|
*/
|
|
|
|
|
struct RectangleCreateInfo
|
|
|
|
|
{
|
|
|
|
|
RectScope2f scope;
|
|
|
|
|
};//struct RectangleCreateInfo
|
2019-07-17 16:51:42 +08:00
|
|
|
|
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateRectangle(PrimitiveCreater *pc,const RectangleCreateInfo *rci);
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建延迟渲染用全屏平面
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateGBufferCompositionRectangle(PrimitiveCreater *pc);
|
2019-05-24 19:28:27 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 圆角矩形创建信息(扇形/线圈)
|
|
|
|
|
*/
|
|
|
|
|
struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float radius; ///<圆角半径
|
|
|
|
|
uint32_t round_per; ///<圆角精度
|
|
|
|
|
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
2020-10-19 22:24:00 +08:00
|
|
|
|
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateRoundRectangle(PrimitiveCreater *pc,const RoundRectangleCreateInfo *rci);
|
2020-10-19 22:24:00 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 圆形创建信息
|
|
|
|
|
*/
|
|
|
|
|
struct CircleCreateInfo
|
|
|
|
|
{
|
|
|
|
|
Vector2f center; ///<圆心坐标
|
|
|
|
|
Vector2f radius; ///<半径
|
|
|
|
|
uint field_count=8; ///<分段次数
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
bool has_color =false;
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
Vector4f center_color; ///<圆心颜色
|
|
|
|
|
Vector4f border_color; ///<边缘颜色
|
|
|
|
|
};//struct CircleCreateInfo
|
2019-05-29 21:48:56 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个2D圆形(扇形/线圈)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateCircle(PrimitiveCreater *pc,const CircleCreateInfo *cci);
|
2019-05-29 21:48:56 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
2023-09-29 02:59:10 +08:00
|
|
|
|
* 平面网格创建信息<br>
|
|
|
|
|
* 会创建一个在XY平面上居中的网格,单个格子尺寸为1。
|
2022-06-24 21:36:24 +08:00
|
|
|
|
*/
|
|
|
|
|
struct PlaneGridCreateInfo
|
|
|
|
|
{
|
2023-09-29 02:59:10 +08:00
|
|
|
|
Size2u grid_size; ///<格子数量
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
2023-09-29 02:59:10 +08:00
|
|
|
|
Size2u sub_count; ///<细分格子数量
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
2024-07-01 02:57:33 +08:00
|
|
|
|
uint8 lum; ///<一般线条亮度
|
|
|
|
|
uint8 sub_lum; ///<细分及边界线条亮度
|
2022-06-24 21:36:24 +08:00
|
|
|
|
};//struct PlaneGridCreateInfo
|
2019-07-17 16:51:42 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个平面网格(线条)
|
|
|
|
|
*/
|
2024-07-01 02:57:33 +08:00
|
|
|
|
Primitive *CreatePlaneGrid2D(PrimitiveCreater *pc,const PlaneGridCreateInfo *pgci); //创建一个平面网格(线条)
|
|
|
|
|
|
|
|
|
|
Primitive *CreatePlaneGrid3D(PrimitiveCreater *pc,const PlaneGridCreateInfo *pgci);
|
2019-07-17 16:51:42 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个平面(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreatePlane(PrimitiveCreater *pc);
|
2019-06-24 20:16:50 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
struct CubeCreateInfo
|
2022-01-10 20:28:02 +08:00
|
|
|
|
{
|
2022-06-24 21:36:24 +08:00
|
|
|
|
bool normal;
|
|
|
|
|
bool tangent;
|
|
|
|
|
bool tex_coord;
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
enum class ColorType
|
|
|
|
|
{
|
|
|
|
|
NoColor=0, ///<没有颜色
|
|
|
|
|
SameColor, ///<一个颜色
|
|
|
|
|
FaceColor, ///<每个面一个颜色(请写入6个颜色值)
|
|
|
|
|
VertexColor, ///<每个顶点一个颜色(请写入24个颜色值)
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
ENUM_CLASS_RANGE(NoColor,VertexColor)
|
|
|
|
|
};
|
2020-06-20 15:43:38 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
ColorType color_type;
|
|
|
|
|
Vector4f color[24];
|
2021-09-24 01:53:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
public:
|
2021-09-24 01:53:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
CubeCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
normal=false;
|
|
|
|
|
tangent=false;
|
|
|
|
|
tex_coord=false;
|
2019-05-27 22:48:01 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
color_type=ColorType::NoColor;
|
|
|
|
|
}
|
|
|
|
|
};//struct CubeCreateInfo
|
2021-09-24 01:53:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个立方体(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateCube(PrimitiveCreater *pc,const CubeCreateInfo *cci);
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
struct BoundingBoxCreateInfo
|
2022-01-10 20:28:02 +08:00
|
|
|
|
{
|
2022-06-24 21:36:24 +08:00
|
|
|
|
bool normal;
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
enum class ColorType
|
|
|
|
|
{
|
|
|
|
|
NoColor=0, ///<没有颜色
|
|
|
|
|
SameColor, ///<一个颜色
|
|
|
|
|
VertexColor, ///<每个顶点一个颜色(请写入8个颜色值)
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
ENUM_CLASS_RANGE(NoColor,VertexColor)
|
|
|
|
|
};
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
ColorType color_type;
|
|
|
|
|
Vector4f color[8];
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
public:
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
BoundingBoxCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
normal=false;
|
2022-01-10 20:28:02 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
color_type=ColorType::NoColor;
|
|
|
|
|
}
|
|
|
|
|
};//struct BoundingBoxCreateInfo
|
2021-09-24 01:53:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个绑定盒(线条)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateBoundingBox(PrimitiveCreater *pc,const BoundingBoxCreateInfo *cci);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个球心坐标为0,0,0,半径为1的球体(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateSphere(PrimitiveCreater *,const uint numberSlices);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个穹顶(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateDome(PrimitiveCreater *pc, const uint numberSlices);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
struct TorusCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float innerRadius,
|
|
|
|
|
outerRadius;
|
2020-10-22 21:23:35 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
uint numberSlices,
|
|
|
|
|
numberStacks;
|
2021-09-24 01:53:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
Vector2f uv_scale={1.0,1.0};
|
|
|
|
|
};//struct TorusCreateInfo
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个圆环(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateTorus(PrimitiveCreater *pc,const TorusCreateInfo *tci);
|
2019-06-17 20:25:44 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
struct CylinderCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float halfExtend, //高度
|
|
|
|
|
radius; //半径
|
|
|
|
|
uint numberSlices;
|
|
|
|
|
};//struct CylinderCreateInfo
|
2019-06-24 20:16:50 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个圆柱(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateCylinder(PrimitiveCreater *,const CylinderCreateInfo *cci);
|
2019-06-24 20:16:50 +08:00
|
|
|
|
|
2022-06-24 21:36:24 +08:00
|
|
|
|
struct ConeCreateInfo
|
|
|
|
|
{
|
|
|
|
|
float halfExtend, //高度
|
|
|
|
|
radius; //半径
|
|
|
|
|
uint numberSlices, //圆切分精度
|
|
|
|
|
numberStacks; //柱高层数
|
|
|
|
|
};//struct ConeCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个圆锥(三角形)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateCone(PrimitiveCreater *,const ConeCreateInfo *cci);
|
2022-06-24 21:36:24 +08:00
|
|
|
|
|
|
|
|
|
struct AxisCreateInfo
|
2019-06-24 20:16:50 +08:00
|
|
|
|
{
|
2022-06-24 21:36:24 +08:00
|
|
|
|
float size;
|
|
|
|
|
Color4f color[3];
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
AxisCreateInfo()
|
|
|
|
|
{
|
|
|
|
|
size=1.0f;
|
|
|
|
|
color[0].Set(1,0,0,1);
|
|
|
|
|
color[1].Set(0,1,0,1);
|
|
|
|
|
color[2].Set(0,0,1,1);
|
|
|
|
|
}
|
|
|
|
|
};//struct AxisCreateInfo
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个坐标线(线条)
|
|
|
|
|
*/
|
2024-05-25 04:11:38 +08:00
|
|
|
|
Primitive *CreateAxis(PrimitiveCreater *pc,const AxisCreateInfo *aci);
|
2022-06-24 21:36:24 +08:00
|
|
|
|
}//namespace inline_geometry
|
2019-05-24 19:28:27 +08:00
|
|
|
|
}//namespace graph
|
|
|
|
|
};//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|