setscreen ("offscreenonly")
const faces := 8
const perspective := 250
var xpp : array 1 .. faces, 1 .. 3 of real := init (-50, 0, 50, 50, 0, 50, -50, 0, 50, -50, 0, -50, -50, 0, 50, 50, 50, 50, -50, 0, 50, -50, -50, -50)
var ypp : array 1 .. faces, 1 .. 3 of real := init (0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0, -50, 0, 0, -50, 0, 0, -50, 0, 0, -50, 0)
var zpp : array 1 .. faces, 1 .. 3 of real := init (50, 0, 50, 50, 0, -50, -50, 0, -50, -50, 0, 50, 50, 50, 50, 50, 0, -50, -50, -50, -50, -50, 0, 50)
var xp : array 1 .. faces, 1 .. 3 of real
var yp : array 1 .. faces, 1 .. 3 of real
var zp : array 1 .. faces, 1 .. 3 of real
var x : array 1 .. 3 of int
var y : array 1 .. 3 of int
var z : array 1 .. 3 of int
var ax, ay, az : int := 0
var mx, my, md : int
procedure rotate (face : int)
var temp : real
for i : 1 .. 3
yp (face, i) := ypp (face, i) * cosd (ax) - zpp (face, i) * sind (ax)
zp (face, i) := zpp (face, i) * cosd (ax) + ypp (face, i) * sind (ax)
temp := zp (face, i)
zp (face, i) := zp (face, i) * cosd (ay) - xpp (face, i) * sind (ay)
xp (face, i) := xpp (face, i) * cosd (ay) + temp * sind (ay)
temp := xp (face, i)
xp (face, i) := xp (face, i) * cosd (az) - yp (face, i) * sind (az)
yp (face, i) := yp (face, i) * cosd (az) + temp * sind (az)
x (i) := round (xp (face, i) / (1 - zp (face, i) / perspective)) + maxx div 2
y (i) := round (yp (face, i) / (1 - zp (face, i) / perspective)) + maxy div 2
end for
end rotate
loop
drawfillbox (0, 0, maxx, maxy, 200)
mousewhere (mx, my, md)
ax := my mod 360
ay := mx mod 360
for i : 1 .. faces
rotate (i)
drawpolygon (x, y, 3, black)
end for
View.Update
end loop |