82 lines
2.5 KiB
C++
82 lines
2.5 KiB
C++
#include <tools.h>
|
||
|
||
using namespace std;
|
||
/**
|
||
* @brief 创建并打开SQLite数据库连接
|
||
* @param db_path 数据库文件路径
|
||
* @param overwrite_file 若为true则删除已有文件后创建新数据库
|
||
* @return 成功返回sqlite3句柄,失败返回NULL
|
||
*/
|
||
sqlite3* create_db(const char* db_path, bool overwrite_file);
|
||
|
||
/**
|
||
* @brief 在指定数据库中创建必要表结构
|
||
* @param db 已打开的SQLite数据库句柄
|
||
* @note 需确保db参数有效且已成功打开
|
||
*/
|
||
void create_tables(sqlite3* db);
|
||
|
||
|
||
///////////////////////////
|
||
//////// 数据保存 /////////
|
||
///////////////////////////
|
||
|
||
/**
|
||
* @brief 将网格数据元信息保存到数据库表
|
||
* @param ctx FTT上下文句柄,包含日志/错误处理等公共资源
|
||
* @param db 已打开的SQLite数据库连接
|
||
* @param name 网格名称(唯一标识)
|
||
* @param vertex_count 顶点数量
|
||
* @param index_count 索引数量
|
||
* @param fbx_id 关联的FBX文件ID
|
||
* @return 成功返回SQLITE_OK,失败返回SQLite错误码(<0)
|
||
* @note 1. 参数需确保有效:ctx/db非NULL,name/fbx_id非空
|
||
* 2. 内部自动处理事务,重复name会触发唯一键冲突
|
||
*/
|
||
int save_mesh_to_table(FttContext* ctx, sqlite3 *db, uint id, uint pid, const std::string &name, int vertex_count, int index_count, const std::string &fbx_id);
|
||
/**
|
||
* @brief 保存网格顶点数据到上下文
|
||
* @param ctx FttContext上下文指针,用于管理网格数据存储
|
||
* @param mesh_id 目标网格的唯一标识符
|
||
* @param vertices 顶点数据容器,存储V3类型的顶点坐标集合
|
||
* @return 成功返回0,失败返回非0错误码
|
||
*/
|
||
int save_mesh_vertices(FttContext* ctx, uint mesh_id, std::vector<V3> vertices);
|
||
|
||
/**
|
||
* @brief 保存网格索引数据到上下文
|
||
* @param ctx FttContext上下文指针,用于管理网格数据存储
|
||
* @param mesh_id 目标网格的唯一标识符,需与顶点数据的mesh_id对应
|
||
* @param indices 索引数据容器,存储unsigned int类型的顶点索引集合
|
||
* @return 成功返回0,失败返回非0错误码
|
||
*/
|
||
int save_mesh_indices(FttContext* ctx, uint mesh_id, std::vector<unsigned int> indices);
|
||
|
||
/*
|
||
id INTEGER PRIMARY KEY,
|
||
pid INTEGER,
|
||
name TEXT NOT NULL,
|
||
t_x REAL,
|
||
t_y REAL,
|
||
t_z REAL,
|
||
r_x REAL,
|
||
r_y REAL,
|
||
r_z REAL,
|
||
s_x REAL,
|
||
s_y REAL,
|
||
s_z REAL,
|
||
properties TEXT
|
||
*/
|
||
int save_nodes(FttContext* ctx, uint id, uint pid,
|
||
const std::string &name,
|
||
double t_x,
|
||
double t_y,
|
||
double t_z,
|
||
double r_x,
|
||
double r_y,
|
||
double r_z,
|
||
double s_x,
|
||
double s_y,
|
||
double s_z,
|
||
const std::string &properties
|
||
); |