增加多种内嵌几何体

This commit is contained in:
hyzboy 2019-06-17 20:25:44 +08:00
parent 57a5dede7a
commit c84b522703
4 changed files with 944 additions and 245 deletions

View File

@ -26,10 +26,15 @@ private:
vulkan::Renderable *ro_plane_grid,
*ro_cube,
*ro_sphere;
*ro_sphere,
*ro_dome,
*ro_torus,
*ro_cylinder,
*ro_cone;
vulkan::Pipeline *pipeline_line =nullptr,
*pipeline_solid =nullptr;
vulkan::Pipeline *pipeline_line =nullptr,
*pipeline_solid =nullptr,
*pipeline_twoside =nullptr;
private:
@ -77,6 +82,48 @@ private:
{
ro_sphere=CreateRenderableSphere(db,material,16);
}
{
DomeCreateInfo dci;
dci.radius=100;
dci.numberSlices=16;
ro_dome=CreateRenderableDome(db,material,&dci);
}
{
TorusCreateInfo tci;
tci.innerRadius=50;
tci.outerRadius=70;
tci.numberSlices=32;
tci.numberStacks=16;
ro_torus=CreateRenderableTorus(db,material,&tci);
}
{
CylinderCreateInfo cci;
cci.halfExtend=10;
cci.radius=10;
cci.numberSlices=16;
ro_cylinder=CreateRenderableCylinder(db,material,&cci);
}
{
ConeCreateInfo cci;
cci.halfExtend=10;
cci.radius=10;
cci.numberSlices=16;
cci.numberStacks=1;
ro_cone=CreateRenderableCone(db,material,&cci);
}
}
bool InitUBO()
@ -99,9 +146,14 @@ private:
db->Add(pipeline_line);
pipeline_creater->Set(PRIM_TRIANGLES);
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_LINE);
pipeline_solid=pipeline_creater->Create();
db->Add(pipeline_solid);
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
pipeline_twoside=pipeline_creater->Create();
db->Add(pipeline_twoside);
delete pipeline_creater;
if(!pipeline_line)
@ -116,8 +168,12 @@ private:
bool InitScene()
{
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_cube ),translate(-10,0,0)*scale(10,10,10));
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_sphere ),translate( 10,0,0)*scale(10,10,10));
render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_dome));
render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_torus));
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cube ),translate(-10, 0,10)*scale(10,10,10));
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_sphere ),translate( 10, 0,10)*scale(10,10,10));
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cylinder ),translate( 0, 16, 0));
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cone ),translate( 0,-16, 0));
render_root.RefreshMatrix();
render_root.ExpendToList(&render_list);

View File

@ -81,6 +81,50 @@ namespace hgl
* 0,0,01
*/
vulkan::Renderable *CreateRenderableSphere(SceneDB *db,vulkan::Material *mtl,const uint numberSlices);
struct DomeCreateInfo
{
float radius;
uint numberSlices;
};//struct DomeCreateInfo
/**
*
*/
vulkan::Renderable *CreateRenderableDome(SceneDB *db,vulkan::Material *mtl, const DomeCreateInfo *);
struct TorusCreateInfo
{
float innerRadius,
outerRadius;
uint numberSlices,
numberStacks;
};//struct TorusCreateInfo
/**
*
*/
vulkan::Renderable *CreateRenderableTorus(SceneDB *db,vulkan::Material *mtl,TorusCreateInfo *tci);
struct CylinderCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices;
};//struct CylinderCreateInfo
vulkan::Renderable *CreateRenderableCylinder(SceneDB *db,vulkan::Material *mtl,CylinderCreateInfo *cci);
struct ConeCreateInfo
{
float halfExtend, //高度
radius; //半径
uint numberSlices, //圆切分精度
numberStacks; //柱高层数
};//struct ConeCreateInfo
vulkan::Renderable *CreateRenderableCone(SceneDB *db,vulkan::Material *mtl,ConeCreateInfo *cci);
}//namespace graph
};//namespace hgl
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE

View File

@ -37,6 +37,13 @@ namespace hgl
virtual ~VertexBufferBase()=default;
void BufferData(const T *ptr)
{
if(!ptr)return;
memcpy(mem_type,ptr,total_bytes);
}
/**
*
* @param offset 访

File diff suppressed because it is too large Load Diff