House (3d)

Help Contents Examples House (3d)
Honey (3d) Icosahedron (3d)

House (3d)

Example:   House
File name:	House.eli
Modified:  May 19, 2000
Author:    Pavel Christov Boychev
Version:   5.0
E-mail:    pavel@elica.net

Copyright © 1999-2000 Elica Group

This example shows the construction of a house. Each floor has a labyrinth.

Note the similarity of the more complex commands to Scheme!

run "graphix

; Define the point of view change procedure
make "t 0

to changeview
	make "t :t+1
	(lookat 
		point  12*(cos :t)  12*(sin :t)  5+5*(sin 2*:t) 
		vector 0 0 0 
		vector 0 0 1
	)
end

make "n 0.5

; A procedure for building a floor's labyrinth
make "w 0

to maze :z

	local "i "j

	make "i -4
	repeat 8
	[
		make "j -4
		repeat 8
		[
			make "w :w+1
			make "wname word "w :w

			(make :wname 
				(styled 
					polygon 
						(set 
							point  0   0  0
							point :n   0  0
							point :n :n/5 0
							point  0 :n/5 0
						)
					(set
						"mode 2
						"color rgb_  0.2  0  0
						"focus point 0 1 0
						"center point :i*:n :j*:n :z+:n/5
					)
				)
			)
			if (random) > 0.5
			[
				make (:wname)("focus) point 1 0 0
				make (:wname)("spin) -90
				make (:wname)("center.y) (:j+1)*:n
			]
			changeview
			make "j :j+1
		]
		make "i :i+1
	]
end

; A defintion of a supporting object
to support :s1 :s2

	run bf :cylinder

	make local "center point 4*:n*:s1  4*:n*:s2  -2*:n
	make local "mode 2
	make local "color rgb_  0.85  0.75  0.5
	make local "radius 0.05
	make local "light "true
	make local "radiusz :n
end

; Defining four edge supporting objects
make "c00 support -1 -1
make "c10 support  1 -1
make "c01 support -1  1
make "c11 support  1  1

; Cycle for creating different floors
make "f (-2)
repeat 5
[
	make "z :f*:n
	changeview

	(make word "f :f 
		(styled 
			polygon 
				(set 
					point (-4*:n) (-4*:n) :z
					point (+4*:n) (-4*:n) :z
					point (+4*:n) (+4*:n) :z
					point (-4*:n) (+4*:n) :z
				) 
			(set
				"mode 2
				"color rgb_  0.6+:f*0.1  0.6+:f*0.1  0.6+:f*0.1
			)
		)
	)
	(make word "fr :f 
		(styled 
			polygon 
				(set 
					point (-4*:n) (-4*:n) :z
					point (+4*:n) (-4*:n) :z
					point (+4*:n) (+4*:n) :z
					point (-4*:n) (+4*:n) :z
				)
			(set
				"mode 1
				"color rgb 0 0 0
			)
		)
	)
	changeview

	make "c00.radiusz (:f+3)*:n
	make "c10.radiusz (:f+3)*:n
	make "c01.radiusz (:f+3)*:n
	make "c11.radiusz (:f+3)*:n

	make "f :f+1
	changeview
	maze :z
]

; Now let's add a roof
(make "roof 
	(styled 
		polygon 
			(set 
				point 0 0 :z+2
				point (-4*:n-0.2) (-4*:n-0.2) :z+:n
				point (+4*:n+0.2) (-4*:n-0.2) :z+:n
				point (+4*:n+0.2) (+4*:n+0.2) :z+:n
				point (-4*:n-0.2) (+4*:n+0.2) :z+:n
				point (-4*:n-0.2) (-4*:n-0.2) :z+:n
			)
		(set
			"mode 2
			"color rgb 0 0 0
			"multicolor "true
		)
	)
)
make "roof.points.#2.color rgb_  0.75  0  0

; And rotate everything a while
repeat 1000 [ changeview ]

Honey (3d) Icosahedron (3d)