Nice work (See attached gif)
It's not a bug in the rendering nor in your code.
It's all a matter of proper lighting (just as it would be
in the physical world).
Poor lighting won't show your work as well as good lighting.
There are several things that effect how something will look.
SETLIGHT [Ambient Diffuse] (how bright the light source is and
how the object relects light)
TURTLE -1 (position which is where your looking from)
TURTLE -3 (position which is where the light source is from)
These all have reasonable defaults that generally do a good job
and novices can leave them at the defaults. But if you want better
looking results try reading up on these parameters and experiment with
them.
The two dice I recently posted was tricky because they are "White"
dice. Since all sides are white how can the seams be seen?
Because the rendering will adjust the color to proper shades of light
grey. The position of the light was critical to make the dice look
good.
You need to think about the colors you choose as well.
Full strength colors (255) leave the rendering engine less
elbow room to work with.
I added "better" lighting to your code.
to aaa
; Draws an icosahedron.
;
; Two basic movement primitives are defined.
; ne (next edge) moves to the next edge clockwise on the current face.
; nr (next-right) moves to the next face to the right.
; repeat 5 [nr] returns to the original position.
;
; The turtle draws five bars of four triangles around the icosahedron.
ico 200
end
to fourtri
make "col :col + 1
setpc :col
tri tri ne tri tri
repeat 2 [nr nr ne]
nr
end
to ico :size
; Define some constants
localmake "phi (1 + sqrt 5) / 2
localmake "beta arcsin (:phi / sqrt 3)
localmake "alpha 180-2*:beta ; 180-angle between unconnected vertices of two hinged faces
cs
perspective
ask -1 [setposxyz [100 -500 600]]
localmake "col 0
repeat 5 [fourtri]
ask -3 [setposxyz [-194 177 22]] ; Arrived at by trial and error see below
setsc [0 0 0]
polyview
; Show sample lighting
; repeat 36 [ask -3 [setxyz 200 - random 400 200 - random 400 200 - random 400 show posxyz] wait 60]
; Now fly around
repeat 36 [ask -1 [fd 200 down 10] wait 10]
end
to ne
pu fd :size rt 120
end
to nr
pu rt 60 fd :size lt 120 rr :alpha
end
to tri
pd polystart repeat 3 [fd :size rt 120] polyend nr
end
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