/*
 * sub.h - include file depecting a generic fast attack submarine
 *
 * It should be easy to add more details, such as a periscope and
 * vent holes for close-up scenes if desired.
 *
 * Stuart Warmink
 * sw@groucho.att.com, November 1992
 *
 * Feel free to use and/or distribute for non-commercial purposes as long
 * as this header remains with the file.
 */

define	Center_hull_len		(4)
define	Bow_len			(4)
define	Stern_len		(9)

define	Oval_factor		(1.1)
define	Deck_level		(0.95)

define	Sail_wid		(0.3)
define	Sail_front		(0.6)
define	Sail_rear		(1.2)
define	Sail_height		(2.0)	/* From centerline */
define	Sail_to_bow		(0)	/* From origin to "center" of sail */

define	Fin_wid			(0.3)
define	Fin_dep			(0.05)
define	Fin_len			(0.95)
define	Fin_from_rear		(2)	/* From rear to "center" of tailfin */
define	Fin_from_top		(0.4)	/* From top of sail */



/* Generic objects that can be scaled and translated etc. later */

name	unit_cylinder		/* along z axis */
	list
		disc		1	0 0 1	0 0 1
		cylinder	1	0 0 0	0 0 1
		disc		1	0 0 0	0 0 -1
	end

name	unit_sphere
	sphere			1	0 0 0

name	unit_box
	box			1 1 0	-1 -1	1

/* Build a pair of fins */

name	ver_fin
	list
		object	unit_cylinder
			scale	(Fin_wid) (Fin_dep) (1)
		object	unit_cylinder
			rotate	1 0 0	180
			scale	(Fin_wid) (Fin_dep) (1)
	end

name	hor_fin
	list
		object	unit_cylinder
			rotate	1 0 0	90
			scale	(Fin_wid) 1 (Fin_dep)
		object	unit_cylinder
			rotate	1 0 0	270
			scale	(Fin_wid) 1 (Fin_dep)
	end

name	tail_fins
	union
		object	ver_fin
		object	hor_fin
	end


/* Build main hull */

name	bow
	difference
		object	unit_sphere
			scale	(Bow_len) 1 (Oval_factor)
		object	unit_box
			rotate		0 1 0	-90
			scale	((Bow_len)+1) 2 ((Oval_factor)+1) 
	end

name	stern
	union
		difference
			object	unit_sphere
				scale	(Stern_len) 1 (Oval_factor)
			object	unit_box
				rotate		0 1 0	90
				scale	((Stern_len)+1) 2 ((Oval_factor)+1)
		end
		object	tail_fins
			translate
			(-1*(((Center_hull_len)/2)+(Stern_len)-(Fin_from_rear))) 0 0
	end

name	center
	union
		object	unit_cylinder
			rotate		0 1 0	90
			scale	((Center_hull_len)/2) 1 (Oval_factor)
		object	unit_cylinder
			rotate		0 1 0	-90
			scale	((Center_hull_len)/2) 1 (Oval_factor)
	end

name 	basic_hull
	difference
		union
			union
				object bow
					translate	((Center_hull_len)/2) 0 0
				object	center
			end
			object stern
				translate	(-1*((Center_hull_len)/2)) 0 0
		end
		object	unit_box
			scale		10 10 2
			translate	0 0 (Deck_level)
	end

/* Build sail */

name	sail_front
	difference
		object	unit_cylinder
			scale	(Sail_front) (Sail_wid) (Sail_height)
		object	unit_box
			rotate		0 1 0	-90
			scale	((Sail_front)+1) ((Sail_wid)+1) ((Sail_height)+1)
	end

name	sail_rear
	difference
		object	unit_cylinder
			scale	(Sail_rear) (Sail_wid) (Sail_height)
		object	unit_box
			rotate		0 1 0	90
			scale	((Sail_rear)+1) ((Sail_wid)+1) ((Sail_height)+1)
	end

name	sail
	union
		union
		
			object	sail_front
			object	sail_rear
		end
		object	hor_fin
			translate	0 0
					((Sail_height)-(Fin_from_top))
	end

/* Make up full hull structure */

name	hull
	union
		object	basic_hull
		object	sail
			translate	(Sail_to_bow) 0 0
	end

name	sub
grid	10 5 5 
	object	hull
		texture bump 0.05
			scale	0.1 0.1 0.1
end
