moved to inline_geometry namespace they are CreateRenderable....functions.

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2022-06-24 21:36:24 +08:00
parent e381c3efeb
commit f70be8e42c
14 changed files with 1229 additions and 1207 deletions

View File

@ -81,7 +81,7 @@ private:
bool InitScene()
{
ro_sphere=CreateRenderableSphere(db,material_instance->GetVAB(),128);
ro_sphere=inline_geometry::CreateSphere(db,material_instance->GetVAB(),128);
render_root.CreateSubNode(scale(100),db->CreateRenderable(ro_sphere,material_instance,pipeline_solid));

View File

@ -121,22 +121,24 @@ private:
void CreateRenderObject()
{
using namespace inline_geometry;
{
struct AxisCreateInfo aci;
aci.size=GetCameraInfo().zfar;
ro_axis=CreateRenderableAxis(db,axis_mi->GetVAB(),&aci);
ro_axis=CreateAxis(db,axis_mi->GetVAB(),&aci);
}
{
struct CubeCreateInfo cci;
ro_cube=CreateRenderableCube(db,sky_mi->GetVAB(),&cci);
ro_cube=CreateCube(db,sky_mi->GetVAB(),&cci);
}
{
ro_sphere=CreateRenderableSphere(db,envmap_mi->GetVAB(),64);
ro_sphere=CreateSphere(db,envmap_mi->GetVAB(),64);
}
}

View File

@ -273,18 +273,20 @@ private:
void CreateRenderObject(const VAB *vab)
{
using namespace inline_geometry;
{
struct PlaneCreateInfo pci;
ro_plane=CreateRenderablePlane(db,vab,&pci);
ro_plane=CreatePlane(db,vab,&pci);
}
{
struct CubeCreateInfo cci;
ro_cube=CreateRenderableCube(db,vab,&cci);
ro_cube=CreateCube(db,vab,&cci);
}
{
ro_sphere=CreateRenderableSphere(db,vab,64);
ro_sphere=CreateSphere(db,vab,64);
}
{
@ -299,7 +301,7 @@ private:
tci.uv_scale.x=4;
tci.uv_scale.y=1;
ro_torus=CreateRenderableTorus(db,vab,&tci);
ro_torus=CreateTorus(db,vab,&tci);
}
{
@ -309,7 +311,7 @@ private:
cci.radius=10;
cci.numberSlices=32;
ro_cylinder=CreateRenderableCylinder(db,vab,&cci);
ro_cylinder=CreateCylinder(db,vab,&cci);
}
{
@ -320,13 +322,13 @@ private:
cci.numberSlices=128;
cci.numberStacks=32;
ro_cone=CreateRenderableCone(db,vab,&cci);
ro_cone=CreateCone(db,vab,&cci);
}
}
bool InitCompositionRenderable()
{
ro_gbc_plane=CreateRenderableGBufferComposition(db,sp_composition.material_instance->GetVAB());
ro_gbc_plane=inline_geometry::CreateGBufferCompositionRectangle(db,sp_composition.material_instance->GetVAB());
if(!ro_gbc_plane)return(false);
ro_gbc_plane_ri=db->CreateRenderable(ro_gbc_plane,sp_composition.material_instance,sp_composition.pipeline_fan);

View File

@ -64,7 +64,7 @@ private:
void CreateRenderObject()
{
ro_sphere=CreateRenderableSphere(db,envmap_mi->GetVAB(),128);
ro_sphere=inline_geometry::CreateSphere(db,envmap_mi->GetVAB(),128);
}
bool InitUBO()

View File

@ -58,6 +58,8 @@ private:
void CreateRenderObject()
{
using namespace inline_geometry;
struct PlaneGridCreateInfo pgci;
pgci.coord[0]=Vector3f(-100,-100,0);
@ -76,16 +78,16 @@ private:
const VAB *vab=material_instance->GetVAB();
ro_plane_grid[0]=CreateRenderablePlaneGrid(db,vab,&pgci);
ro_plane_grid[0]=CreatePlaneGrid(db,vab,&pgci);
pgci.color.Set(0,0.5,0,1);
pgci.side_color.Set(0,1,0,1);
ro_plane_grid[1]=CreateRenderablePlaneGrid(db,vab,&pgci);
ro_plane_grid[1]=CreatePlaneGrid(db,vab,&pgci);
pgci.color.Set(0,0,0.5,1);
pgci.side_color.Set(0,0,1,1);
ro_plane_grid[2]=CreateRenderablePlaneGrid(db,vab,&pgci);
ro_plane_grid[2]=CreatePlaneGrid(db,vab,&pgci);
}
bool InitScene()

View File

@ -147,12 +147,14 @@ private:
void CreateRenderObject()
{
using namespace inline_geometry;
{
struct AxisCreateInfo aci;
aci.size=200;
ro_axis=CreateRenderableAxis(db,axis_mi->GetVAB(),&aci);
ro_axis=CreateAxis(db,axis_mi->GetVAB(),&aci);
}
const VAB *vab=material_instance->GetVAB();
@ -164,11 +166,11 @@ private:
cci.tex_coord=true;
cci.color_type=CubeCreateInfo::ColorType::SameColor;
cci.color[0]=Vector4f(1,1,1,1);
ro_cube=CreateRenderableCube(db,vab,&cci);
ro_cube=CreateCube(db,vab,&cci);
}
{
ro_sphere=CreateRenderableSphere(db,vab,64);
ro_sphere=CreateSphere(db,vab,64);
}
{
@ -183,7 +185,7 @@ private:
tci.uv_scale.x=4;
tci.uv_scale.y=1;
ro_torus=CreateRenderableTorus(db,vab,&tci);
ro_torus=CreateTorus(db,vab,&tci);
}
{
@ -193,7 +195,7 @@ private:
cci.radius=10;
cci.numberSlices=32;
ro_cylinder=CreateRenderableCylinder(db,vab,&cci);
ro_cylinder=CreateCylinder(db,vab,&cci);
}
{
@ -204,7 +206,7 @@ private:
cci.numberSlices=128;
cci.numberStacks=32;
ro_cone=CreateRenderableCone(db,vab,&cci);
ro_cone=CreateCone(db,vab,&cci);
}
}

View File

@ -188,7 +188,7 @@ private:
aci.size.Set(1000,1000,1000);
axis_renderable=CreateRenderableAxis(db,mp_line.material,&aci);
axis_renderable=CreateAxis(db,mp_line.material,&aci);
axis_renderable_instance=CreateRenderable(mp_line,axis_renderable);
}
@ -198,7 +198,7 @@ private:
cci.has_color=true;
cci.color.Set(1,1,1,1);
bbox_renderable=CreateRenderableBoundingBox(db,mp_line.material,&cci);
bbox_renderable=CreateBoundingBox(db,mp_line.material,&cci);
bbox_renderable_instance=CreateRenderable(mp_line,bbox_renderable);
}
}

