you can change the smax constant to a lower value to get
more speed. the srad constant is the radius of the spheres.
#constant smax 50
#constant srad 32
type tcam
speed as float
x1 as float
y1 as float
z1 as float
state as float
x2 as float
y2 as float
z2 as float
endtype
cam as tcam
sync on : sync rate 60 : backdrop off : autocam off : randomize timer()
for i = 1 to smax
make object sphere i, srad * 2, 32, 32
set object light i, 0
repeat
x = rnd(1024) - 512
y = srad + rnd(512)
z = rnd(1024) - 512
for s = 1 to i
if SphereColli(x, y, z, s) then exit
if Distance(0, 0, 0, x, y, z) > 512 - srad then exit
next s
until s > i
position object i, x, y, z
next i
make object plain 101, 1024, 1024
pitch object up 101, 90
set reflection shading on 101
make object sphere 102, 1024 , 32, 32
set object cull 102, 0
cam.speed = 0.0005 + rnd(10) * 0.0001
cam.state = 0.0
repeat
cam.x1 = rnd(1024) - 512
cam.y1 = srad + rnd(512)
cam.z1 = rnd(1024) - 512
until Distance(0, 0, 0, cam.x1, cam.y1, cam.z1) < 512 - srad
repeat
cam.x2 = rnd(1024) - 512
cam.y2 = srad + rnd(512)
cam.z2 = rnd(1024) - 512
until Distance(0, 0, 0, cam.x2, cam.y2, cam.z2) < 512 - srad
repeat
position camera x#, y#, z#
rotate camera x#, y# , z#
x# = CosInt(cam.x1, cam.x2, cam.state)
y# = CosInt(cam.y1, cam.y2, cam.state)
z# = CosInt(cam.z1, cam.z2, cam.state)
cam.state = cam.state + cam.speed
if cam.state > 1.0
cam.speed = 0.0010 + rnd(20) * 0.0001
cam.x1 = camera position x()
cam.y1 = camera position y()
cam.z1 = camera position z()
cam.state = 0.0
repeat
cam.x2 = rnd(1024) - 512
cam.y2 = srad + rnd(512)
cam.z2 = rnd(1024) - 512
until Distance(0, 0, 0, cam.x2, cam.y2, cam.z2) < 512 - srad
endif
set cursor 0, 0
print screen fps()
inc o : if o > smax then o = 1
SyncCams(o)
until mouseclick()
end
function Distance(x1, y1, z1, x2, y2, z2)
r = make vector3(1)
set vector3 1, x1 - x2 , y1 - y2, z1 - z2
d = length vector3(1)
endfunction d
function SphereColli(x, y, z, s)
if Distance(x, y, z, object position x(s), object position y(s), object position z(s)) < srad * 2
f = 1
else
f = 0
endif
endfunction f
function CosInt(a#, b#, c#)
f# = (1 - cos(c# * 180.0)) / 2
r# = a# * (1 - f#) + b# * f#
endfunction r#
function SyncCams(o)
restore camdata
for c = 1 to 6
make camera c
read x, y, z
rotate camera c, x, y, z
position camera c, object position x(o), object position y(o), object position z(o)
set camera aspect c, 1.0
set camera fov c, 90
set camera to image c, c, 128, 128
next c
sync
for c = 1 to 6 : delete camera c : next c
set cube mapping on o, 1, 2, 3, 4, 5, 6
camdata:
data 0, 90, 0
data 0, 270, 0
data 270, 0, 0
data 90, 0, 0
data 0, 0, 0
data 0, 180, 0
endfunction