some funny cubes in a picture frame ...
if check display mode(1280, 1024, 32)
set display mode 1280, 1024, 32
else
set display mode 1024, 768, 32
endif
sync on : sync rate 60 : autocam off : color backdrop 0
set ambient light 50
MakeFrame(1, 16, 12)
position object 1, 0, 0, 10014
make camera 1
set camera to image 1, 1, 640, 480
texture limb 1, 0, 1
make object plain 2, 1024, 1024
pitch object up 2, 90
set reflection shading on 2
make object sphere 3, 1024, 32, 32
set object cull 3, 0
set object ambient 3, 0
color object 3, rgb(128, 128, 255)
for o = 4 to 9
MakeVectorCube(o, 64)
next o
restore CubeData
for o = 4 to 9
read a, x, y, z,
read r, g, b
yrotate object o, a
position object o, x, y, z
color object o, rgb(r, g, b)
next o
t = timer() + 5000 : r = 250
repeat
if timer() > t
for o = 4 to 9
RandVectorCube(o, 64, r)
t = timer() + 50
next o
if r > 10 then dec r
endif
rotate camera sin(a#) * 3, cos(a#), sin(a#) * 7
position camera 0, 0, 10000 + cos(a# / 2)
set camera to follow 1, 0, 0, 0, a#, 400, 128 + sin(a#) * 64, 1, 0
point camera 1, 0, 0, 0
a# = a# + 0.7
sync
until mouseclick()
end
CubeData:
data 25, 64, 32, -32, 255, 0, 0
data 75, -32, 32, 64, 0, 255, 0
data 0, -32, 32, -64, 0, 0, 255
data 15, 16, 96, -32, 255, 0, 255
data 45, 24, 32, -130, 255, 255, 0
data 50, 64, 32, 96, 0, 255, 255
function MakeFrame(o, w, h)
make object sphere o, 1
make mesh from object o, 1
make object cylinder o + 1, 1
zrotate object o + 1, 90
scale object o + 1, 100, 100 * w, 100
make mesh from object o + 1, o + 1
make object cylinder o + 2, 1
scale object o + 2, 100, 100 * h, 100
make mesh from object o + 2, o + 2
make object plain o + 3, w, h
make mesh from object o + 3, o + 3
for i = o to o + 3 : delete object i : next i
restore FrameData
make object plain o, w - 4, h - 4
for l = 1 to 9
read m, x, y
add limb 1, l, m
offset limb 1, l, x * 0.5 * w, y * 0.5 * h, 0
next l
for i = o to o + 3 : delete mesh i : next i
set object ambient o, 0
set object transparency o, 2
color object o, rgb(80, 80, 160)
set object emissive o, 120
create bitmap 1, 640, 480
ink -1, 0
box 0, 0, 640, 480
ink 0, 0
box 80, 80, 560, 400
set text font "courier new"
set text size 32
set text to bolditalic
ink rgb(128, 128, 0), 0
center text 320, 40, "Live Cubes"
center text 320, 410, "(C)ode by Jukuma"
mirror bitmap 1
blur bitmap 1, 3
get image 9, 0, 0, 640, 480
texture limb o, 9, 9
delete bitmap 1
FrameData:
data 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1
data 2, 0, 1, 2, 0, -1, 3, -1, 0, 3, 1, 0, 4, 0, 0
endfunction
function MakeVectorCube(o, s)
s = s >> 1
make object triangle o, 0, 0, 0, 0, 0, 0, 0, 0, 0
make mesh from object o, o
set object wireframe o, 1
restore VectorData
lock vertexdata for limb o, 0
for p = 1 to 12
read x1, y1, z1
read x2, y2, z2
add mesh to vertexdata o
v = get vertexdata index count()
set vertexdata position v, x1 * s, y1 * s, z1 * s
set vertexdata position v + 1, x2 * s, y2 * s, z2 * s
set vertexdata position v + 2, x2 * s, y2 * s, z2 * s
next p
unlock vertexdata
delete mesh o
VectorData:
data -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1
data -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1
data -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1
data -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1
data -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1
data -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1
endfunction
function RandVectorCube(o, s, r)
s = s >> 1
restore VectorData
lock vertexdata for limb o, 0
for v = get indexdata(0) to get vertexdata index count() step 3
read x1, y1, z1
read x2, y2, z2
x1 = x1 * s + rnd(r) - (r >> 1) : y1 = y1 * s + rnd(r) - (r >> 1) : z1 = z1 * s + rnd(r) - (r >> 1)
x2 = x2 * s + rnd(r) - (r >> 1) : y2 = y2 * s + rnd(r) - (r >> 1) : z2 = z2 * s + rnd(r) - (r >> 1)
set vertexdata position v, x1, y1, z1
set vertexdata position v + 1, x2, y2, z2
set vertexdata position v + 2, x2, y2, z2
next v
unlock vertexdata
endfunction