!---------------------------------------------------------------
!
! TUTORIAL21 - RayDance tutorial script #21.
!
! This script demonstates bump mapping.
!
! Concepts include :
!
!  o SPHERE bump mapping
!
!---------------------------------------------------------------

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


? "TUTORIAL21 - This script creates two rows of four\n",
  "spheres.  The top row of spheres is bump mapped with\n",
  "regular bumps.  The bottom row of spheres is bump\n",
  "mapped using the NEGATIVE flag to turn the bumps inside\n",
  "out.  Bumpfactor increases from left to right with each\n",
  "succesive object having double the bumpfactor of its\n",
  "predecessor (0.5, 1.0, 2.0, 4.0).  All bumping is doen\n",
  "with the same bump map array.\n\n";


! Load the bump map array

OURMAP : bumpmap( "mottledorange.ilbm" );


! Create a color for our objects

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


! Create a surface for our objects

SHINY : surface(PHONG, 0.4,.8, .4,30, 0,0,0, 0, 0 );


! Create the top row of spheres and bump map them.

! Bumpmap syntax is,
! ident : BUMP( SPHERE, bumpmaparray, surface, bumpfactor,
!   position, uaxis, vaxis, xmag, ymag, flags );
!
! Refer to page 63 and 65 for illustrations of mapping.

BUMP1A : bump( SPHERE, OURMAP, SHINY, 0.5, [-300,0,100],
  [0,1,0], [1,0,0], 2,2, 0 );
BUMP2A : bump( SPHERE, OURMAP, SHINY, 1.0, [-100,0,100],
  [0,1,0], [1,0,0], 2,2, 0 );
BUMP3A : bump( SPHERE, OURMAP, SHINY, 2.0, [ 100,0,100],
  [0,1,0], [1,0,0], 2,2, 0 );
BUMP4A : bump( SPHERE, OURMAP, SHINY, 4.0, [ 300,0,100],
  [0,1,0], [1,0,0], 2,2, 0 );

sphere( [-300,0,100], 80, WHITE, BUMP1A );
sphere( [-100,0,100], 80, WHITE, BUMP2A );
sphere( [ 100,0,100], 80, WHITE, BUMP3A );
sphere( [ 300,0,100], 80, WHITE, BUMP4A );


! Create the bottom row of spheres and bump map them.  These
! spheres are bumped with inverted bumps since the NEGATIVE
! flag is used.

BUMP1B : bump( SPHERE, OURMAP, SHINY, 0.5, [-300,0,-100],
  [0,1,0], [1,0,0], 2,2, NEGATIVE );
BUMP2B : bump( SPHERE, OURMAP, SHINY, 1.0, [-100,0,-100],
  [0,1,0], [1,0,0], 2,2, NEGATIVE );
BUMP3B : bump( SPHERE, OURMAP, SHINY, 2.0, [ 100,0,-100],
  [0,1,0], [1,0,0], 2,2, NEGATIVE );
BUMP4B : bump( SPHERE, OURMAP, SHINY, 4.0, [ 300,0,-100],
  [0,1,0], [1,0,0], 2,2, NEGATIVE );

sphere( [-300,0,-100], 80, WHITE, BUMP1B );
sphere( [-100,0,-100], 80, WHITE, BUMP2B );
sphere( [ 100,0,-100], 80, WHITE, BUMP3B );
sphere( [ 300,0,-100], 80, WHITE, BUMP4B );


! 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,0.1] );


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

CAMERA'POS = [0,-1200,0];
CAMERA'TARGET = [0,0,0];


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
