home *** CD-ROM | disk | FTP | other *** search
- !---------------------------------------------------------------
- !
- ! TUTORIAL3 - RayDance tutorial script #3.
- !
- ! This script demonstrates specular hilite control on a 4 x 5
- ! array of spheres.
- !
- ! Concepts include :
- !
- ! o Declaring PHONG surfaces with different ks and n values.
- !
- ! o Declaring and calling procedures
- !
- ! o Using variables
- !
- ! o Using WHILE loops
- !
- ! o Using a PRINT statement to display the contents of
- ! variables
- !
- !---------------------------------------------------------------
-
- ! Provide some informative text on the message window describing
- ! this script.
-
- ? "TUTORIAL3 - This script defines a scene with four rows of\n",
- "5 spheres. Each sphere will be the same color but will\n",
- "have different specular reflection surface values (ks and\n",
- "n). ks will increase toward the bottom rows. n will\n",
- "increase toward the right side of the screen. Higher\n",
- "values of ks increase the brightness of specular\n",
- "highlighting while higher values of n will make the\n",
- "highlight more focused.\n";
-
- ! The camera will be positioned along the negative y axis
- ! looking at the origin.
-
- CAMERA'POS = [0,-3000,0];
- CAMERA'TARGET = [0,0,0];
-
-
- ! Define the color of the sphere
-
- SPHERE_COLOR : COLOR ( RGB, [0.8,0.4,0] ); ! Lt orange
-
-
- ! Declare our variables.
-
- real XPOS,ZPOS;
-
- real KS,N;
-
-
- ! Declare a procedure (subroutine). This procedure will create
- ! a sphere at the specified location with the specified surface
- ! characteristics.
- !
- ! NOTE: All variables declared inside a procedure (including
- ! surfaces) are local. This means that each time you call the
- ! procedure a completely new and unique variable will be
- ! created. We will exploit this feature to create a seperate
- ! surface for each sphere within this procedure.
-
- proc MAKESPHERE( vector POS, real RADIUS,
- real PHONG_KS, real PHONG_N )
-
- ! ka kd ks n km kr ir kb flags
- SPHERE_SURF :
- SURFACE(PHONG, 1.0,1.0,PHONG_KS,PHONG_N,0.0,0.0,0.0,0.0,0 );
-
- ! Create the actual sphere
-
- SPHERE( POS, RADIUS, SPHERE_COLOR, SPHERE_SURF );
-
- ! Print the position and surface parameters of each sphere
-
- ? "Creating sphere,", POS, RADIUS,
- "Ks & n", PHONG_KS, PHONG_N, "\n";
-
- endproc
-
-
- ! Setup two loops to create the spheres. The spheres will be
- ! placed in rows parallel to the x axis and columns parallel to
- ! the z axis.
-
- XPOS = -800;
- N = 1;
-
- while (XPOS <= 800) {
-
- ZPOS = 600;
- KS = 0.1;
-
- while (ZPOS >= -600) {
-
- ! Call the procedure that will construct the sphere. Since
- ! radius was declared as a REAL we MUST pass a real constant,
- ! 100.0. Passing 100 (an integer constant) will cause syntax
- ! errors.
-
- MAKESPHERE( [XPOS,0,ZPOS], 100.0, KS, N );
-
- KS = KS + .2;
- ZPOS = ZPOS - 400;
- }
-
- XPOS = XPOS + 400;
- N = N * 3;
- }
-
-
- ! Specify the ambient light. This will provide illumination for
- ! the areas that are shadows from the star light source.
- ! Positioning of ambient lights is reserved for future
- ! expansion. For now, set position to [0,0,0]. The intensity
- ! of ambient lights should range from [0,0,0] to [1,1,1]. We
- ! will use a muted white light. The ambient direction is UP, but
- ! since K1 and K2 are zero this light is non-directional making
- ! direction a place holder. UP is toward the positive z-axis.
-
- ! always 0's color direction k1(base) k2(range)
-
- AMBIENT( [0,0,0], [0.6,0.6,0.6], [0,0,1], 0, 0 );
-
-
- ! Specify the STAR light. Position it above, behind, and to the
- ! right of the camera. Since the light of a star doesn't
- ! diminish with distance good light values range from [0,0,0] to
- ! [1,1,1]. Make a slightly yellowish star.
-
- ! position color radius
-
- STAR( [5000,-5000,4000], [1,1,.9], 300 );
-
-
- ! Set the background color to a dark, muddy red
-
- ! type rgb color value
-
- BACKGROUND( PLAIN, [0.2,0.05,0.05] );
-
-
- ! The scene has now been constructed, render it!
-
- RENDER;
-
-
- ! All scripts must terminate with an END
-
- END
-