!---------------------------------------------------------------
!
! TUTORIAL18 - RayDance tutorial script #18.
!
! This script demonstates projective texture mapping.
!
! Concepts include :
!
!  o PLANE, CYLINDER, and SPHERE texture mapping
!
!---------------------------------------------------------------

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


? "TUTORIAL18 - This script creates six lathed objects and\n",
  "texture maps a picture onto them.  The top and bottom\n",
  "rows represent top and front views (respectively) of the\n",
  "objects.  The left most objects are PLANE mapped, the\n",
  "middle objects are CYLINDER wrapped, and the right most\n",
  "objects are SPHERE mapped.  All mapping is done with the\n",
  "same picture file (texture map array).\n\n";


! Variables

integer  SEGMENTS = 64;     ! # of steps around lathed objects
real     ANGLE = 360;       ! Lathe a complete revolution
vector   SCALING = [1,1,1]; ! Full size

vector   POS1A = [-400,0,200],
         POS1B = [-400,0,-200],
         POS2A = [   0,0,200],
         POS2B = [   0,0,-200],
         POS3A = [ 400,0,200],
         POS3B = [ 400,0,-200];


! Load the texture map array

OURMAP : texturemap( "bricks4.ilbm" );


! Make up a surface for our objects

MATTE : surface(PHONG, 0.8,1, 0,0, 0,0,0, 0, 0 );


! Create our outline (for rotation around the z axis)

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


! Create the left-most objects and PLANE map them.

MAP1A : texture( PLANE, ourmap, POS1A, [0,0,1], [1,0,0],
  280,285,285, 2,2, SMOOTH5 );

MAP1B : texture( PLANE, ourmap, POS1B, [0,1,0], [1,0,0],
  280,285,285, 2,2, SMOOTH5 );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS1A, [90,0,0],
  MAP1A, MATTE, PHONG|ZAXIS );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS1B, [0,0,0],
  MAP1B, MATTE, PHONG|ZAXIS );


! Create the central objects and CYLINDER map them.

MAP2A : texture( CYLINDER, ourmap, POS2A, [0,-1,0], [1,0,0],
  285, 2,2, SMOOTH5 );

MAP2B : texture( CYLINDER, ourmap, POS2B, [0,0,1], [1,0,0],
  285, 2,2, SMOOTH5 );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS2A, [90,0,0],
  MAP2A, MATTE, PHONG|ZAXIS );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS2B, [0,0,0],
  MAP2B, MATTE, PHONG|ZAXIS );


! Create the right-most objects and SPHERE map them.

MAP3A : texture( SPHERE, ourmap, POS3A, [0,-1,0], [1,0,0],
  2,2, SMOOTH5 );

MAP3B : texture( SPHERE, ourmap, POS3B, [0,0,1], [1,0,0],
  2,2, SMOOTH5 );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS3A, [90,0,0],
  MAP3A, MATTE, PHONG|ZAXIS );

lathe( ( OUROUTLINE ),
  SEGMENTS, ANGLE, 0, SCALING, POS3B, [0,0,0],
  MAP3B, MATTE, PHONG|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 = [0,-1700,550];
CAMERA'TARGET = (POS2A+POS2B)*0.5; ! between the two objects


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
