do roadster_pic;


include 'engine.smpl';


object tire is
	cylinder with end1 = 0 -3 0; end2 = 0 3 0; radius = 15; end;
	cylinder with end1 = 0 -3 0; end2 = 0 3 0; radius = 10; end;
	ring with center = 0 3 0; normal = 0 1 0;
		inner_radius = 10; outer_radius = 15; end;
	ring with center = 0 -3 0; normal = 0 1 0;
		inner_radius = 10; outer_radius = 15; end;
end;	{tire}


object wheel is
	flat grey tire; 
	flat white ring with 
		center = 0 2 0; normal = 0 1 0;
		inner_radius = 8; outer_radius = 10;
	end;	{whitewalls}
	flat white cone with end1 = 0 2 0; end2 = 0 4 0;
		radius1 = 8; radius2 = 0;
	end; 
	sphere with center = 0 2 0; radius = 3; end;
end;	{wheel}	


object axel is
	flat white cylinder with 
		end1 = 0 25 0; end2 = 0 -25 0; radius = 2;
	end; 
	wheel with move to 0 25 0; end;
	wheel with rotate by 180 around 0 0 1; move to 0 -25 0; end;
end;	{axel}


object fender is
	{footstep}
	polygon [(-20 -5 0) (20 -5 0) (20 5 0) (-20 5 0)];
	
	{front fender}
	polygon [(-65 -5 20) (-20 -5 0) (-20 5 0) (-65 5 20)];
	polygon [(-75 -5 20) (-65 -5 20) (-65 5 20) (-75 5 20)];
	polygon [(-75 -5 20) (-85 -5 10) (-85 5 10) (-75 5 20)];

	{rear fender}
	polygon [(40 -5 20) (20 -5 0) (20 5 0) (40 5 20)];
	polygon [(40 -5 20) (50 -5 20) (50 5 20) (40 5 20)];
	polygon [(50 -5 20) (60 -5 10) (60 5 10) (50 5 20)];
end;	{fender}


object hood is
	polygon [(0 -10 10) (50 -10 10) (50 0 0) (0 0 0)];
	polygon [(0 -10 10) (50 -10 10) (50 -20 10) (0 -20 10)];
	polygon [(0 -20 10) (50 -20 10) (50 -30 0) (0 -30 0)];
end;	{hood}


object body is
	{front}
	polygon [(-70 15 0) (-70 15 20) (-70 5 30)
			 (-70 -5 30) (-70 -15 20) (-70 -15 0)];
	
	{dashboard}
	polygon [(-20 15 0) (-20 15 20) (-20 5 30)
			 (-20 -5 30) (-20 -15 20) (-20 -15 0)];
	
	{sides}
	polygon [(-70 -15 0) (-20 -15 0) 
			 (-20 -15 20) (-70 -15 20)];
	polygon [(-70 15 0) (-20 15 0)
			 (-20 15 20) (-70 15 20)];

	{triangular piece in front of seat}
	polygon [(0 -20 0) (-20 -15 20) (-20 -15 0)];
	polygon [(0 20 0) (-20 15 20) (-20 15 0)];

	{sides in back}
	polygon [(0 -20 0) (60 -20 0) (60 -20 10) (0 -20 10)];
	polygon [(0 20 0) (60 20 0) (60 20 10) (0 20 10)];
	
	{vertical piece under seats}
	polygon [(0 -20 0) (0 -20 10) (0 20 10) (0 20 0)];
	
	{floor under seats}
	polygon [(0 -20 10) (60 -20 10) (60 20 10) (0 20 10)];
end;	{body}


object seat_back is
	sphere with center = 0 -5 20; radius = 3; end;
	sphere with center = 0 5 20; radius = 3; end;
	cylinder with end1 = 0 0 0; end2 = 0 0 20; radius = 3; end;
	cylinder with end1 = 0 -5 0; end2 = 0 -5 20; radius = 3; end;
	cylinder with end1 = 0 5 0; end2 = 0 5 20; radius = 3; end;
	cylinder with end1 = 0 5 20; end2 = 0 -5 20; radius = 3; end;
end;	{seat_back}


object seat is
	seat_back with 
		rotate by 15 around 0 1 0;	{tilt seat back}
		move to  8 0 0;
	end;
	cylinder with end1 = 8 5 0; end2 = 8 -5 0; radius = 3; end;
	sphere with center = -8 5 0; radius = 3; end;
	sphere with center = -8 -5 0; radius = 3; end;
	sphere with center = 8 5 0; radius = 3; end;
	sphere with center = 8 -5 0; radius = 3; end;
	cylinder with end1 = -8 0 0; end2 = 8 0 0; radius = 3; end;
	cylinder with 
		end1 = -8 5 0; end2 = -8 -5 0; radius = 3;
	end;	{front of seat}
	cylinder with 
		end1 = -8 5 0; end2 = 8 5 0; radius = 3;
	end;	{side of seat}
	cylinder with 
		end1 = -8 -5 0; end2 = 8 -5 0; radius = 3;
	end;	{side of seat}
end;	{seat}


object gas_tank is
	cylinder with end1 = 0 -16 0; end2 = 0 16 0; radius = 10; end;
	paraboloid with top = 0 -19 0; base = 0 -16 0; radius = 10; end;
	paraboloid with top = 0 19 0; base = 0 16 0; radius = 10; end;