View File

@ -96,6 +96,8 @@ public:
return(false);
{
using namespace inline_geometry;
CircleCreateInfo cci;
cci.center=Vector2f(OFFSCREEN_SIZE*0.5,OFFSCREEN_SIZE*0.5);
@ -105,7 +107,7 @@ public:
cci.center_color=Vector4f(1,1,1,1);
cci.border_color=Vector4f(1,1,1,0);
Primitive *primitive=CreateRenderableCircle(db,os.material_instance->GetVAB(),&cci);
Primitive *primitive=CreateCircle(db,os.material_instance->GetVAB(),&cci);
if(!primitive)return(false);
os.renderable=db->CreateRenderable(primitive,os.material_instance,os.pipeline);
@ -136,12 +138,14 @@ public:
if(!cube.material_instance->BindSampler(DescriptorSetsType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
return(false);
{
{
using namespace inline_geometry;
CubeCreateInfo cci;
cci.tex_coord=true;
Primitive *primitive=CreateRenderableCube(db,cube.material_instance->GetVAB(),&cci);
Primitive *primitive=CreateCube(db,cube.material_instance->GetVAB(),&cci);
if(!primitive)return(false);
cube.renderable=db->CreateRenderable(primitive,cube.material_instance,cube.pipeline);
@ -159,7 +163,7 @@ public:
bool Init()
{
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
//if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
return(false);
SetClearColor(COLOR::MozillaCharcoal);

View File

@ -78,6 +78,8 @@ private:
bool CreateRenderObject()
{
using namespace inline_geometry;
{
struct PlaneGridCreateInfo pgci;
@ -97,7 +99,7 @@ private:
const VAB *vab=material_instance->GetVAB();
ro_plane_grid=CreateRenderablePlaneGrid(db,vab,&pgci);
ro_plane_grid=CreatePlaneGrid(db,vab,&pgci);
}
{

View File

@ -36,7 +36,7 @@ private:
GPUBuffer * ubo_color =nullptr;
GPUBuffer * ubo_sun =nullptr;
Primitive * renderable_object =nullptr;
Primitive * primitive =nullptr;
Pipeline * pipeline =nullptr;
@ -67,7 +67,7 @@ private:
void CreateRenderObject()
{
renderable_object=CreateRenderableSphere(db,material_instance->GetVAB(),40);
primitive=inline_geometry::CreateSphere(db,material_instance->GetVAB(),40);
}
bool InitUBO()
@ -112,7 +112,7 @@ private:
uint count;
float size;
Renderable *ri=db->CreateRenderable(renderable_object,material_instance,pipeline);
Renderable *ri=db->CreateRenderable(primitive,material_instance,pipeline);
for(uint i=0;i<360;i++)
{

View File

@ -90,7 +90,7 @@ private:
{
const VAB *vab=material_instance->GetVAB();
ro_skyphere=CreateRenderableDome(db,vab,64);
ro_skyphere=inline_geometry::CreateDome(db,vab,64);
}
bool InitScene()

View File

@ -77,6 +77,8 @@ private:
void CreateRenderObject()
{
using namespace inline_geometry;
struct PlaneGridCreateInfo pgci;
pgci.coord[0]=Vector3f(-100,-100,0);
@ -95,7 +97,7 @@ private:
const VAB *vab=material_instance->GetVAB();
renderable=CreateRenderablePlaneGrid(db,vab,&pgci);
renderable=CreatePlaneGrid(db,vab,&pgci);
}
bool InitScene()

View File

@ -10,227 +10,230 @@ namespace hgl
{
namespace graph
{
/**
* (/)
*/
struct RectangleCreateInfo
namespace inline_geometry
{
RectScope2f scope;
};//struct RectangleCreateInfo
Primitive *CreateRenderableRectangle(RenderResource *db,const VAB *vab,const RectangleCreateInfo *rci);
/**
*
*/
Primitive *CreateRenderableGBufferComposition(RenderResource *db,const VAB *vab);
/**
* (/线)
*/
struct RoundRectangleCreateInfo:public RectangleCreateInfo
{
float radius; ///<圆角半径
uint32_t round_per; ///<圆角精度
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
Primitive *CreateRenderableRoundRectangle(RenderResource *db,const VAB *vab,const RoundRectangleCreateInfo *rci);
/**
*
*/
struct CircleCreateInfo
{
Vector2f center; ///<圆心坐标
Vector2f radius; ///<半径
uint field_count=8; ///<分段次数
bool has_color =false;
Vector4f center_color; ///<圆心颜色
Vector4f border_color; ///<边缘颜色
};//struct CircleCreateInfo
/**
* 2D圆形(/线)
*/
Primitive *CreateRenderableCircle(RenderResource *db,const VAB *vab,const CircleCreateInfo *cci);
/**
*
*/
struct PlaneGridCreateInfo
{
Vector3f coord[4];
Vector2u step;
Vector2u side_step; //到边界的步数
Color4f color; //一般线条颜色
Color4f side_color; //边界线条颜色
};//struct PlaneGridCreateInfo
/**
* (线)
*/
Primitive *CreateRenderablePlaneGrid(RenderResource *db,const VAB *vab,const PlaneGridCreateInfo *pgci);
struct PlaneCreateInfo
{
Vector2f tile;
public:
PlaneCreateInfo()
/**
* (/)
*/
struct RectangleCreateInfo
{
tile.x=1.0f;
tile.y=1.0f;
}
};//struct PlaneCreateInfo
RectScope2f scope;
};//struct RectangleCreateInfo
/**
* ()
*/
Primitive *CreateRenderablePlane(RenderResource *db,const VAB *vab,const PlaneCreateInfo *pci);
Primitive *CreateRectangle(RenderResource *db,const VAB *vab,const RectangleCreateInfo *rci);
struct CubeCreateInfo
{
bool normal;
bool tangent;
bool tex_coord;
/**
*
*/
Primitive *CreateGBufferCompositionRectangle(RenderResource *db,const VAB *vab);
enum class ColorType
/**
* (/线)
*/
struct RoundRectangleCreateInfo:public RectangleCreateInfo
{
NoColor=0, ///<没有颜色
SameColor, ///<一个颜色
FaceColor, ///<每个面一个颜色(请写入6个颜色值)
VertexColor, ///<每个顶点一个颜色(请写入24个颜色值)
float radius; ///<圆角半径
uint32_t round_per; ///<圆角精度
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
ENUM_CLASS_RANGE(NoColor,VertexColor)
};
Primitive *CreateRoundRectangle(RenderResource *db,const VAB *vab,const RoundRectangleCreateInfo *rci);
ColorType color_type;
Vector4f color[24];
public:
CubeCreateInfo()
/**
*
*/
struct CircleCreateInfo
{
normal=false;
tangent=false;
tex_coord=false;
Vector2f center; ///<圆心坐标
Vector2f radius; ///<半径
uint field_count=8; ///<分段次数
color_type=ColorType::NoColor;
}
};//struct CubeCreateInfo
bool has_color =false;
/**
* ()
*/
Primitive *CreateRenderableCube(RenderResource *db,const VAB *vab,const CubeCreateInfo *cci);
Vector4f center_color; ///<圆心颜色
Vector4f border_color; ///<边缘颜色
};//struct CircleCreateInfo
struct BoundingBoxCreateInfo
{
bool normal;
/**
* 2D圆形(/线)
*/
Primitive *CreateCircle(RenderResource *db,const VAB *vab,const CircleCreateInfo *cci);
enum class ColorType
/**
*
*/
struct PlaneGridCreateInfo
{
NoColor=0, ///<没有颜色
SameColor, ///<一个颜色
VertexColor, ///<每个顶点一个颜色(请写入8个颜色值)
Vector3f coord[4];
Vector2u step;
ENUM_CLASS_RANGE(NoColor,VertexColor)
};
Vector2u side_step; //到边界的步数
ColorType color_type;
Vector4f color[8];
Color4f color; //一般线条颜色
Color4f side_color; //边界线条颜色
};//struct PlaneGridCreateInfo
public:
/**
* (线)
*/
Primitive *CreatePlaneGrid(RenderResource *db,const VAB *vab,const PlaneGridCreateInfo *pgci);
BoundingBoxCreateInfo()
struct PlaneCreateInfo
{
normal=false;
Vector2f tile;
color_type=ColorType::NoColor;
}
};//struct BoundingBoxCreateInfo
public:
/**
* (线)
*/
Primitive *CreateRenderableBoundingBox(RenderResource *db,const VAB *vab,const BoundingBoxCreateInfo *cci);
PlaneCreateInfo()
{
tile.x=1.0f;
tile.y=1.0f;
}
};//struct PlaneCreateInfo
/**
* 0,0,01()
*/
Primitive *CreateRenderableSphere(RenderResource *db,const VAB *vab,const uint numberSlices);
/**
* ()
*/
Primitive *CreatePlane(RenderResource *db,const VAB *vab,const PlaneCreateInfo *pci);
/**
* ()
*/
Primitive *CreateRenderableDome(RenderResource *db,const VAB *vab, const uint numberSlices);
struct TorusCreateInfo
{
float innerRadius,
outerRadius;
uint numberSlices,
numberStacks;
Vector2f uv_scale={1.0,1.0};
};//struct TorusCreateInfo
/**
* ()
*/
Primitive *CreateRenderableTorus(RenderResource *db,const VAB *vab,const TorusCreateInfo *tci);
struct CylinderCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices;
};//struct CylinderCreateInfo
/**
* ()
*/
Primitive *CreateRenderableCylinder(RenderResource *db,const VAB *vab,const CylinderCreateInfo *cci);
struct ConeCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices, //圆切分精度
numberStacks; //柱高层数
};//struct ConeCreateInfo
/**
* ()
*/
Primitive *CreateRenderableCone(RenderResource *db,const VAB *vab,const ConeCreateInfo *cci);
struct AxisCreateInfo
{
float size;
Color4f color[3];
public:
AxisCreateInfo()
struct CubeCreateInfo
{
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
bool normal;
bool tangent;
bool tex_coord;
/**
* 线(线)
*/
Primitive *CreateRenderableAxis(RenderResource *db,const VAB *vab,const AxisCreateInfo *aci);
enum class ColorType
{
NoColor=0, ///<没有颜色
SameColor, ///<一个颜色
FaceColor, ///<每个面一个颜色(请写入6个颜色值)
VertexColor, ///<每个顶点一个颜色(请写入24个颜色值)
ENUM_CLASS_RANGE(NoColor,VertexColor)
};
ColorType color_type;
Vector4f color[24];
public:
CubeCreateInfo()
{
normal=false;
tangent=false;
tex_coord=false;
color_type=ColorType::NoColor;
}
};//struct CubeCreateInfo
/**
* ()
*/
Primitive *CreateCube(RenderResource *db,const VAB *vab,const CubeCreateInfo *cci);
struct BoundingBoxCreateInfo
{
bool normal;
enum class ColorType
{
NoColor=0, ///<没有颜色
SameColor, ///<一个颜色
VertexColor, ///<每个顶点一个颜色(请写入8个颜色值)
ENUM_CLASS_RANGE(NoColor,VertexColor)
};
ColorType color_type;
Vector4f color[8];
public:
BoundingBoxCreateInfo()
{
normal=false;
color_type=ColorType::NoColor;
}
};//struct BoundingBoxCreateInfo
/**
* (线)
*/
Primitive *CreateBoundingBox(RenderResource *db,const VAB *vab,const BoundingBoxCreateInfo *cci);
/**
* 0,0,01()
*/
Primitive *CreateSphere(RenderResource *db,const VAB *vab,const uint numberSlices);
/**
* ()
*/
Primitive *CreateDome(RenderResource *db,const VAB *vab, const uint numberSlices);
struct TorusCreateInfo
{
float innerRadius,
outerRadius;
uint numberSlices,
numberStacks;
Vector2f uv_scale={1.0,1.0};
};//struct TorusCreateInfo
/**
* ()
*/
Primitive *CreateTorus(RenderResource *db,const VAB *vab,const TorusCreateInfo *tci);
struct CylinderCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices;
};//struct CylinderCreateInfo
/**
* ()
*/
Primitive *CreateCylinder(RenderResource *db,const VAB *vab,const CylinderCreateInfo *cci);
struct ConeCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices, //圆切分精度
numberStacks; //柱高层数
};//struct ConeCreateInfo
/**
* ()
*/
Primitive *CreateCone(RenderResource *db,const VAB *vab,const ConeCreateInfo *cci);
struct AxisCreateInfo
{
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
/**
* 线(线)
*/
Primitive *CreateAxis(RenderResource *db,const VAB *vab,const AxisCreateInfo *aci);
}//namespace inline_geometry
}//namespace graph
};//namespace hgl
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE

File diff suppressed because it is too large Load Diff