From 4832e23573edbc44eb5310dc2e394c470c8ef333 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 20 Jun 2020 01:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E5=AE=8C=E5=85=A8=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=9E=8B=E4=BB=A5=E5=8F=8A=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMPlatform | 2 +- example/Vulkan/LoadScene.cpp | 64 ++++++++++++++++++++++++++++++ inc/hgl/graph/data/SceneNodeData.h | 3 +- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/CMPlatform b/CMPlatform index 9b1975a8..984d9698 160000 --- a/CMPlatform +++ b/CMPlatform @@ -1 +1 @@ -Subproject commit 9b1975a8a5c74dfc5189b4d7f23d155b6e15cca8 +Subproject commit 984d9698ef873a08f0c99579e8a9b4bf15e5ce5f diff --git a/example/Vulkan/LoadScene.cpp b/example/Vulkan/LoadScene.cpp index 70660b2f..7a3b1ca4 100644 --- a/example/Vulkan/LoadScene.cpp +++ b/example/Vulkan/LoadScene.cpp @@ -167,6 +167,64 @@ namespace hgl return(true); } + SceneNodeData *LoadNode(const int level) + { + #ifdef _DEBUG + AutoDeleteArray spaces=new char[level+1]; + + memset(spaces,' ',level); + spaces[level]=0; + #endif//_DEBUG + + SceneNodeData *node=new SceneNodeData; + + memcpy(&(node->local_matrix),sp,sizeof(Matrix4f)); + sp+=sizeof(Matrix4f); + + { + const uint8 name_len=*sp++; + + node->name.SetString((char *)sp,name_len); + sp+=name_len; + + LOG_INFO(spaces+UTF8String("Node name: ")+node->name); + } + + { + node->mesh_count=*(uint32 *)sp; + sp+=sizeof(uint32); + + if(node->mesh_count>0) + { + node->mesh_index=(const uint32 *)sp; + + #ifdef _DEBUG + const uint32 *mi=node->mesh_index; + + for(uint i=0;imesh_count;i++) + LOG_INFO(spaces+UTF8String(" ")+UTF8String::valueOf(i)+UTF8String(" : ")+md->mesh_name[*mi++]); + #endif//_DEBUG + + sp+=node->mesh_count*sizeof(uint32); + } + } + + { + const uint32 child_count=*(uint32 *)sp; + sp+=sizeof(uint32); + + if(child_count>0) + { + LOG_INFO(spaces+UTF8String("Sub-node Count: ")+UTF8String::valueOf(child_count)); + + for(uint i=0;isub_nodes.Add(LoadNode(level+1)); + } + } + + return node; + } + public: LoadModelData(uint8 *source,const uint8 *s) @@ -204,6 +262,12 @@ namespace hgl md->mesh_list.Add(mesh); } + LOG_INFO(OS_TEXT("Load Scene Tree")); + + Load(md->bounding_box); + + md->root_node=LoadNode(1); + return(true); } };//struct LoadModelData diff --git a/inc/hgl/graph/data/SceneNodeData.h b/inc/hgl/graph/data/SceneNodeData.h index c811456f..d9394e67 100644 --- a/inc/hgl/graph/data/SceneNodeData.h +++ b/inc/hgl/graph/data/SceneNodeData.h @@ -14,7 +14,8 @@ namespace hgl Matrix4f local_matrix; - List mesh_index; + uint32 mesh_count; + const uint32 *mesh_index; ObjectList sub_nodes; };//struct SceneNodeData