--- /dev/null
+#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 */
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
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]
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;
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 );
}
render_world( projection, cam_new );
-
+
if( grender.high_qual )
{
/*
}
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 );
+/*
+ * Copyright (C) Mount0 Software, Harry Godden - All Rights Reserved
+ */
+
#include "common.h"
/* Resources */
#include "road.h"
#include "scene.h"
#include "ik.h"
+#include "audio.h"
#include "terrain.h"
#include "character.h"
#include "ragdoll.h"
gate_register();
}
+static void init_other(void)
+{
+ render_init();
+ gate_init();
+ terrain_init();
+ character_init();
+ audio_init();
+}
+
vg_tex2d *texture_list[] =
{
&tex_norwey,
});
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 );
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 );
#ifndef PLAYER_H
#define PLAYER_H
+#include "audio.h"
#include "common.h"
#include "character.h"
#include "bvh.h"
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" ))
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 );
}
}
+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<player.land_log_count; i++ )
player_do_motion();
player_animate();
+
+ v3f offs = { -0.35f, 0.0f, 0.0f };
+ m3x3_mulv( player.to_world, offs, offs );
+ m4x3_mulv( player.to_world, player.mdl.ik_body.end, player.camera_pos );
+ v3_add( offs, player.camera_pos, player.camera_pos );
}
else
{
}
}
+ player_audio();
+
/* Update camera matrices */
m4x3_identity( player.camera );
m4x3_rotate_y( player.camera, -player.angles[0] );
else
character_eval( &player.mdl );
- character_draw( &player.mdl, (player.is_dead|player.in_air)? 0.0f: 1.0f );
+ float opacity = 1.0f-player.air_blend;
+ if( player.is_dead )
+ opacity = 0.0f;
+
+ character_draw( &player.mdl, opacity );
}
#endif /* PLAYER_H */
// Colour blending
float amtgrass = step(qnorm.y,0.6);
- float amtsand = min(max((aCo.y + 90.0) * -0.08,0.0)*qnorm.y,1.0);
+ float amtsand = min(max((aCo.y - 10.0) * -0.08,0.0)*qnorm.y,1.0);
vec2 uvgradients = vec2( rgarbage.a, -amtgrass*0.125 ) + aUv;
vec3 diffuse = texture( uTexGradients, uvgradients ).rgb;
diffuse = mix( diffuse, vec3(1.0,0.9,0.7), amtsand );
"\n"
" // Colour blending\n"
" float amtgrass = step(qnorm.y,0.6);\n"
-" float amtsand = min(max((aCo.y + 90.0) * -0.08,0.0)*qnorm.y,1.0);\n"
+" float amtsand = min(max((aCo.y - 10.0) * -0.08,0.0)*qnorm.y,1.0);\n"
" vec2 uvgradients = vec2( rgarbage.a, -amtgrass*0.125 ) + aUv;\n"
" vec3 diffuse = texture( uTexGradients, uvgradients ).rgb;\n"
" diffuse = mix( diffuse, vec3(1.0,0.9,0.7), amtsand );\n"
}
wrender =
{
- .fbreflect = { .format = GL_RGB, .div = 2 },
- .fbdepth = { .format = GL_RGBA, .div = 2 }
+ .fbreflect = { .format = GL_RGB, .div = 4 },
+ .fbdepth = { .format = GL_RGBA, .div = 4 }
};
static float water_height(void)
{
for( int x=0; x<kres; x++ )
{
- v3f pos = { x, 0, y };
+ v3f pos = { x, 0.0f, y };
v3_divs( pos, kres, pos );
v3_muladd( bounds[0], pos, volume, pos );
pos[1] = wrender.height;
if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &hit ))
{
float h = wrender.height - hit.pos[1];
- h *= 1.0f/15.0f;
+ h *= 1.0f/25.0f;
h = vg_clampf( h, 0.0f, 1.0f );
*dst = (u8)(h*255.0f);
}
v4f clippb = { 0.0f, -1.0f, 0.0f, -(wrender.height) };
m4x3_mulp( inverse, clippb, clippb );
clippb[3] *= -1.0f;
-
- float depth_loss = camera[3][1]-wrender.height;
m4x4_projection( projection,
gpipeline.fov,
v3f tutorial;
- teleport_gate gates[16];
+ teleport_gate gates[64];
u32 gate_count;
- rigidbody temp_rbs[32];
+ rigidbody temp_rbs[128];
u32 rb_count;
bh_tree bhcubes;
scene_bind( &world.foliage );
scene_draw( &world.foliage );
glEnable(GL_CULL_FACE);
+
+ vg_line_boxf( world.geo.bbx, 0xff00ff00 );
}
static void ray_world_get_tri( ray_hit *hit, v3f tri[3] )
scene_copy_slice( &world.geo, &world.sm_terrain );
+ vg_info( "BBX: %.3f %.3f %.3f -> %.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
*/
water_init();
water_set_surface( &surf, sm->pivot[1] );
+ vg_info( "%.3f\n", sm->pivot[1] );
+
break;
}
}
{
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;