}
}
+/*
+ * '
+ * .
+ * |
+ * |
+ * /#\
+ * -'###`-
+ */
+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; j<samples; j++ ){
+ if( pcbuf->count >= 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,
f64 area = 0.0;
area = world_routes_scatter_surface_points( world, pcbuf, 16.0f );
world_routes_surface_grid( world, pcbuf );
+
+ for( u32 i=0; i<mdl_arrcount( &world->ent_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 );
}