See GIF attachment
to aaa
;
; This example draws two dice as 3D solids.
;
perspective
cs
setsc [0 0 0]
; These parameters were chosen by trial and error with the code disabled at the bottom
ask -3 [setposxyz [185 -24 -72]]
setlight [0.1 0.36]
; Draw 2 dice
dice
rt 90
fd 125
lt 90
rr 180
down 90
dice
; Render them solid
polyview
; Fly around them
repeat 36 [ask -1 [fd 200 down 10] wait 10]
; Save a picture
gifsave "dice.gif
; I used this code below to find good light position and properties
stop
repeat 100 ~
[
ask -3 [setxyz (200 - random 400) (200 - random 400) (200 - random 400) show posxyz]
setlight (list (random 100)/100 (random 100)/100)
show light
MessageBox [] []
]
end
to dice
repeat 4 [face repcount down 90]
rr 90
down 90
face 5
down 180
face 6
down 90
lr 90
end
to dots :n
; Note I may have the wrong dots on the wrong faces.
if :n = 1 ~
[
pd
polystart
circle 10
polyend
pu
]
if :n = 2 ~
[
lt 45
fd 30
repeat 2 [dots 1 bk 60]
fd 2*60-30
rt 45
]
if :n = 3 ~
[
dots 2
dots 1
]
if :n = 4 ~
[
dots 2
rt 90
dots 2
lt 90
]
if :n = 5 ~
[
dots 4
dots 1
]
if :n = 6 ~
[
dots 4
repeat 2
[
rt 45
fd 30
rt 135
fd sqrt (30*30/2)
dots 1
bk sqrt (30*30/2)
lt 135
bk 30
lt 45
rt 180
]
]
end
to face :n
; Working from the center move outward to the face and draw a grey square surface
fd 50
down 90
fd 50
lt 90
fd 50
pd
setpc [128 128 128]
polystart
repeat 4 [lt 90 fd 100]
polyend
pu
bk 50
rt 90
bk 50
up 90
; Draw the dots in black slightly raised above the surface of the cube
fd 1
down 90
setpc [0 0 0]
dots :n
up 90
bk 1
bk 50
end
===============================================================
George Mills
email: mills@softronix.com
http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home