3D Voxel Landscape

Post Reply
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

3D Voxel Landscape

Post by NightRadio »

Code: Select all

xsize = 320
ysize = 240
hx = xsize / 2
hy = ysize / 2
resize_pixi( 0, xsize, ysize )

map = new_pixi( 64, 64, 1 )

calc_map = new_pixi( 64, 64, 1 )

set_screen( map )
p = 0
y = 0 while( y < 64 ) {
x = 0 while( x < 64 ) {
	v = (sin(x*16)*cos(y*16))/256
	v / 4
	map[ p ] = get_color( v, v, v )
	p + 1
	x + 1
}
y + 1
}

start_timer( 0 )

start:

t = get_timer( 0 ) / 8

set_screen( calc_map )
clear( BLUE )
t_reset
t_rotate_z( t, 0, 0, 0 );
pixi( map, 0, 0, 2, 0 )
t_scale( 512, 512, 512 )
print( "VOXEL LANDSCAPE", -32, -4, get_color( sin(t)/4+128, sin(t)/2, sin(t)/2 ) )
t_reset

set_screen( 0 )
clear( BLACK )
map_xsize = get_pixi_xsize( calc_map )
map_ysize = get_pixi_ysize( calc_map )
xstep = xsize / get_pixi_xsize( calc_map )
start_p = map_xsize * ( map_ysize - 1 )
x = 0 while( x < xsize ) 
{
	p = start_p
	max_v = 0
	prev_v = 0
	my = 0 while( my < map_ysize )
	{
		pixel = calc_map[ p ]
		v = get_red( pixel ) + my
		if v > max_v
		{
			c = 255 - ( v - prev_v ) * 8
			fbox( x - hx, hy - v, xstep, v - max_v, get_color( c+64, c+32, c ) )
			max_v = v
		}
		p - map_xsize
		prev_v = v
		my + 1
	}
	start_p + 1
	x + xstep
}

frame( 0 )

go start
goglus
Posts: 122
Joined: Tue Dec 04, 2007 4:19 pm
Contact:

Re: 3D Voxel Landscape

Post by goglus »

прорыв блин однако в новые реальности
Post Reply