!---------------------------------------------------------------
!
! TUTORIAL8 - RayDance tutorial script #8.
!
! This script demonstrates the lathe statement.
!
! Concepts include :
!
!  o Creating a simple outline and using it in a lathe statement
!
!  o Importing an outline
!
!  o Altering lathe parameters
!
!---------------------------------------------------------------

! Use a print statement to display descriptive text on the
! message window.


? "TUTORIAL8 - This script creates two rows of lathed\n",
  "objects.  The top row is lathed from an outline created\n",
  "in this script.  The bottom row is lathed from an outline\n",
  "imported from a disk file.  Each outline is lathed 3\n",
  "times.  The leftmost is a complete 360 degree lathe.  The\n",
  "middle has a slice removed but appears solid.  The\n",
  "rightmost has a slice removed and appears hollow.  The\n",
  "lathe flag NOENDS is used to achieve this last effect.\n\n";


! Variables

integer  SEGMENTS = 64;     ! # of steps around lathed objects
vector   SCALING = [1,1,1]; ! Full size

vector   POS1A = [-400,0,250],
         POS1B = [   0,0,250],
         POS1C = [ 400,0,250],

         POS2A = [-400,0,-250],
         POS2B = [   0,0,-250],
         POS2C = [ 400,0,-250];

! Create colors for our objects

BLUE   : color( RGB, [0,0,1] );
PURPLE : color( RGB, [.7,0,1] );


! Create a surface for our objects

MATTE  : surface(PHONG, 0.5,.8, 0,0, 0,0,0, 0, 0 );


! Create a simple outline (for rotation around the z axis)
! and lathe it.  Negative lathe angles create a counter-
! clockwise lathing action (rather than a clockwise one).

OUTLINE1 : outline[5] = (
  [0,0,-140], [100,0,-140], [130,0,0], [100,0,140], [0,0,140]
);

lathe( ( OUTLINE1 ),
  SEGMENTS, -360, 0, SCALING, POS1A, [0,0,0],
  BLUE, MATTE, ZAXIS );

lathe( ( OUTLINE1 ),
  SEGMENTS, -230, 0, SCALING, POS1B, [0,0,0],
  BLUE, MATTE, ZAXIS );

lathe( ( OUTLINE1 ),
  SEGMENTS, -230, 0, SCALING, POS1C, [0,0,0],
  BLUE, MATTE, NOENDS ZAXIS );


! Import an outline and lathe it.  NOTE: RayDance considers
! imported outlines to be an object and looks for the outline
! file in the directories specified by the user interface object
! path.

OUTLINE2 : outline( "pawn.outline", [2,2,2], XZ );

lathe( ( OUTLINE2 ),
  SEGMENTS, -360, 0, SCALING, POS2A, [0,0,0],
  PURPLE, MATTE, ZAXIS );

lathe( ( OUTLINE2 ),
  SEGMENTS, -230, 0, SCALING, POS2B, [0,0,0],
  PURPLE, MATTE, ZAXIS );

lathe( ( OUTLINE2 ),
  SEGMENTS, -230, 0, SCALING, POS2C, [0,0,0],
  PURPLE, MATTE, NOENDS ZAXIS );


! Specify the ambient light.

AMBIENT( [0,0,0], [0.6,0.6,0.6], [0,0,1], 0, 0 );

! Specify the STAR light.

STAR( [40000,-50000,60000], [1,.9,1], 300 );


! Set the background color to a dark purple

BACKGROUND( PLAIN, [0,0.05,0.15] );


! The camera will be positioned along the negative y axis aiming
! toward the central objects

CAMERA'POS = [800,-1900,200];
CAMERA'TARGET = [0,40,50];


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
