X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=aade46aa21ddd00c341c552d71669bc20f1fbd00;hb=refs%2Fheads%2Fmenu2;hp=ae19f6f090d57848ff97fdb9d8f9df2533377a6e;hpb=17851df33b64209eeefcc0dc096dadb8a8ff2c1a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index ae19f6f..aade46a 100644 --- a/model.h +++ b/model.h @@ -5,7 +5,7 @@ #pragma once #define MDL_VERSION_MIN 101 -#define MDL_VERSION_NR 105 +#define MDL_VERSION_NR 106 enum mdl_shader{ k_shader_standard = 0, @@ -85,7 +85,7 @@ typedef struct mdl_header mdl_header; typedef struct glmesh glmesh; struct glmesh { - GLuint vao, vbo, ebo; + u32 vao, vbo, ebo; u32 indice_count; u32 loaded; }; @@ -124,7 +124,15 @@ static void mdl_transform_mul( mdl_transform *a, mdl_transform *b, v3_mul( a->s, b->s, d->s ); } -struct mdl_material +struct mdl_file +{ + u32 pstr_path, + pack_offset, + pack_size; +}; + +#if (MDL_VERSION_MIN <= 105) +struct mdl_material_v105 { u32 pstr_name, shader, @@ -138,6 +146,27 @@ struct mdl_material tex_none0, tex_none1; }; +#endif + +struct mdl_material +{ + u32 pstr_name, + shader, + flags, + surface_prop; + + union + { + struct + { + u32 offset, size; + /* -> vg_msg containing KV properties */ + } + kvs; + void *compiled; /* -> shader specific structure for render */ + } + props; +}; struct mdl_bone { @@ -212,13 +241,6 @@ struct mdl_mesh armature_id; }; -struct mdl_file -{ - u32 pstr_path, - pack_offset, - pack_size; -}; - struct mdl_texture { mdl_file file; @@ -240,7 +262,8 @@ struct mdl_header mdl_array index; }; -struct mdl_context{ +struct mdl_context +{ FILE *file; mdl_header info; @@ -299,6 +322,7 @@ void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst ); int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ); int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ); int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ); +int mdl_load_materials( mdl_context *mdl, void *lin_alloc ); /* load mesh */ void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh, u32 *fixup_table ); @@ -309,6 +333,7 @@ void mdl_async_full_load_std( mdl_context *mdl ); /* rendering */ void mdl_draw_submesh( mdl_submesh *sm ); mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ); +mdl_submesh *mdl_find_submesh( mdl_context *mdl, const char *mesh_name ); /* pstrs */ const char *mdl_pstr( mdl_context *mdl, u32 pstr );