static int debugview = 0;
static int sv_debugcam = 0;
static int lightedit = 0;
+static int sv_scene = 0;
/* Components */
#include "road.h"
#include "shaders/standard.h"
#include "shaders/unlit.h"
+#include "physics_test.h"
+
void vg_register(void)
{
shader_blit_register();
static void init_other(void)
{
+ player_init();
render_init();
gate_init();
world_init();
void vg_start(void)
{
vg_convar_push( (struct vg_convar){
- .name = "freecam",
+ .name = "fc",
.data = &freecam,
.data_type = k_convar_dtype_i32,
.opt_i32 = { .min=0, .max=1, .clamp=1 },
.persistent = 1
});
+ vg_convar_push( (struct vg_convar){
+ .name = "dt",
+ .data = &ktimestep,
+ .data_type = k_convar_dtype_f32,
+ .opt_f32 = { .clamp = 0 },
+ .persistent = 0
+ });
+
vg_convar_push( (struct vg_convar){
.name = "debugcam",
.data = &sv_debugcam,
init_other();
- character_load( &player.mdl, "ch_mike" );
- character_init_ragdoll( &player.mdl );
+ /*
+ * If we're in physics test mode we dont need to load anything else, this
+ * parameter is dev only. TODO: dev only cvars that don't ship with the game
+ * when building in release mode.
+ */
- world_load();
+ if( sv_scene == 0 )
+ {
+ character_load( &player.mdl, "ch_default" );
+ character_init_ragdoll( &player.mdl );
+
+ world_load();
- reset_player( 1, (const char *[]){ "tutorial" } );
- player_transform_update();
+ reset_player( 1, (const char *[]){ "start" } );
+ rb_init( &player.rb );
+ }
+ else
+ {
+ physics_test_start();
+ }
}
void vg_free(void)
void vg_update(void)
{
- player_update();
+ if( sv_scene == 0 )
+ {
+ player_update();
+ world_update();
+ //traffic_visualize( world.traffic, world.traffic_count );
+ //
+ /* TEMP */
+ if( glfwGetKey( vg_window, GLFW_KEY_J ))
+ {
+ v3_copy( player.camera_pos, world.mr_ball.co );
+ }
+ }
+ else if( sv_scene == 1 )
+ {
+ physics_test_update();
+ }
}
static void vg_framebuffer_resize( int w, int h )
water_fb_resize();
}
-void vg_render(void)
+static void draw_origin_axis(void)
{
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glViewport( 0,0, vg_window_x, vg_window_y );
-
- glDisable( GL_DEPTH_TEST );
- glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
+ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
+}
- float speed = freecam? 0.0f: v3_length( player.v );
+static void render_main_game(void)
+{
+ float speed = freecam? 0.0f: v3_length( player.rb.v );
v3f shake = { vg_randf()-0.5f, vg_randf()-0.5f, vg_randf()-0.5f };
v3_muls( shake, speed*0.01f, shake );
gpipeline.fov = freecam? 60.0f: 135.0f; /* 120 */
m4x4_projection( vg_pv, gpipeline.fov,
(float)vg_window_x / (float)vg_window_y,
- 0.1f, 2100.0f );
+ 0.02f, 2100.0f );
m4x4_mul( vg_pv, world_4x4, vg_pv );
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
- vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
-
glEnable( GL_DEPTH_TEST );
/*
* Draw world
*/
-
+
render_world( vg_pv, player.camera );
render_water_texture( player.camera );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
render_water_surface( vg_pv, player.camera );
- vg_tex2d_bind( &tex_water, 1 );
-
- for( int i=0; i<world.gate_count; i++ )
- {
- render_gate( &world.gates[i], player.camera );
- }
-
+ vg_tex2d_bind( &tex_water, 1 ); /*TODO: ?*/
+ render_world_gates( vg_pv, player.camera );
/* Copy the RGB of what we have into the background buffer */
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
{
m4x4_projection( vg_pv, gpipeline.fov,
(float)vg_window_x / (float)vg_window_y,
- 0.01f, 100.0f );
+ 0.04f, 600.0f );
m4x4_mul( vg_pv, world_4x4, vg_pv );
}
draw_player();
glViewport( 0,0, vg_window_x, vg_window_y );
}
+void vg_render(void)
+{
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg_window_x, vg_window_y );
+
+ glDisable( GL_DEPTH_TEST );
+ glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+
+ draw_origin_axis();
+
+ if( sv_scene == 0 )
+ {
+ render_main_game();
+ }
+ else if( sv_scene == 1 )
+ {
+ physics_test_render();
+ }
+}
+
static void run_light_widget( struct light_widget *lw )
{
struct ui_checkbox c1 = { .data=&lw->enabled };