#
# Manual construction of layout (prisa) of simple polyhedra.
#

save_mat = view_mat;

square = poly( list( vector( 0, 0, 0 ),
		     vector( 0, 1, 0 ),
		     vector( 1, 1, 0 ),
		     vector( 1, 0, 0 ),
		     vector( 0, 0, 0 ) ),
	       true );
attrib( square, "width", "0.02" );
color( square, red );

rectan = poly( list( vector( 0, 0, 0 ),
		     vector( 0, 1, 0 ),
		     vector( 2, 1, 0 ),
		     vector( 2, 0, 0 ),
		     vector( 0, 0, 0 ) ),
	       true );
attrib( rectan, "width", "0.02" );
color( rectan, red );

triang = poly( list( vector( 0,   0,   0 ),
		     vector( 0,   1,   0 ),
		     vector( 1.5, 0.5, 0 ),
		     vector( 0,   0,   0 ) ),
	       true );
attrib( triang, "width", "0.02" );
color( triang, red );

view_mat = scale( vector( 0.2, 0.2, 0.2 ) );
cube_prisa = list( square,
		   square * trans( vector(  1,  0, 0 ) ),
		   square * trans( vector(  2,  0, 0 ) ),
		   square * trans( vector( -1,  0, 0 ) ),
		   square * trans( vector(  0,  1, 0 ) ),
		   square * trans( vector(  0, -1, 0 ) ) );
interact( list( view_mat, cube_prisa) );
save( "cubepris", cube_prisa );
free( cube_prisa );

box_prisa = list( rectan,
		  square * trans( vector(  2,  0, 0 ) ),
		  square * trans( vector( -1,  0, 0 ) ),
		  rectan * trans( vector(  0,  1, 0 ) ),
		  rectan * trans( vector(  0,  2, 0 ) ),
		  rectan * trans( vector(  0, -1, 0 ) ) );
interact( list( view_mat, box_prisa ) );
save( "box_pris", box_prisa );
free( box_prisa );

piram_prisa = list( square,
		    triang * trans( vector(  1,  0, 0 ) ),
		    triang * rotz( 90 ) * trans( vector( 1,  1, 0 ) ),
		    triang * rotz( 180 ) * trans( vector( 0,  1, 0 ) ),
		    triang * rotz( 270 ) * trans( vector( 0,  0, 0 ) ) );
interact( list( view_mat, piram_prisa ) );
save( "pirapris", piram_prisa );
free( piram_prisa );

view_mat = save_mat;

free( square );
free( triang );
free( rectan );
