From a180970eb6b4bfb6a77fb99a1697972fc78301a9 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 15 Jun 2025 02:03:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BBauto=5Fmerge=5Fmaterial=5Fins?= =?UTF-8?q?tance,BillboardTest,PlaneGrid3D,RayPicking=E5=9B=9B=E4=B8=AA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=8C=83=E4=BE=8B=E5=88=B0=E6=96=B0=E7=9A=84?= =?UTF-8?q?Component=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Basic/BillboardTest.cpp | 19 +++---------------- .../Basic/auto_merge_material_instance.cpp | 3 ++- example/Gizmo/PlaneGrid3D.cpp | 3 ++- example/Gizmo/RayPicking.cpp | 3 ++- inc/hgl/WorkObject.h | 6 ++++++ 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/example/Basic/BillboardTest.cpp b/example/Basic/BillboardTest.cpp index 61229765..a99b537d 100644 --- a/example/Basic/BillboardTest.cpp +++ b/example/Basic/BillboardTest.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using namespace hgl; using namespace hgl::graph; @@ -112,19 +113,6 @@ private: return(true); } - SceneNode *CreateSceneNode(Primitive *r,MaterialInstance *mi,Pipeline *p) - { - Mesh *ri=db->CreateMesh(r,mi,p); - - if(!ri) - { - LOG_ERROR(OS_TEXT("Create Mesh failed.")); - return(nullptr); - } - - return(new SceneNode(ri)); - } - bool CreateRenderObject() { using namespace inline_geometry; @@ -164,9 +152,8 @@ private: { SceneNode *scene_root=GetSceneRoot(); //取得缺省场景根节点 - scene_root->Add(CreateSceneNode(prim_plane_grid,mi_plane_grid,pipeline_plane_grid)); - - scene_root->Add(new SceneNode(ro_billboard)); + CreateComponent(scene_root,db->CreateMesh(prim_plane_grid,mi_plane_grid,pipeline_plane_grid)); + CreateComponent(scene_root,ro_billboard); CameraControl *camera_control=GetCameraControl(); diff --git a/example/Basic/auto_merge_material_instance.cpp b/example/Basic/auto_merge_material_instance.cpp index b18cecbc..4c0f6fb0 100644 --- a/example/Basic/auto_merge_material_instance.cpp +++ b/example/Basic/auto_merge_material_instance.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace hgl; using namespace hgl::graph; @@ -93,7 +94,7 @@ private: mat=rotate(deg2rad(TRI_ROTATE_ANGLE*i),AxisVector::Z); - scene_root->Add(new SceneNode(mat,render_obj[i].mesh)); + CreateComponent(mat,scene_root,render_obj[i].mesh); } return(true); diff --git a/example/Gizmo/PlaneGrid3D.cpp b/example/Gizmo/PlaneGrid3D.cpp index 3e5fdd58..4db3d5ee 100644 --- a/example/Gizmo/PlaneGrid3D.cpp +++ b/example/Gizmo/PlaneGrid3D.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace hgl; using namespace hgl::graph; @@ -83,7 +84,7 @@ private: if(!ri) return; - parent_node->Add(new SceneNode(mat,ri)); + CreateComponent(mat,parent_node,ri); } bool InitScene() diff --git a/example/Gizmo/RayPicking.cpp b/example/Gizmo/RayPicking.cpp index 36309bbc..5fe3af5f 100644 --- a/example/Gizmo/RayPicking.cpp +++ b/example/Gizmo/RayPicking.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace hgl; using namespace hgl::graph; @@ -100,7 +101,7 @@ private: return(nullptr); } - parent_node->Add(new SceneNode(ri)); + CreateComponent(parent_node,ri); return ri; } diff --git a/inc/hgl/WorkObject.h b/inc/hgl/WorkObject.h index e11c5465..2262d3d5 100644 --- a/inc/hgl/WorkObject.h +++ b/inc/hgl/WorkObject.h @@ -156,6 +156,9 @@ namespace hgl return(nullptr); } + /** + * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 + */ parent_node->AttachComponent(c); //将组件附加到父节点 return c; @@ -178,6 +181,9 @@ namespace hgl return(nullptr); } + /** + * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 + */ parent_node->AttachComponent(c); //将组件附加到父节点 c->graph::SceneOrient::SetLocalMatrix(mat);