!---------------------------------------------------------------
!
! TUTORIAL10 - RayDance tutorial script #10.
!
! This script demonstrates the extrude statement.
!
! Concepts include :
!
!  o Creating a sheet extrusion.
!
!  o Algorithmic outline creation
!
!  o PHONG smoothing of the extrusion
!
!---------------------------------------------------------------

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


? "TUTORIAL10 - This script creates two extruded 'flag'\n",
  "objects.  Both are extruded from the same outline.  The\n",
  "outlines vertices are calculated to form a sine wave.\n",
  "The blue 'flag' is NOT phong smoothed.  The orange 'flag'\n",
  "is phong smoothed.\n";


! Create colors for our objects

BLUE   : color(RGB, [0,0,.7] );
ORANGE : color(RGB, [.6,.3,0] );

! Make up a surface for our objects

!                       ka kd ks  n km kr ir kb flgs
SHINY  : surface(PHONG, .5,.8,.4,30, 0, 0, 0, 0, 0 );



! Creat the outline for our "flags".  We declare the outline
! first then calculate the points for it.  The flag will be
! based on a sine curve showing 3 cycles.

FLAG_OUTLINE : outline[20];

integer  K;

real     DEGREES_PER_CYCLE = 360,
         NUM_CYCLES = 3.0,
         AMPLITUDE = 100;

! Step through the outline calculating positions for each corner

K = 0;
while (K < 20) {
  FLAG_OUTLINE[k] =
    [k*40, AMPLITUDE*sin(K*DEGREES_PER_CYCLE*NUM_CYCLES/19.0),0];
  K = K + 1;
}

extrude( ( FLAG_OUTLINE ),
  200, [0,0,200], [1,1,1], [-400,0,25], [0,0,0],
  BLUE, SHINY, OPEN NOENDS );

extrude( ( FLAG_OUTLINE ),
  200, [0,0,200], [1,1,1], [-400,0,-225], [0,0,0],
  ORANGE, SHINY, OPEN NOENDS PHONG );



! Specify the ambient light.

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

! Specify the STAR light.

STAR( [3000,-50000,10000], [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 = [0,-1500,-300];
CAMERA'TARGET = [0,0,0];


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
