!---------------------------------------------------------------
!
! TUTORIAL22 - RayDance tutorial script #22.
!
! This script creates a texture and bump mapped ground.
!
! Concepts include :
!
!  o Texture and bump mapping of a ground plane.
!
!---------------------------------------------------------------

? "TUTORIAL22 - This script creates two texture and bump\n",
  "mapped ground planes, one above and one below the camera.\n",
  "The upper ground plane alternates mapped areas with solid\n",
  "colored areas.\n";

! Load the maps
BRICKS_TXA : texturemap( "bricks4.ilbm" );
BRICKS_BMA : bumpmap( "brickbumps4b.ilbm" );

! Create colors
YELLOW : color( RGB, [.8,.8,.1] );

! Create a surface for our ground planes.  Since one will be
! backlit use the TRANSLUCENT flag to allow backlighting.
MATTE : surface(PHONG, 0.4,.8, 0,0, 0,0,0, 0, TRANSLUCENT );

! Create the bump and texture maps for the ground plane.  Note
! that the width and height parameters must be the same or it
! won't work right.

TXTURE : texture( PLANE, BRICKS_TXA, [0,0,0],
  [0,0,1], [1,0,0], 400,400,400, 2,2, REPEAT SMOOTH3 );

BUMPS : bump( PLANE, BRICKS_BMA, MATTE, 2.0, [0,0,0],
  [0,0,1], [1,0,0], 400,400,400, 2,2, REPEAT );

! Since we declared projective maps we can plug 'em in anywhere
! a color or surface would work.  This includes the GROUND 
! statements (except for TEXTURE mode ground statements which
! require a texture map ARRAY
GROUND( PLAIN, -100, TXTURE, BUMPS );  ! Below sea level

! To make things interesting lets create one more ground plane.
! This time let's use a BULLSEYE pattern but make only one of
! the color/surface pairs our brick texture.  Make the other
! color yellow.
GROUND( BULLSEYE, 100, 200, TXTURE, BUMPS, YELLOW, MATTE );


! Specify the lighting.  Use NOSHADOWS so the upper ground
! won't shadow the lower ground.
AMBIENT( [0,0,0], [0.6,0.6,0.6], [0,0,1], 0, 0 );
STAR( [40000,-50000,60000], [1,.9,1], 300, NOSHADOWS );

! Dark blue background
BACKGROUND( PLAIN, [0,0,0.1] );

! The camera looks up the positive y axis
CAMERA'POS = [0,-1200,0];
CAMERA'TARGET = [0,0,0];

RENDER;

END
