!---------------------------------------------------------------
!
! TUTORIAL19 - RayDance tutorial script #19.
!
! This script demonstrates wrap mode texture mapping.
!
! Concepts include :
!
!  o Wrap mode textures on an extruded surface.
!
!---------------------------------------------------------------

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


? "TUTORIAL19 - This script creates two extruded 'flag'\n",
  "objects.  Both are extruded from the same outline.  The\n",
  "outlines are imported from a disk file.  The top 'flag'\n",
  "is texture mapped with a PLANE map.  The lower 'flag' is\n",
  "texture mapped using wrap mode.  Both 'flags' are Phong\n",
  "smoothed.  Note how the texture of the lower 'flag' \n",
  "follows its contours!\n";


FLAG_MAP : texturemap( "flag.ilbm" );

! Create a surface for our flags...

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

real  x1,x2;

! Import the outline of our flag...

FLAG_OUTLINE : outline( "flag1.geo", [2,1,1], xy );

! Figure the widht of this outline

X1 = FLAG_OUTLINE[0]'X;
X2 = FLAG_OUTLINE[FLAG_OUTLINE'STEPS-1]'X;


PLANE_MAP : texture( PLANE, FLAG_MAP, [25,0,150], [0,1,0], [1,0,0],
  280,X2-X1,250, 1,1, SMOOTH3 REPEAT );

extrude( ( FLAG_OUTLINE ),
  250, [0,0,250], [1,1,1], [0,0,25], [0,0,0],
  PLANE_MAP, SHINY, OPEN NOENDS PHONG );

extrude( ( FLAG_OUTLINE ),
  250, [0,0,250], [1,1,1], [0,0,-275], [0,0,0],
  FLAG_MAP(1,1,SMOOTH3|REPEAT), 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,350];
CAMERA'TARGET = [0,0,0];


! The scene has now been constructed, render it!

RENDER;


! All scripts must terminate with an END

END
