!---------------------------------------------------------------
!
! TUTORIAL15 - RayDance tutorial script #15.
!
! This script demonstrates polygon mesh creation.
!
! Concepts include :
!
!  o Using the MESH statement to create polygon meshes.
!
!  o Using the PERTURB statement to change the position of the
!    mesh vertices.
!
!---------------------------------------------------------------

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


? "TUTORIAL15 - This script creates a pair of polygon meshes\n",
  "using the MESH statement.  It then tweaks their vertices\n",
  "using the PERTURB to make it appear as though a sine wave\n",
  "were passing through them.  The mesh of the right is\n",
  "PHONG smoothed.\n";


! Create colors for our objects

WHITE  : color(RGB, [1,1,1] );

! Create surfaces 
!                ka kd ks  n km kr ir kb flgs
MATTE     :
  surface(PHONG, .3,.8, 0, 0, 0, 0, 0, 0, 0 );


vector POS;


! Create two polygon meshes.  Each mesh will be 200 units of
! length on each side and contain 400 vertices (20x20)

POS = [-115,0,0];

OUR_MESH1 : mesh(
  [-100,100,0]+POS, [100,100,0]+POS,    ! corners 1 & 2
  [100,-100,0]+POS, [-100,-100,0]+POS,  ! corners 3 & 4
  20,20,                        ! number of rows and columns
  WHITE, MATTE, 0 );            ! color, surface, flags


POS = [115,0,0];

OUR_MESH2 : mesh(
  [-100,100,0]+POS, [100,100,0]+POS,    ! corners 1 & 2
  [100,-100,0]+POS, [-100,-100,0]+POS,  ! corners 3 & 4
  20,20,                        ! number of rows and columns
  WHITE, MATTE, PHONG );        ! color, surface, flags


! Now we're going to adjust the height of each point in the
! meshes making a sine wave ripple out from corner 2 of
! mesh 1.

perturb( OUR_MESH1, CIRCLE, [100,100,0], 10, 130, 0 );
perturb( OUR_MESH2, CIRCLE, [100,100,0], 10, 130, 0 );


! Specify the ambient light.

!       always 0's  lamp color   dir.    k1  k2

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


! Specify the STAR light.

!         position        lamp color rad  flags

star( [3000,-30000,40000], [1,.9,1], 300, NOSHADOWS );


! 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,-300,700];
CAMERA'TARGET = [0,0,0];


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
