X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.c;h=529fdefcccfcf2bfbf416fdb6c94e264b290829a;hb=5d5d5f394cbe2212769bc58a70fa622b4ed46205;hp=a66f93ffc00e3f3d8c97d0a9503b694850f29ad7;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.c b/world_routes.c index a66f93f..529fdef 100644 --- a/world_routes.c +++ b/world_routes.c @@ -268,6 +268,57 @@ void world_routes_pointcloud_spot( world_instance *world, } } +/* + * ' + * . + * | + * | + * /#\ + * -'###`- + */ +VG_STATIC +void world_routes_pointcloud_tower( world_instance *world, + pointcloud_buffer *pcbuf, + v3f co, f32 radius, f32 height, + u32 samples, v4f colour ) +{ + v3f inv_ext; + v3_sub( pcbuf->boundary[1], pcbuf->boundary[0], inv_ext ); + v3_div( (v3f){1.0f,1.0f,1.0f}, inv_ext, inv_ext ); + + for( u32 j=0; jcount >= pcbuf->max ) + return; + + pointcloud_vert *vert = &pcbuf->buf[ pcbuf->count ++ ]; + + v3f point; + point[0] = vg_randf64()*2.0f-1.0f; + point[1] = 0.0f; + point[2] = vg_randf64()*2.0f-1.0f; + v3_normalize( point ); + v3_muls( point, sqrtf(vg_randf64()), point ); + + f32 h = vg_randf64(); + point[1] = h*h*h*height; + point[0] *= radius; + point[2] *= radius; + + v3_add( point, co, point ); + v3_sub( point, pcbuf->boundary[0], point ); + v3_mul( point, inv_ext, point ); + + /* TODO....... */ + for( u32 i=0; i<3; i++ ){ + vert->pos[i] = (point[i]-0.5f) * 32767.0f; + } + + for( u32 i=0; i<4; i++ ){ + vert->colour[i] = colour[i] * 255.0f; + } + } +} + VG_STATIC void world_routes_place_curve( world_instance *world, ent_route *route, v4f h[3], v3f n0, v3f n2, scene_context *scene, @@ -804,13 +855,39 @@ VG_STATIC void world_gen_routes_generate(void) f64 area = 0.0; area = world_routes_scatter_surface_points( world, pcbuf, 16.0f ); world_routes_surface_grid( world, pcbuf ); + + for( u32 i=0; ient_gate ); i++ ){ + ent_gate *gate = mdl_arritm( &world->ent_gate, i ); + + world_routes_pointcloud_tower( world, pcbuf, gate->co[0], + 2.0f, 50.0f, 128, + (v4f){0.2f,0.2f,0.2f,1.0f} ); + } + vg_info( "Distrubuted %u points over %fkm^2!\n", pcbuf->count, area/1e6f ); + + if( world_loader.location == k_world_load_type_local ){ + char path_buf[4096]; + vg_str path; + vg_strnull( &path, path_buf, 4096 ); + vg_strcat( &path, "maps/" ); + vg_strcat( &path, world_loader.name ); + vg_strcat( &path, "/preview.bin" ); + + if( !vg_strgood( &path ) ) vg_fatal_error( "Path too long\n" ); + FILE *fp = fopen( path_buf, "wb" ); + if( !fp ) vg_fatal_error( "Cannot open '%s' for writing\n", path_buf ); + + fwrite( pcbuf, sizeof(pcbuf) + + sizeof(struct pointcloud_vert)*pcbuf->count, 1, fp ); + fclose( fp ); + } + vg_async_dispatch( call_pointcloud, async_pointcloud_sub ); } vg_async_dispatch( call_scene, async_scene_upload ); - world_routes_clear( world ); }