BRF文件数据结构

一.BRF-文件头数据结构

type_mesh = "mesh" 网格
type_material = "material" 材质

struct brf_header{
   int type_length; //4个字节, type字符串对应长度
   char* type_name; //根据type_length获取
   int type_content_num; //4个字节,对应类型所含个数,例如含有模型6个
}

例如一个包含2个模型的BRF文件,对应的BRF文件头应该是:

BRF文件数据结构_第1张图片

二.BRF-mesh数据结构

int 对应4个字节
float 对应4个字节

struct mesh{
   int name_length;//模型名长度
   char* name;//模型名
   const int material_flag = 0;//标志位
   int material_cnt;//材质名长度
   int material_name_length;//材质名长度
   char* material_name;//材质名

   int vertex_num;//顶点数量(Normal格式顶点) x, y, z三个坐标float类型数值
   vertex_normal[];
   
   int vertex_fvf_num;//顶点数量(FVF格式顶点)顶点数量
   vertex_fvf[];
   
   int triangle_num;//三角面数量
   triangle[];
}

struct vertex_normal{
   float x;
   float y;
   float z;
};

struct vertex_fvf{
   int vertex_fvf_index;
   const int vertex_uv_flag = -1;//标志位
   float x;
   float y;
   float z;
   float u;
   float v;
   float vnx;
   float vny;
   float vnz;
};

struct triangle{
   int v1_index;
   int v2_index;
   int v3_index;
}

BRF文件数据结构_第2张图片

你可能感兴趣的:(C++,数据结构,c++,游戏程序)