Flying Turtles (3d)

Help Contents Examples Flying Turtles (3d)
Floor_map (one 3d storey of a house) Hanoi (3d Towers of Hanoi solver)

Flying Turtles (3d)

This 3d example shows a bundle of nice textured turtles flying around in wild circles.

run "graphix

make "t 0
make "D 25

to changeview
	make "t :t+3
	lookat vector :D * (cos :t) :D * (sin :t) :D * (sin :t) vector 0 0 0 vector 0 0 1
end

;turtle image

make "turtle_tex texture "turtle.bmp


to turtle_image

	make "O vector 0 0 0

	make local "m 2
	make local "l "true
	make local "s "false
	make local "p 12

	make local "cover styled (sphere :O 1) (set
		"mode :m
		"color rgb_  1/2  1/2  1/2
		"light :l
		"smooth :s
		"rangev.fromangle 0
		"rangev.toangle 180
		"radius 0.8
		"radiusy 0.7
		"radiusz 1
		"texture :turtle_tex
		"precision :p)

	make local "cover1 styled (sphere :O 1) (set
		"mode :m
		"color rgb_  1/2  1/2  1/4
		"light :l
		"smooth :s
		"rangev.fromangle 180
		"rangev.toangle 360
		"radius 0.8
		"radiusy 0.3
		"radiusz 1
		"texture :turtle_tex
		"precision :p)
	make local "tail styled (sphere vector 0 0 -0.5) (set
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.3
		"radiusy 0.15
		"radiusz -0.7
		"precision :p)

	make local "head styled (sphere vector 0 0.1 0.8) (set
		"focus vector 0 0.2 1
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.3
		"radiusy 0.2
		"radiusz 0.7
		"precision :p)

	make local "lhand styled (sphere vector -0.3 0 0.2) (set
		"focus vector 2 0.5 -3
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.2
		"radiusy 0.1
		"radiusz 0.8
		"precision :p)
	make local "rhand styled (sphere vector 0.3 0 0.2) (set
		"focus vector -2 0.5 -3
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.2
		"radiusy 0.1
		"radiusz 0.8
		"precision :p)

	make local "lhand1 styled (sphere vector -0.8 -0.1 0.8) (set
		"focus vector 1 0.2 0
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.1
		"radiusy 0.07
		"radiusz 0.2
		"precision :p)
	make local "rhand1 styled (sphere vector 0.8 -0.1 0.8) (set
		"focus vector 1 0.2 0
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.1
		"radiusy 0.07
		"radiusz 0.2
		"precision :p)

	make local "lleg styled (sphere vector -0.3 0 -0.2) (set
		"focus vector -2 -0.5 -3
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.2
		"radiusy 0.1
		"radiusz 0.8
		"precision :p)
	make local "rleg styled (sphere vector 0.3 0 -0.2) (set
		"focus vector 2 -0.5 -3
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.2
		"radiusy 0.1
		"radiusz 0.8
		"precision :p)
	make local "lleg1 styled (sphere vector -0.7 -0.1 -0.8) (set
		"focus vector 1 0.2 2
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.1
		"radiusy 0.07
		"radiusz 0.2
		"precision :p)
	make local "rleg1 styled (sphere vector 0.7 -0.1 -0.8) (set
		"focus vector 1 0.2 -2
		"mode :m
		"color rgb_  1/4  1/8  0
		"light :l
		"smooth :s
		"radiusx 0.1
		"radiusy 0.07
		"radiusz 0.2
		"precision :p)

	to ondrawimage 
	end
end

make "a.ti turtle_image

to tortoise :center

	make local "spin 0
	make local "slope 0

	to ondrawimage
		pushmatrix
		spinx 90
		spiny :spin+180
		spinz :slope
		ondrawimagenow "a.ti
		popmatrix
	end
end

make "t 45
make "q 0
changeview

print 666
make "ta tortoise point 4 0 0
make "tb tortoise point -4 0 0
make "tc tortoise point -4 0 0
make "td tortoise point -4 0 0
make "te tortoise point -4 0 0
print 777

to xxx
	make "tc.center point 9*(cos :t+:q*1.5) 9*(sin :t+:q*1.5) 3*(sin :t+:q)
	make "tc.spin :t+:q*1.5
	make "tc.slope 30*(sin 10*:t)

	make "td.center point 8.2*(cos :t+:q*2) 8.2*(sin :t+:q*2) 3*(sin :t+2*:q)
	make "td.spin :t+:q*2
	make "td.slope 70*(sin 4*:t)

	make "ta.center point 6*(cos :t) 6*(sin :t) 3*(sin :t)
	make "ta.spin :t
	make "ta.slope 120*(sin 4*:t)

	make "tb.center point 7.5*(cos :t+:q) 7.5*(sin :t+:q) 3*(cos 1.5*:t)
	make "tb.spin :t+:q
	make "tb.slope 30*(sin 8*:t)

	make "te.center point 5*(cos :t+:q*2.5) 5*(sin :t+:q*2.5) 4*(cos 2.5*:t)
	make "te.spin :t+:q*2.5
	make "te.slope 100*(sin 2*:t)

	;make "tb.center point 5*(cos (2*:t)) 5*(sin :t) 0
	;  lookat vector :D * (cos 0-:t/5) :D * (sin 0-:t/5) :D*(sin :t) vector 0 0 0 vector sin :t cos :t 1
	;  lookat vector :D  0 0 vector 0 0 0 vector 0 0 1
end

make "onbeforedraw.fog fog "true 50 20 0.1 rgb_  1  0.9  0.8
make "onbeforedraw.clearcolor clearcolor 255 220 200

repeat 10000 
[
	xxx
	make "q :q+1
	make "t :t+2.1
	;changeview
]

Floor_map (one 3d storey of a house) Hanoi (3d Towers of Hanoi solver)