#include "traffic.h" /*TODO: -> world_traffic.h */
#include "world_routes.h"
+#include "world_sfd.h"
#include "shaders/terrain.h"
#include "shaders/sky.h"
u32 spawn_count;
struct subworld_routes routes;
+ struct subworld_sfd sfd;
/* ...
struct subworld_spawns system_spawns;
struct subworld_physics system_physics;
*/
- teleport_gate gates[64];
- u32 gate_count;
-
/* Paths */
traffic_node traffic[128];
u32 traffic_count;
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;
world;
static struct subworld_routes *subworld_routes(void) { return &world.routes; }
+static struct subworld_sfd *subworld_sfd(void) { return &world.sfd; }
vg_tex2d tex_terrain_colours = { .path = "textures/gradients.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++ )
shader_gpos_register();
shader_fscolour_register();
shader_alphatest_register();
+
+ world_routes_register();
+ world_sfd_register();
}
static void world_free(void)
{
/* TODO.. */
+
+ world_sfd_free();
}
static void render_world_depth( m4x4f projection, m4x3f camera );
mdl_header *mworld = mdl_load( "models/mp_dev.mdl" );
world.spawn_count = 0;
- world.gate_count = 0;
world.traffic_count = 0;
world.instance_cache = NULL;
if( pnode->classtype == k_classtype_none )
{}
-#if 0
- else if( pnode->classtype == k_classtype_gate )
- {
- struct classtype_gate *entgate = mdl_get_entdata( mworld, pnode );
-
- if( entgate->target )
- {
- mdl_node *pother = mdl_node_from_id( mworld, entgate->target );
-
- teleport_gate *gate = &world.gates[ world.gate_count ++ ];
-
- v3_copy( pnode->co, gate->co[0] );
- v3_copy( pother->co, gate->co[1] );
- v4_copy( pnode->q, gate->q[0] );
- v4_copy( pother->q, gate->q[1] );
- v2_copy( pnode->s, gate->dims );
-
- gate_transform_update( gate );
- }
- }
-#endif
else if( pnode->classtype == k_classtype_spawn )
{
struct respawn_point *rp = &world.spawns[ world.spawn_count ++ ];
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; i<mworld->material_count; i++ )
{
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;
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 );
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_init( mworld );
+ world_routes_loadfrom( mworld );
for( int i=0; i<world.instance_cache_count; i++ )
free( world.instance_cache[i].mdl );
{
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 );
world.dome_lower = *mdl_node_submesh( msky, nlower, 0 );
world.dome_upper = *mdl_node_submesh( msky, nupper, 0 );
free(msky);
+
+
+ /* Other systems */
+ world_sfd_init();
}
static void world_update(void)
{
+ world_routes_update();
world_routes_debug();
+ sfd_update( &world.sfd.tester );
#if 0
rb_solver_reset();
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);
}
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);
glDepthMask( GL_TRUE );
}
+static void render_world_gates( m4x4f projection, m4x3f camera )
+{
+ float closest = INFINITY;
+ int id = 0;
+
+ for( int i=0; i<world.routes.gate_count; i++ )
+ {
+ struct route_gate *rg = &world.routes.gates[i];
+ float dist = v3_dist2( rg->gate.co[0], camera[3] );
+
+ if( dist < closest )
+ {
+ closest = dist;
+ id = i;
+ }
+ }
+
+ render_gate( &world.routes.gates[id].gate, camera );
+}
+
static void render_world( m4x4f projection, m4x3f camera )
{
render_sky( camera );
+ render_world_routes( projection, camera[3] );
render_world_vb( projection, camera[3] );
render_world_alphatest( projection, camera[3] );
render_terrain( projection, camera[3] );
+
+ m4x3f identity_matrix;
+ m4x3_identity( identity_matrix );
+ identity_matrix[3][1] = 125.0f;
+
+ v4f t;
+ q_axis_angle( t, (v3f){0.0f,1.0f,0.0f}, 2.3f );
+ q_m3x3( t, identity_matrix );
+
+ sfd_render( &world.sfd.tester, projection, camera[3], identity_matrix );
}
static void render_world_depth( m4x4f projection, m4x3f camera )