fbx_to_3dtiles/cpp_src/include/fbx_wrap.h

42 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <fbxsdk.h>
#include <vector>
#include <tools.h>
#include <tuple>
using namespace std;
using Triangle = std::tuple<int, int, int>;
/**
* 递归遍历FBX节点树结构
* @param parent_node 起始父节点从此节点开始向下遍历若为nullptr则函数不执行任何操作
* @param level 当前节点层级用于缩进或层级标识建议初始调用时传入0
* @note 函数内部会递归访问parent_node的所有直接子节点和间接子节点
* @warning 若输入的parent_node无效如野指针可能导致程序崩溃
*/
void each_node(const FttContext* ctx, FbxNode* parent_node, int level);
/**
* 打印FBX节点的基本信息含层级缩进
* @param node 待打印信息的节点指针nullptr时输出警告日志
* @param level 节点层级用于控制打印缩进每级建议缩进4空格
* @details 输出内容包含:节点名称、类型、子节点数量、层级深度
* @example 层级2的节点打印格式" |-- NodeName (Type: Mesh, Children: 3)"
*/
void print_node_info(FbxNode* node, int level);
/**
* 从FBX文件加载并返回根节点
* @param fbx_path FBX文件路径需绝对路径或相对于可执行文件路径
* @return FbxNode* 成功时返回根节点指针失败返回nullptr
* @note 内部会初始化FBX SDK环境并自动释放资源
* @warning 路径无效或文件损坏时返回空指针,需调用方检查
*/
FbxNode* get_fbx_root_node(const char* fbx_path);
/**
* 从FBX属性提取三角形数据并填充到向量
* @param attr FBX节点属性指针需为Mesh类型非Mesh类型返回0
* @param triangles 输出三角形数据的向量引用(会自动清空原有数据)
* @return int 成功提取的三角形数量,失败返回-1如attr为空或非Mesh类型
* @note 仅处理三角形网格,四边形等多边形会被自动三角化
*/
int load_triangles(fbxsdk::FbxNodeAttribute* attr, std::vector<Triangle>& triangles);