end;	{gas_tank}
	
	
object trunk is
	block with
		vertex = 0 -15 0;
		side1 = 30 0 0;
		side2 = 0 30 0;
		side3 = 0 0 30;
	end;
end;	{trunk}


object hitch is
	cylinder with end1 = 0 0 0; end2 = 0 0 6; radius = 1; end;
	sphere with center = 0 0 6; radius = 2; end;
end;	{hitch}	


object steering_wheel is
	metallic white cylinder with 
		end1 = 0 0 10; end2 = 0 0 20; radius = 1;
	end;
	metallic white cylinder with
		end1 = -8 0 20; end2 = 8 0 20; radius = .8;
	end; 
	metallic white cylinder with
		end1 = 0 -8 20; end2 = 0 8 20; radius = .8;
	end; 
	flat grey cylinder with
		end1 = 0 0 19.5; end2 = 0 0 20.5; radius = 8;
	end; 
	flat grey ring with
		center = 0 0 20.5; normal = 0 0 1;
		inner_radius = 7; outer_radius = 8;
	end; 
	disk with center = 0 0 20.5; normal = 0 0 1; radius = 2; end;
end;	{steering_wheel}


{
object engine is
	cylinder with end1 = -10 -5 0; end2 = -10 -5 25; radius = 5; end;
	disk with center = -10 -5 25; normal = 0 0 1; radius = 5; end;
	cylinder with end1 = -10 5 0; end2 = -10 5 25; radius = 5; end;
	disk with center = -10 5 25; normal = 0 0 1; radius = 5; end;
	cylinder with end1 = 0 -5 0; end2 = 0 -5 25; radius = 5; end;
	disk with center = 0 -5 25; normal = 0 0 1; radius = 5; end;
	cylinder with end1 = 0 5 0; end2 = 0 5 25; radius = 5; end;
	disk with center = 0 5 25; normal = 0 0 1; radius = 5; end;	
	cylinder with end1 = 10 -5 0; end2 = 10 -5 25; radius = 5; end;
	disk with center = 10 -5 25; normal = 0 0 1; radius = 5; end;
	cylinder with end1 = 10 5 0; end2 = 10 5 25; radius = 5; end;
	disk with center = 10 5 25; normal = 0 0 1; radius = 5; end;	
end;	{engine}
}

	
object headlight is
	paraboloid with top = 10 0 0; base = 0 0 0; radius = 5; end;
	unshaded white sphere with center = 3 0 0; radius = 2; end;
end;	{headlight}


object chassis
is
	fender with move to 0 -25 15; end;
	fender with move to 0 25 15; end;
	
	body with move to 0 0 15; end;

	{crankshaft}
	flat white cylinder with end1 = -20 0 15; end2 = 45 0 15; radius = 1; end;

	steering_wheel with 
		rotate by 80 around 0 1 0; 
		move to -30 10 35; 
	end;
	metallic white cylinder with 
		end1 = 45 0 35; end2 = 60 0 35; radius = 2;
	end;	{spare wheel holder}
	wheel with 
		rotate by -90 around 0 0 1;
		move to 60 0 35; 
	end;	{spare wheel}

	flat brown seat with move to 10 -10 28; end; 
	flat brown seat with move to 10 10 28; end;
	flat grey trunk with move to 25 0 15; end; 
	metallic white gas_tank with move to 35 0 45; end;
	metallic white hitch with move to 68 0 15; end;

	{floor}
	flat charcoal polygon [(70 0 15) (60 20 15) (-70 20 15)
			 (-80 0 15) (-70 -20 15) (60 -20 15)];

	metallic white headlight with move to -70 -25 40; end;
	metallic white headlight with move to -70 25 40; end;
end;	{chassis}	


object roadster with
	scalar t = 0;
	scalar hood_angle = 0;
is
	engine with 
		time = t / 15;
		magnify by 8;
		rotate by 180 around 0 0 1;
		move to -50 0 15; 
	end; 
	axel with rotate by t * 10 around 0 -1 0; move to -70 0 15; end;
	axel with rotate by t * 10 around 0 -1 0; move to 45 0 15; end;

	hood with 
		render_mode = wireframe;
		rotate by -hood_angle around 1 0 0;
		move to -70 15 35;
	end;

	chassis with
		render_mode = wireframe;
	end;
end;	{roadster}


picture roadster_pic with
	scalar t = 0;
	eye = 100 -150 100; 
	lookat = 0 0 16;
	render_mode = shaded;

	{
	facets = 4;
	render_mode = hidden_line;
	}
	{
	eye = 100 -150 16; 
	projection = orthographic;
	field_of_view = 400;
	}
is
	distant_light with direction = .3 -.5 1; end;
	glossy red roadster with t = t; end;
end;	{roadster_pic}


anim roadster_anim with
	field_of_view = 80;
	render_mode = shaded;
	facets = 0;
	width = 16;
	height = 8;
is
	integer frames = 0;
	while true do
		roadster_pic with 
			t = frames; 
			double_buffer = on;
		end;
		rotate by 1 around 0 0 1;
		frames = frames + 1;
	end;	
end;	{roadster_anim}