X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=f970b0a3204f68152656d8fa366db6f9817aad44;hb=b0a4fb814d794157c55212191df200915ab99515;hp=73a33c0275208cc9e4312c4c5b6abee059a2319d;hpb=4c49b11c317034277be4d117c5d2847ef2f3492b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index 73a33c0..f970b0a 100644 --- a/world.h +++ b/world.h @@ -62,8 +62,10 @@ static struct gworld scene geo, foliage; rigidbody rb_geo; + /* TODO Maybe make this less hardcoded */ mdl_submesh sm_geo_std_oob, sm_geo_std, sm_geo_vb, - sm_foliage_main, sm_foliage_alphatest; + sm_foliage_main, sm_foliage_alphatest, + sm_graffiti, sm_subworld; glmesh skybox, skydome; mdl_submesh dome_upper, dome_lower; @@ -99,6 +101,9 @@ vg_tex2d tex_terrain_noise = { .path = "textures/garbage.qoi", vg_tex2d tex_alphatest = { .path = "textures/alphatest.qoi", .flags = VG_TEXTURE_NEAREST }; +vg_tex2d tex_graffiti = { .path = "textures/graffitibox.qoi", + .flags = VG_TEXTURE_NEAREST }; + static void ray_world_get_tri( ray_hit *hit, v3f tri[3] ) { for( int i=0; i<3; i++ ) @@ -349,7 +354,9 @@ static void world_load(void) u32 mat_surf = 0, mat_surf_oob = 0, mat_vertex_blend = 0, - mat_alphatest = 0; + mat_alphatest = 0, + mat_graffiti = 0, + mat_subworld = 0; for( int i=1; imaterial_count; i++ ) { @@ -364,6 +371,10 @@ static void world_load(void) mat_vertex_blend = i; else if( !strcmp( "alphatest", mat_name )) mat_alphatest = i; + else if( !strcmp( "graffitibox", mat_name )) + mat_graffiti = i; + else if( !strcmp( "subworld", mat_name )) + mat_subworld = i; } m4x3f midentity; @@ -379,6 +390,10 @@ static void world_load(void) add_all_if_material( midentity, &world.geo, mworld, mat_surf ); scene_copy_slice( &world.geo, &world.sm_geo_std ); + if( mat_subworld ) + add_all_if_material( midentity, &world.geo, mworld, mat_subworld ); + scene_copy_slice( &world.geo, &world.sm_subworld ); + if( mat_vertex_blend ) add_all_if_material( midentity, &world.geo, mworld, mat_vertex_blend ); scene_copy_slice( &world.geo, &world.sm_geo_vb ); @@ -398,6 +413,9 @@ static void world_load(void) add_all_if_material( midentity, &world.foliage, mworld, mat_alphatest ); scene_copy_slice( &world.foliage, &world.sm_foliage_alphatest ); + add_all_if_material( midentity, &world.foliage, mworld, mat_graffiti ); + scene_copy_slice( &world.foliage, &world.sm_graffiti ); + scene_upload( &world.foliage ); world_routes_loadfrom( mworld ); @@ -485,7 +503,8 @@ static void world_init(void) { vg_tex2d_init( (vg_tex2d *[]){ &tex_terrain_colours, &tex_terrain_noise, - &tex_alphatest }, 3 ); + &tex_alphatest, + &tex_graffiti }, 4 ); mdl_header *mcars = mdl_load( "models/rs_cars.mdl" ); mdl_unpack_glmesh( mcars, &world.cars ); @@ -511,6 +530,7 @@ static void world_init(void) static void world_update(void) { + world_routes_update(); world_routes_debug(); sfd_update( &world.sfd.tester ); @@ -592,6 +612,10 @@ static void render_world_alphatest( m4x4f projection, v3f camera ) glDisable(GL_CULL_FACE); scene_bind( &world.foliage ); mdl_draw_submesh( &world.sm_foliage_alphatest ); + + vg_tex2d_bind( &tex_graffiti, 1 ); + mdl_draw_submesh( &world.sm_graffiti ); + glEnable(GL_CULL_FACE); } @@ -613,6 +637,7 @@ static void render_terrain( m4x4f projection, v3f camera ) scene_bind( &world.geo ); mdl_draw_submesh( &world.sm_geo_std_oob ); mdl_draw_submesh( &world.sm_geo_std ); + mdl_draw_submesh( &world.sm_subworld ); /* TODO: Dont draw in reflection */ glDisable(GL_CULL_FACE); @@ -678,15 +703,22 @@ static void render_sky(m4x3f camera) static void render_world_gates( m4x4f projection, m4x3f camera ) { - int count = 0; + float closest = INFINITY; + int id = 0; + for( int i=0; igate, camera ); + float dist = v3_dist2( rg->gate.co[0], camera[3] ); - if( count == 2 ) - return; + if( dist < closest ) + { + closest = dist; + id = i; + } } + + render_gate( &world.routes.gates[id].gate, camera ); } static void render_world( m4x4f projection, m4x3f camera )