From: hgn Date: Mon, 4 Jul 2022 00:54:14 +0000 (+0100) Subject: audio&island X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=cb16ccb05a796178c879ea8d5091663d215a5217;p=carveJwlIkooP6JGAAIwe30JlM.git audio&island --- diff --git a/audio.h b/audio.h new file mode 100644 index 0000000..498acc3 --- /dev/null +++ b/audio.h @@ -0,0 +1,55 @@ +#ifndef AUDIO_H +#define AUDIO_H + +#include "common.h" + +sfx_vol_control audio_vol_all = { .val = 1.0f, .name = "All" }; + +sfx_set audio_board = +{ + .sources = "sound/skate.ogg\0" + "sound/wheel.ogg\0" + "sound/slide.ogg\0" +}; + +sfx_system audio_player0 = +{ + .vol = 0.0f, + .ch = 1, + .vol_src = &audio_vol_all, + .name = "Player0", + .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT +}; + +sfx_system audio_player1 = +{ + .vol = 0.0f, + .ch = 1, + .vol_src = &audio_vol_all, + .name = "Player1", + .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT +}; + +sfx_system audio_player2 = +{ + .vol = 0.0f, + .ch = 1, + .vol_src = &audio_vol_all, + .name = "Player2", + .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT +}; + +static void audio_init(void) +{ + sfx_set_init( &audio_board, NULL ); + sfx_set_play( &audio_board, &audio_player0, 0 ); + sfx_set_play( &audio_board, &audio_player1, 1 ); + sfx_set_play( &audio_board, &audio_player2, 2 ); +} + +static void audio_free(void) +{ + sfx_set_free( &audio_board ); +} + +#endif /* AUDIO_H */ diff --git a/blender_export.py b/blender_export.py index afb0f78..a13e84e 100644 --- a/blender_export.py +++ b/blender_export.py @@ -256,6 +256,11 @@ def write_model(name): sm.indice_count += 1 + if sm.vertex_count == 0: + for j in range(2): + for i in range(3): + sm.bbx[j][i] = 0 + layers += [sm] header.layer_count += 1 header.vertex_count += sm.vertex_count @@ -266,6 +271,8 @@ def write_model(name): mref['vertex_start'] = sm.vertex_start mref['vertex_count'] = sm.vertex_count mref['bbx'] = sm.bbx + print( F"{sm.bbx[0][0]},{sm.bbx[0][1]},{sm.bbx[0][2]}" ) + mref['material'] = sm.material ref['sm'] += [mref] diff --git a/character.h b/character.h index 047b714..59fbdca 100644 --- a/character.h +++ b/character.h @@ -422,7 +422,7 @@ void character_final_pose( struct character *ch, v3f cog, character_pose *pose, float q ) { character_pose npose; - float dip = vg_clampf(cog[1], -1.0f, 0.3f) * 0.35f, + float dip = vg_clampf(cog[1], -1.0f, 0.3f) * 0.5f, tilt = vg_clampf(cog[2], -1.0f, 1.0f) * 0.3f; v4f rz; m4x3f tr; @@ -447,6 +447,18 @@ void character_final_pose( struct character *ch, v3f cog, character_pose_blend( ch, &npose, q ); } +static void character_yaw_upper( struct character *ch, float yaw ) +{ + m3x3f r; + v4f q; + + q_axis_angle( q, (v3f){0.0f,1.0f,0.0f}, yaw ); + q_m3x3( q, r ); + + m3x3_mulv( r, ch->ik_body.pole, ch->ik_body.pole ); + m3x3_mulv( r, ch->ik_body.end, ch->ik_body.end ); +} + static void zero_ik_basic( struct ik_basic *ik ) { v3_zero( ik->base ); diff --git a/gate.h b/gate.h index 7088c7d..3151878 100644 --- a/gate.h +++ b/gate.h @@ -162,7 +162,7 @@ static void render_gate( teleport_gate *gate, m4x3f camera ) } render_world( projection, cam_new ); - + if( grender.high_qual ) { /* @@ -202,6 +202,14 @@ static void render_gate( teleport_gate *gate, m4x3f camera ) } else { + glDisable( GL_STENCIL_TEST ); + + render_water_texture( cam_new ); + fb_use( NULL ); + glEnable( GL_STENCIL_TEST ); + + render_water_surface( projection, cam_new ); + glStencilMask( 0xFF ); glStencilFunc( GL_ALWAYS, 1, 0xFF ); glDisable( GL_STENCIL_TEST ); diff --git a/main.c b/main.c index def609d..4462c0f 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,7 @@ +/* + * Copyright (C) Mount0 Software, Harry Godden - All Rights Reserved + */ + #include "common.h" /* Resources */ @@ -17,6 +21,7 @@ static int sv_debugcam = 0; #include "road.h" #include "scene.h" #include "ik.h" +#include "audio.h" #include "terrain.h" #include "character.h" #include "ragdoll.h" @@ -43,6 +48,15 @@ void vg_register(void) gate_register(); } +static void init_other(void) +{ + render_init(); + gate_init(); + terrain_init(); + character_init(); + audio_init(); +} + vg_tex2d *texture_list[] = { &tex_norwey, @@ -119,11 +133,8 @@ void vg_start(void) }); vg_tex2d_init( texture_list, vg_list_size( texture_list ) ); - - render_init(); - gate_init(); - terrain_init(); - character_init(); + + init_other(); character_load( &player.mdl, "ch_default" ); character_init_ragdoll( &player.mdl ); @@ -167,10 +178,10 @@ void vg_render(void) m4x4f world_4x4; m4x3_expand( player.camera_inverse, world_4x4 ); - gpipeline.fov = freecam? 60.0f: 120.0f; /* 120 */ + gpipeline.fov = freecam? 60.0f: 135.0f; /* 120 */ m4x4_projection( vg_pv, gpipeline.fov, (float)vg_window_x / (float)vg_window_y, - 0.025f, 1000.0f ); + 0.1f, 1500.0f ); m4x4_mul( vg_pv, world_4x4, vg_pv ); diff --git a/player.h b/player.h index 6c81980..34ed469 100644 --- a/player.h +++ b/player.h @@ -1,6 +1,7 @@ #ifndef PLAYER_H #define PLAYER_H +#include "audio.h" #include "common.h" #include "character.h" #include "bvh.h" @@ -63,8 +64,7 @@ static void player_transform_update(void) static int reset_player( int argc, char const *argv[] ) { - v3_copy( (v3f){ 0.0f, -2.0f, 0.0f }, player.co ); - + v3_copy( world.tutorial, player.co ); if( argc == 1 ) { if( !strcmp( argv[0], "tutorial" )) @@ -1626,12 +1626,17 @@ static void player_animate(void) character_final_pose( &player.mdl, (v3f){0.0f,0.0f,0.0f}, &pose_fly, amt_air ); + + static float fupper = 0.0f; + fupper = vg_lerpf( fupper, -vg_get_axis("horizontal")*0.2f, 0.1f ); + character_yaw_upper( &player.mdl, fupper ); /* Camera position */ v3_lerp( player.smooth_localcam, player.mdl.cam_pos, 0.08f, player.smooth_localcam ); v3_muladds( player.smooth_localcam, offset, 0.7f, player.camera_pos ); player.camera_pos[1] = vg_clampf( player.camera_pos[1], 0.3f, kheight ); + m4x3_mulv( player.to_world, player.camera_pos, player.camera_pos ); player.air_blend = vg_lerpf( player.air_blend, player.in_air, 0.04f ); @@ -2008,6 +2013,51 @@ static void player_do_collision( rigidbody *rb ) } } +static void player_audio(void) +{ + float speed = vg_minf(v3_length( player.v )*0.1f,1.0f), + attn = v3_dist( player.co, player.camera[3] )+1.0f; + attn = (1.0f/(attn*attn)) * speed; + + static float air = 0.0f; + air = vg_lerpf(air, player.in_air? 1.0f: 0.0f, 0.7f); + + v3f ears = { 1.0f,0.0f,0.0f }; + v3f delta; + + v3_sub( player.co, player.camera[3], delta ); + v3_normalize( delta ); + m3x3_mulv( player.camera, ears, ears ); + + float pan = v3_dot( ears, delta ); + audio_player0.pan = pan; + audio_player1.pan = pan; + audio_player2.pan = pan; + + if( freecam ) + { + audio_player0.vol = 0.0f; + audio_player1.vol = 0.0f; + audio_player2.vol = 0.0f; + } + else + { + if( player.is_dead ) + { + audio_player0.vol = 0.0f; + audio_player1.vol = 0.0f; + audio_player2.vol = 0.0f; + } + else + { + float slide = vg_clampf( fabsf(player.slip), 0.0f, 1.0f ); + audio_player0.vol = (1.0f-air)*attn*(1.0f-slide); + audio_player1.vol = air *attn; + audio_player2.vol = (1.0f-air)*attn*slide; + } + } +} + static void player_update(void) { for( int i=0; i %.3f %.3f %.3f\n", + world.geo.bbx[0][0], world.geo.bbx[0][1], world.geo.bbx[0][2], + world.geo.bbx[1][0], world.geo.bbx[1][1], world.geo.bbx[1][2] ); + /* * TODO: Parametric marker import */ @@ -139,6 +145,8 @@ static void world_load(void) water_init(); water_set_surface( &surf, sm->pivot[1] ); + vg_info( "%.3f\n", sm->pivot[1] ); + break; } } @@ -195,6 +203,7 @@ static void world_load(void) { v3f pos; v3_mul( volume, (v3f){ vg_randf(), 1000.0f, vg_randf() }, pos ); + pos[1] = 1000.0f; v3_add( pos, world.geo.bbx[0], pos ); ray_hit hit;