From 043d5608d02de43f756a9b2a8721118b6104d04e Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 3 Jun 2020 17:39:36 +0800 Subject: [PATCH] =?UTF-8?q?AxisCreateInfo/CubeCreateInfo=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=94=AF=E6=8C=81AABB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/LoadModel.cpp | 10 ++------- example/Vulkan/SimplePBRForward.cpp | 10 ++------- inc/hgl/graph/InlineGeometry.h | 35 ++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/example/Vulkan/LoadModel.cpp b/example/Vulkan/LoadModel.cpp index 8be1371e..f0181df9 100644 --- a/example/Vulkan/LoadModel.cpp +++ b/example/Vulkan/LoadModel.cpp @@ -131,20 +131,14 @@ private: } { - AxisCreateInfo aci; - - aci.root=model_data->bounding_box.CenterPoint().xyz(); - aci.size=model_data->bounding_box.HalfSize().xyz(); + AxisCreateInfo aci(model_data->bounding_box); axis_renderable=CreateRenderableAxis(db,material,&aci); axis_renderable_instance=db->CreateRenderableInstance(pipeline_lines,material_instance,axis_renderable); } { - CubeCreateInfo cci; - - cci.center=model_data->bounding_box.CenterPoint().xyz(); - cci.size=model_data->bounding_box.Size().xyz(); + CubeCreateInfo cci(model_data->bounding_box); bbox_renderable=CreateRenderableBoundingBox(db,material,&cci); bbox_renderable_instance=db->CreateRenderableInstance(pipeline_lines,material_instance,bbox_renderable); diff --git a/example/Vulkan/SimplePBRForward.cpp b/example/Vulkan/SimplePBRForward.cpp index 92e5489b..330f3ecb 100644 --- a/example/Vulkan/SimplePBRForward.cpp +++ b/example/Vulkan/SimplePBRForward.cpp @@ -130,20 +130,14 @@ private: } { - AxisCreateInfo aci; - - aci.root=model_data->bounding_box.CenterPoint().xyz(); - aci.size=model_data->bounding_box.HalfSize().xyz(); + AxisCreateInfo aci(model_data->bounding_box); axis_renderable=CreateRenderableAxis(db,material,&aci); axis_renderable_instance=db->CreateRenderableInstance(pipeline_lines,material_instance,axis_renderable); } { - CubeCreateInfo cci; - - cci.center=model_data->bounding_box.CenterPoint().xyz(); - cci.size=model_data->bounding_box.Size().xyz(); + CubeCreateInfo cci(model_data->bounding_box); bbox_renderable=CreateRenderableBoundingBox(db,material,&cci); bbox_renderable_instance=db->CreateRenderableInstance(pipeline_lines,material_instance,bbox_renderable); diff --git a/inc/hgl/graph/InlineGeometry.h b/inc/hgl/graph/InlineGeometry.h index cbd7e918..507eb196 100644 --- a/inc/hgl/graph/InlineGeometry.h +++ b/inc/hgl/graph/InlineGeometry.h @@ -95,6 +95,12 @@ namespace hgl Vector2f tile; public: + + void Set(const AABB &box) + { + center=box.CenterPoint().xyz(); + size=box.HalfSize().xyz(); + } CubeCreateInfo() { @@ -102,6 +108,12 @@ namespace hgl size.Set(1,1,1); tile.Set(1,1); } + + CubeCreateInfo(const AABB &box) + { + Set(box); + tile.Set(1,1); + } };//struct CubeCreateInfo /** @@ -177,13 +189,30 @@ namespace hgl public: + void RestartColor() + { + color[0].Set(1,0,0,1); + color[1].Set(0,1,0,1); + color[2].Set(0,0,1,1); + } + + void Set(const AABB &box) + { + root=box.CenterPoint().xyz(); + size=box.HalfSize().xyz(); + } + AxisCreateInfo() { root.Set(0,0,0); size.Set(1,1,1); - color[0].Set(1,0,0,1); - color[1].Set(0,1,0,1); - color[2].Set(0,0,1,1); + RestartColor(); + } + + AxisCreateInfo(const AABB &box) + { + Set(box); + RestartColor(); } };//struct AxisCreateInfo