X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=f8b09b85fcbdb2af8f8d5ae6f0753b6114bdc0dc;hb=d57b7661518800479c00300ce57407378696eec9;hp=a65f11fd2ae20dcdde75ab1e72f6a50545af56f6;hpb=6d66c67945f84476d6ac75a0497007cc30bcf58c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index a65f11f..f8b09b8 100644 --- a/model.h +++ b/model.h @@ -14,7 +14,7 @@ typedef struct mdl_header mdl_header; #define MDL_SIZE_MAX 0x1000000 #define MDL_VERT_MAX 1000000 #define MDL_INDICE_MAX 1000000 -#define MDL_MATERIAL_MAX 500 +#define MDL_MATERIAL_MAX 32 #define MDL_NODE_MAX 4000 #define MDL_SUBMESH_MAX 8000 #define MDL_STRING_LENGTH_MAX 64 @@ -83,6 +83,7 @@ struct classtype_block struct classtype_gate { u32 target; + v3f dims; }; struct classtype_spawn @@ -100,6 +101,27 @@ struct classtype_car_path u32 target, target1; }; +struct classtype_instance +{ + u32 pstr_file; +}; + +struct classtype_capsule +{ + float height, radius; +}; + +struct classtype_route_node +{ + u32 target, target1; +}; + +struct classtype_route +{ + u32 pstr_name; + u32 id_start; +}; + #pragma pack(pop) /* @@ -411,5 +433,42 @@ static void *mdl_get_entdata( mdl_header *mdl, mdl_node *pnode ) return mdl_baseptr( mdl, mdl->entdata_offset ) + pnode->offset; } +static void mdl_link_materials( mdl_header *root, mdl_header *child ) +{ + u32 lookup[MDL_MATERIAL_MAX]; + + for( int i=0; imaterial_count; i++ ) + { + mdl_material *mi = mdl_material_from_id( child, i ); + const char *si = mdl_pstr( child, mi->pstr_name ); + + lookup[i] = 0; + + for( int j=0; jmaterial_count; j++ ) + { + mdl_material *mj = mdl_material_from_id( root, j ); + const char *sj = mdl_pstr( root, mj->pstr_name ); + + if( !strcmp( si, sj ) ) + { + lookup[i] = j; + break; + } + } + + if( lookup[i] == 0 && i != 0 ) + { + vg_warn( "Could not link material '%s' (not present in root model)\n", + si ); + } + } + + for( int i=0; isubmesh_count; i++ ) + { + mdl_submesh *sm = mdl_submesh_from_id( child, i ); + sm->material_id = lookup[sm->material_id]; + } +} + #endif