diff --git a/cpp_src/db_ops.cpp b/cpp_src/db_ops.cpp index ad88cb0..d3c892e 100644 --- a/cpp_src/db_ops.cpp +++ b/cpp_src/db_ops.cpp @@ -28,6 +28,26 @@ sqlite3 *create_db(const char *db_path, bool overwrite_file) void create_tables(sqlite3 *db) { + const char *sql_nodes = R" + CREATE TABLE IF NOT EXISTS nodes ( + id INTEGER PRIMARY KEY, + unique_id INTEGER NOT NULL UNIQUE, + parent_id INTEGER, + name TEXT NOT NULL, + lcl_translation_x REAL, + lcl_translation_y REAL, + lcl_translation_z REAL, + lcl_rotation_x REAL, + lcl_rotation_y REAL, + lcl_rotation_z REAL, + lcl_scaling_x REAL, + lcl_scaling_y REAL, + lcl_scaling_z REAL, + properties TEXT, + FOREIGN KEY (parent_id) REFERENCES fbx_nodes(unique_id) + ); + "; + const char *sql_meshes = R"( CREATE TABLE IF NOT EXISTS meshes ( id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/cpp_src/fbx_wrap.cpp b/cpp_src/fbx_wrap.cpp index 3938778..b01cc45 100644 --- a/cpp_src/fbx_wrap.cpp +++ b/cpp_src/fbx_wrap.cpp @@ -117,25 +117,35 @@ void each_node(FttContext *ctx, FbxNode *parent_node, int level) } } -void print_node_info(FbxNode *node, int level) -{ - // todo 打印一下节点信息 - // 1. 平移、旋转、缩放等矩阵 - // 2. 名称,id, pid等 - // 3. 节点其他properties - - - // 打印一下节点信息 +void print_node_info(FbxNode* node, int level) { + // 层级前缀 + for (int i = 0; i < level; i++) printf("--"); printf("|"); - for (int i = 0; i < level; i++) - { - printf("-"); - } - printf("> "); + printf("--> "); + + // 基础信息:ID/父ID/名称 FbxNode* parent = node->GetParent(); - uint parent_id = 0; - if (parent != NULL) { - parent_id = parent->GetUniqueID(); + printf("[ID:%lld/PID:%lld] Name: %s\n", + node->GetUniqueID(), + parent ? parent->GetUniqueID() : 0, + node->GetNameOnly().Buffer()); + + // 变换矩阵:平移/旋转/缩放 + FbxDouble3 t = node->LclTranslation.Get(); + FbxDouble3 r = node->LclRotation.Get(); + FbxDouble3 s = node->LclScaling.Get(); + printf(" Transform: T(%.2f,%.2f,%.2f) R(%.2f,%.2f,%.2f) S(%.2f,%.2f,%.2f)\n", + t[0], t[1], t[2], r[0], r[1], r[2], s[0], s[1], s[2]); + + // 属性列表(前5个非默认属性) + FbxProperty p = node->GetFirstProperty(); + int prop_count = 0; + printf(" Properties: "); + while (p.IsValid() && prop_count < 5) { + + printf("%s[%.2f] ", p.GetName().Buffer(), p.Get()); + prop_count++; + p = node->GetNextProperty(p); } - printf("[%lld/%lld]: %s\n", node->GetUniqueID(), parent_id, node->GetNameOnly().Buffer()); -} \ No newline at end of file + if (prop_count > 0) printf("\n"); +}