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);