This commit is contained in:
dqn 2025-09-15 18:11:17 +08:00
parent a0ca1bffc3
commit 93b4efead1
2 changed files with 49 additions and 19 deletions

View File

@ -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,

View File

@ -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<double>());
prop_count++;
p = node->GetNextProperty(p);
}
printf("[%lld/%lld]: %s\n", node->GetUniqueID(), parent_id, node->GetNameOnly().Buffer());
}
if (prop_count > 0) printf("\n");
}