X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=dae6038bbc04543d4221449829ba5e6eee386610;hb=137d40d96fe923600d8378b8e138e3c276f27ff4;hp=9f5bdb5451e39a826b97304bd85635db04c059a1;hpb=35b57a341eb37d863ec69e4f011a88b7bfba5c01;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index 9f5bdb5..dae6038 100644 --- a/model.h +++ b/model.h @@ -8,7 +8,7 @@ #include "skaterift.h" #define MDL_VERSION_MIN 101 -#define MDL_VERSION_NR 102 +#define MDL_VERSION_NR 103 enum mdl_shader{ k_shader_standard = 0, @@ -19,7 +19,8 @@ enum mdl_shader{ k_shader_invisible = 5, k_shader_boundary = 6, k_shader_fxglow = 7, - k_shader_cubemap = 8 + k_shader_cubemap = 8, + k_shader_override = 30000 }; enum mdl_surface_prop{ @@ -269,7 +270,7 @@ struct mdl_context{ }; -VG_STATIC void mdl_load_fatal_corrupt( mdl_context *mdl ) +static void mdl_load_fatal_corrupt( mdl_context *mdl ) { fclose( mdl->file ); vg_file_print_invalid( mdl->file ); @@ -280,7 +281,7 @@ VG_STATIC void mdl_load_fatal_corrupt( mdl_context *mdl ) * Model implementation */ -VG_STATIC u32 mdl_query_array_size( mdl_array *arr ) +static u32 mdl_query_array_size( mdl_array *arr ) { if( arr->item_count ){ u32 size = arr->item_size*arr->item_count; @@ -289,8 +290,8 @@ VG_STATIC u32 mdl_query_array_size( mdl_array *arr ) else return 0; } -VG_STATIC const char *mdl_pstr( mdl_context *mdl, u32 pstr ); -VG_STATIC +static const char *mdl_pstr( mdl_context *mdl, u32 pstr ); +static void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst ) { if( !info->pack_size ){ @@ -305,7 +306,7 @@ void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst ) } /* TODO: Rename these */ -VG_STATIC void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, +static void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, void *buffer ) { if( arr->item_count ){ @@ -316,7 +317,7 @@ VG_STATIC void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, } } -VG_STATIC void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, +static void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, mdl_array *arr, void *lin_alloc ) { if( arr->item_count ){ @@ -331,17 +332,17 @@ VG_STATIC void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, ptr->stride = arr->item_size; } -VG_STATIC void *mdl_arritm( mdl_array_ptr *arr, u32 index ) +static void *mdl_arritm( mdl_array_ptr *arr, u32 index ) { return ((u8 *)arr->data) + index*arr->stride; } -VG_STATIC u32 mdl_arrcount( mdl_array_ptr *arr ) +static u32 mdl_arrcount( mdl_array_ptr *arr ) { return arr->count; } -VG_STATIC mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) +static mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) { for( u32 i=0; iindex); i++ ){ mdl_array *arr = mdl_arritm( &mdl->index, i ); @@ -354,7 +355,7 @@ VG_STATIC mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) return NULL; } -VG_STATIC int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, +static int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, const char *name, void *lin_alloc ) { mdl_array *arr = mdl_find_array( mdl, name ); @@ -371,7 +372,7 @@ VG_STATIC int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, } } -VG_STATIC int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) { int success = 1; @@ -381,7 +382,7 @@ VG_STATIC int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) return success; } -VG_STATIC int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) { int success = 1; @@ -397,7 +398,7 @@ VG_STATIC int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) return success; } -VG_STATIC int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) { return mdl_load_array( mdl, &mdl->keyframes, "mdl_keyframe", lin_alloc ); } @@ -405,7 +406,7 @@ VG_STATIC int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) /* * if calling mdl_open, and the file does not exist, the game will fatal quit */ -VG_STATIC void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) +static void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) { memset( mdl, 0, sizeof( mdl_context ) ); mdl->file = fopen( path, "rb" ); @@ -437,7 +438,7 @@ VG_STATIC void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) /* * close file handle */ -VG_STATIC void mdl_close( mdl_context *mdl ) +static void mdl_close( mdl_context *mdl ) { fclose( mdl->file ); mdl->file = NULL; @@ -445,7 +446,7 @@ VG_STATIC void mdl_close( mdl_context *mdl ) /* useful things you can do with the model */ -VG_STATIC void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) +static void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) { q_m3x3( transform->q, mtx ); v3_muls( mtx[0], transform->s[0], mtx[0] ); @@ -454,13 +455,13 @@ VG_STATIC void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) v3_copy( transform->co, mtx[3] ); } -VG_STATIC const char *mdl_pstr( mdl_context *mdl, u32 pstr ) +static const char *mdl_pstr( mdl_context *mdl, u32 pstr ) { return ((char *)mdl_arritm( &mdl->strings, pstr )) + 4; } -VG_STATIC int +static int mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) { u32 hash = *((u32 *)mdl_arritm( &mdl->strings, pstr )); @@ -479,7 +480,7 @@ mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) * ---------------------------------------------------------------------------- */ -VG_STATIC void mesh_upload( glmesh *mesh, +static void mesh_upload( glmesh *mesh, mdl_vert *verts, u32 vert_count, u32 *indices, u32 indice_count ) { @@ -535,23 +536,23 @@ VG_STATIC void mesh_upload( glmesh *mesh, mesh->loaded = 1; } -VG_STATIC void mesh_bind( glmesh *mesh ) +static void mesh_bind( glmesh *mesh ) { glBindVertexArray( mesh->vao ); } -VG_STATIC void mesh_drawn( u32 start, u32 count ) +static void mesh_drawn( u32 start, u32 count ) { glDrawElements( GL_TRIANGLES, count, GL_UNSIGNED_INT, (void *)(start*sizeof(u32)) ); } -VG_STATIC void mesh_draw( glmesh *mesh ) +static void mesh_draw( glmesh *mesh ) { mesh_drawn( 0, mesh->indice_count ); } -VG_STATIC void mesh_free( glmesh *mesh ) +static void mesh_free( glmesh *mesh ) { if( mesh->loaded ){ glDeleteVertexArrays( 1, &mesh->vao ); @@ -561,12 +562,12 @@ VG_STATIC void mesh_free( glmesh *mesh ) } } -VG_STATIC void mdl_draw_submesh( mdl_submesh *sm ) +static void mdl_draw_submesh( mdl_submesh *sm ) { mesh_drawn( sm->indice_start, sm->indice_count ); } -VG_STATIC mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) +static mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) { for( u32 i=0; imeshs ); i++ ){ mdl_mesh *mesh = mdl_arritm( &mdl->meshs, i ); @@ -587,7 +588,7 @@ struct payload_glmesh_load{ glmesh *mesh; }; -VG_STATIC void async_mdl_load_glmesh( void *payload, u32 size ) +static void async_mdl_load_glmesh( void *payload, u32 size ) { struct payload_glmesh_load *job = payload; mesh_upload( job->mesh, job->verts, job->vertex_count, @@ -595,7 +596,7 @@ VG_STATIC void async_mdl_load_glmesh( void *payload, u32 size ) } /* TODO: Find out if this needs deprecating in favour of the new full loader */ -VG_STATIC void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) +static void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) { mdl_array *arr_vertices = mdl_find_array( mdl, "mdl_vert" ); mdl_array *arr_indices = mdl_find_array( mdl, "mdl_indice" ); @@ -653,7 +654,7 @@ VG_STATIC void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) } /* uploads the glmesh, and textures. everything is saved into the mdl_context */ -VG_STATIC void mdl_async_full_load_std( mdl_context *mdl ){ +static void mdl_async_full_load_std( mdl_context *mdl ){ mdl_async_load_glmesh( mdl, &mdl->mesh ); for( u32 i=0; itextures ); i ++ ){