X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=ad9dfeb53ce6e782125243df58b27a6f7ba49619;hb=55b17b4ef5e56ee515656960609843d5365b4d93;hp=4ed39d4780500a4d876c19955ed4aea24dbb8f46;hpb=9c85e110fa8b965195438d96625ff9753af362a6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index 4ed39d4..ad9dfeb 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 @@ -50,8 +50,9 @@ struct mdl_node v3f co; v4f q; v3f s; - - u32 submesh_start, + + union{ u32 submesh_start, sub_uid; }; + u32 submesh_count, classtype, offset, @@ -82,6 +83,7 @@ struct classtype_block struct classtype_gate { u32 target; + v3f dims; }; struct classtype_spawn @@ -94,6 +96,33 @@ struct classtype_water u32 temp; }; +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; + v3f colour; +}; + #pragma pack(pop) /* @@ -361,9 +390,9 @@ static mdl_material *mdl_material_from_id( mdl_header *mdl, u32 id ) static void mdl_node_transform( mdl_node *pnode, m4x3f transform ) { q_m3x3( pnode->q, transform ); - transform[0][0] *= pnode->s[0]; - transform[1][1] *= pnode->s[1]; - transform[2][2] *= pnode->s[2]; + v3_muls( transform[0], pnode->s[0], transform[0] ); + v3_muls( transform[1], pnode->s[1], transform[1] ); + v3_muls( transform[2], pnode->s[2], transform[2] ); v3_copy( pnode->co, transform[3] ); } @@ -405,5 +434,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