#
# A model of a light mill.
#
#						Gershon Elber, Dec 1998.
#

Circ = cregion( circle( vector( 0.0, 0.0, 0.0 ), 0.6 )
					 * rz( 90 ) * rx( 90 ) * tz( 2.1 ),
		0.1, 1.9 );

BodySec = 
      cbspline( 3,
		list( ctlpt( E3,  -0.5, 0.0,  0.0 ),
		      ctlpt( E3,  -0.5, 0.0,  0.01 ),
		      ctlpt( E3,  -0.1, 0.0,  0.05 ),
		      ctlpt( E3, -0.03, 0.0,  0.3 ),
		      ctlpt( E3, -0.03, 0.0,  0.75 ),
		      ctlpt( E3,  -0.1, 0.0,  1.0 ),
		      ctlpt( E3,  -0.1, 0.0,  1.1 ),
		      ctlpt( E3, -0.03, 0.0,  1.2 ),
		      ctlpt( E3, -0.03, 0.0,  1.3 ),
		      ctlpt( E3, -0.04, 0.0,  1.31 ),
		      ctlpt( E3, -0.08, 0.0,  1.32 ),
		      ctlpt( E3, -0.09, 0.0,  1.4 ),
		      ctlpt( E3, -0.08, 0.0,  1.5 ) ),
		list( kv_open ) )
    + -Circ
    + cbspline( 3,
		list( ctlpt( E3, -0.07, 0.0,  2.7 ),
		      ctlpt( E3, -0.07, 0.0,  2.8 ),
		      ctlpt( E3, -0.01, 0.0,  2.9 ),
		      ctlpt( E3, -0.05, 0.0,  2.9 ),
		      ctlpt( E3, -0.05, 0.0,  3.0 ),
		      ctlpt( E3, -0.001, 0.0, 3.0 ) ),
		list( kv_open ) );
free( Circ );

Body = surfrev( BodySec );
free( BodySec );
attrib( Body, "transp", 0.95 );
color( Body, white );

Base1Sec = cbspline( 3,
		     list( ctlpt( E3, -0.08, 0.0,  1.4 ),
		           ctlpt( E3, -0.02, 0.0,  1.4 ),
		           ctlpt( E3, -0.01, 0.0,  1.7 ),
		           ctlpt( E3, -0.01, 0.0,  2.0 ) ),
		     list( kv_open ) );
Base1 = surfrev( Base1Sec );
free( Base1Sec );
attrib( Base1, "transp", 0.95 );
color( Base1, white );

Niddle1Sec = 
     cbspline( 3,
	       list( ctlpt( E3, -0.002,  0.0,  1.7 ),
	             ctlpt( E3, -0.002,  0.0,  1.8 ),
		     ctlpt( E3, -0.001,  0.0,  2.0 ),
	             ctlpt( E3, -0.0001, 0.0,  2.2 ) ),
	       list( kv_open ) );
Niddle1 = surfrev( Niddle1Sec );
free( Niddle1Sec );
attrib( Niddle1, "rgb", "100, 100, 100" );

Base2Sec = cbspline( 3,
		     list( ctlpt( E3, -0.08, 0.0,  2.7 ),
		           ctlpt( E3, -0.04, 0.0,  2.7 ),
		           ctlpt( E3, -0.04, 0.0,  2.5 ),
		           ctlpt( E3, -0.04, 0.0,  2.15 ) ),
		     list( kv_open ) );
Base2 = surfrev( Base2Sec );
free( Base2Sec );
attrib( Base2, "transp", 0.95 );
color( Base2, white );


WingSec = cbspline( 2,
		    list( ctlpt( E3, -1, -1,  0 ),
		          ctlpt( E3, -1,  1,  0 ),
		          ctlpt( E3,  1,  1,  0 ),
		          ctlpt( E3,  1, -1,  0 ),
		          ctlpt( E3, -1, -1,  0 ) ),
		    list( kv_open ) );
WingFrame =
     sFromCrvs( list( WingSec,
		      WingSec * sc( 1.1 ),
		      WingSec * sc( 1.1 ) * tz( 0.1 ),
		      WingSec * tz( 0.1 ) ),
		3, KV_OPEN );
free( WingSec );
WingPlane1 = ruledSrf( ctlpt( E3, -1, -1,  0 ) + ctlpt( E3, -1,  1,  0 ),
		       ctlpt( E3,  1, -1,  0 ) + ctlpt( E3,  1,  1,  0 ) );
WingPlane2 = -WingPlane1 * tz( 0.1 );
attrib( WingPlane1, "rgb", "10, 10, 10" );
attrib( WingPlane2, "rgb", "255, 255, 255" );
attrib( WingFrame,  "rgb", "100, 100, 100" );

WingBase = list( WingFrame, WingPlane1, WingPlane2 );
free( WingFrame );
free( WingPlane1 );
free( WingPlane2 );

Wing = WingBase * tx( 1 ) * ty( 1 )* sc( 0.11 )
		* rz( 45 ) * ry( 90 ) * tz( 2.1 ) * ty( 0.1 );
Wings = list( Wing,
	      Wing * rz( 90 ),
	      Wing * rz( 180 ),
	      Wing * rz( 270 ) );
free( Wing );

WingBaseSec = cbspline( 3,
		        list( ctlpt( E3, -0.10,  0.0,  2.1 ),
		              ctlpt( E3, -0.02,  0.0,  2.1 ),
		              ctlpt( E3, -0.02,  0.0,  2.2 ),
		              ctlpt( E3, -0.02,  0.0,  2.21 ),
		              ctlpt( E3, -0.001, 0.0,  2.21 ) ),
		        list( kv_open ) );
WingBase = surfrev( WingBaseSec );
free( WingBaseSec );
attrib( WingBase, "transp", 0.95 );
color( WingBase, white );

All = list( Body, Base1, Niddle1, Base2, Wings, WingBase );

view( All, true );
save( "lightmil", All );

free( Body );
free( Base1 );
free( Base2 );
free( Niddle1 );
free( Wings );
free( WingBase );
free( All );
