aUCBLogo Demos and Tests / house2
to house2 [size 300]
local
[ hsize bricks rooftiles tex
doorwitdh doorheight doorx doorstep doorpos doorori
]
cs ht
grass=loadImage "grass.jpg
texGrass=Texture grass
bricks=loadImage "bricks.png
texBricks=Texture bricks
rooftiles=loadImage "rooftiles.png
texRooftiles=Texture rooftiles
horizon=1e4
hsize=size/2
sizey=size/2*(1+sqrt 3)
wall=hsize/10
setLightAmbient rgb .4 .4 .4
perspective
green=hsb 60 0.4 0.1
setPC "white
pu rr 30 down 180 fd hsize up 90
enableTexture
Texture texGrass
draw_plane
lt 180 fd hsize rt 90 fd hsize lr 90 rt 90
openpos=[]
openori=[]
pink=hsb 0 0.3 0.7
setpc "white ;pink
Texture texBricks
double [draw_front] down 90 fd size up 90 lr 90
double [draw_side] down 90 fd size up 90 lr 90
double [draw_back] down 90 fd size up 90 lr 90
double [draw_side]
fd hsize down 30 bk wall lt 90 fd wall rt 90
Texture texRooftiles
draw_roof
fd size+wall down 120 fd size+wall rt 90 fd size+2*wall rt 90
draw_roof
setPC "white
Texture texBricks
draw_openings
rotateScene2
end
to double runlist
double? = false
run runlist
down 90 fd wall up 90
double? = true
run runlist
down 90 bk wall up 90
end
to add_open
if not double?
[ push "openpos posXYZ
push "openori Orientation
push "openheight height
push "openwidth width
]
end
to save_pos
opos=posXYZ
oori=Orientation
end
to reset_pos
pu
setPosXYZ opos
setOrientation oori
end
to draw_plane
save_pos
fd horizon rt 90 fd horizon rt 90
setpc hsb 60 0.3 0.7
pd
PolyStart
setTexXY 0 300 fd horizon*2 rt 90
setTexXY 300 300 fd horizon*2 rt 90
setTexXY 300 0 fd horizon*2 rt 90
setTexXY 0 0 fd horizon*2 rt 90
PolyEnd
reset_pos
end
to draw_openings
while [not empty? openpos]
[ setPosXYZ pop "openpos
setOrientation pop "openori
width=pop "openwidth
height=pop "openheight
rr 90
pd
repeat 2
[ PolyStart
myTexXY 0 height fd height rt 90
myTexXY wall height fd wall rt 90
myTexXY wall 0 fd height rt 90
myTexXY 0 0 fd wall rt 90
PolyEnd
pu fd height up 90 pd
PolyStart
myTexXY 0 width fd width rt 90
myTexXY wall width fd wall rt 90
myTexXY wall 0 fd width rt 90
myTexXY 0 0 fd wall rt 90
PolyEnd
pu fd width up 90 pd
]
pu
]
end
to myTexXY x y
setTexXY 5*x/size 5*y/sizey
end
to drawWindow
reset_pos
rt 90 fd winx lt 90 fd winy
add_open
pd
myTexXY winx height+winy fd height rt 90
myTexXY winx+width height+winy fd width rt 90
myTexXY winx+width winy fd height rt 90
myTexXY winx winy fd width
end
to drawFrontOut
save_pos
pd
myTexXY 0 hsize fd hsize rt 30
myTexXY size/2 sizey fd size rt 120
myTexXY size hsize fd size rt 30
myTexXY size 0 fd hsize rt 90
myTexXY 0 0 fd size rt 90
end
to draw_front
TessStart
drawFrontOut
TessContour
height=size*3/8
width=height*1/2
winx=size/4
winy=height/8
drawWindow
TessContour
height=size*3/12
width=height*3/2
winx=size*9/16
winy=height*6/8
drawWindow
TessContour
height=size*3/12
width=height*3/2
winx=size*5/16
winy=hsize+winy
drawWindow
TessEnd
reset_pos
end
to draw_back
TessStart
drawFrontOut
TessContour
height=size*3/12
width=height*3/2
winx=size*1/16
winy=height*6/8
drawWindow
TessContour
winx=size*9/16
drawWindow
TessContour
height=size*3/12
width=height*3/2
winx=size*5/16
winy=hsize+winy
drawWindow
TessEnd
reset_pos
end
to draw_side
TessStart
save_pos
pd
myTexXY 0 hsize fd hsize rt 90
myTexXY size hsize fd size rt 90
myTexXY size 0 fd hsize rt 90
myTexXY 0 0 fd size rt 90
TessContour
height=size*3/12
width=height*3/2
winx=size*1/16
winy=height*6/8
drawWindow
TessContour
winx=size*9/16
drawWindow
TessEnd
reset_pos
end
to draw_roof
pd
red=hsb 0 1 1
setPC red
PolyStart
myTexXY 0 size+wall fd size+wall rt 90
myTexXY size+2*wall size+wall fd size+2*wall rt 90
myTexXY size+2*wall 0 fd size+wall rt 90
myTexXY 0 0 fd size+2*wall rt 90
PolyEnd
pu
end