尝试制作StaticMeshComponent

This commit is contained in:
2025-06-14 04:13:49 +08:00
parent 8ee9cdc396
commit edaf5aa3ca
6 changed files with 71 additions and 10 deletions

View File

@@ -5,6 +5,8 @@
#include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/mtl/Material2DCreateConfig.h>
#include<hgl/component/StaticMeshComponent.h>
using namespace hgl;
using namespace hgl::graph;
@@ -40,6 +42,8 @@ private:
Pipeline * pipeline =nullptr;
StaticMeshComponent *sm_component=nullptr;
private:
bool InitMaterial()
@@ -87,7 +91,11 @@ private:
SceneNode *scene_root=GetSceneRoot(); ///<取得场景根节点
auto manager=StaticMeshComponentManager::GetDefaultManager();
sm_component=manager->CreateStaticMeshComponent(mesh_triangle);
scene_root->AttachComponent(sm_component);
scene_root->Add(new SceneNode(mesh_triangle));
@@ -98,6 +106,11 @@ public:
using WorkObject::WorkObject;
~TestApp()
{
SAFE_CLEAR(sm_component);
}
bool Init() override
{
if(!InitMaterial())