Hi, it was a very boring day so I created some functions which will increase your fps.
This code will fade objects out of your view if they are to far away.
Maybe somebody will combine this with the frustrum culling system from LiT.
Here
sync on
sync rate 60
set display mode 1024,768,32
global max_view_distance# = 400.0
set camera range 0.5,int(max_view_distance#)+100
type tree_def
alpha as integer
num as integer
on as boolean
x# as float
y# as float
z# as float
endtype
init_tree_cull()
for x=1 to 50
make object box x,10,10,10
position object x,rnd(600),rnd(100),rnd(600)
rem If you have transparent objects, set the trasparency flag on 6
rem set object transparency x,6
add_tree_obj(x)
next x
do
set cursor 0,0
print "Polygons: ",statistic(1)
print "FPS: ",screen fps()
control camera using arrowkeys 0,1,1
handle_trees()
sync
loop
function init_tree_cull()
null=make vector3(6)
dim trees(128) as tree_def
global tree_start as integer
endfunction
function handle_trees()
for x=1 to tree_start
if cam_dist(trees(x).x#,trees(x).y#,trees(x).z#)>max_view_distance#
trees(x).on=0
else
trees(x).on=1
endif
if trees(x).on=0
if trees(x).alpha>0 then dec trees(x).alpha,5
else
if trees(x).alpha<100 then inc trees(x).alpha,5
endif
if trees(x).alpha>0 then SET ALPHA MAPPING ON trees(x).num,trees(x).alpha
if trees(x).alpha=0
exclude object on trees(x).num
else
exclude object off trees(x).num
endif
next x
endfunction
function add_tree_obj(num)
inc tree_start
trees(tree_start).num=num
trees(tree_start).alpha=100
trees(tree_start).x#=object position x(num)
trees(tree_start).y#=object position y(num)
trees(tree_start).z#=object position z(num)
endfunction
function cam_dist(x#,y#,z#)
set vector3 6,x#-camera position x(),y#-camera position y(),z#-camera position z()
distance#=length vector3(6)
endfunction distance#
[/center]