      INCLUDE 'GRAFTYPE.FOR'
      RECORD /WorldRect/  wr
      RECORD /point3d/ contourMap(-15 : 15, -15 : 15)
      COMMON /Map/ contourmap
      INTEGER  i


      CALL createFunction
      CALL tInit3
      CALL Init3D(-1, 'c:\FOR\LIB\*.FON')
      CALL SetWorldRect(wr, -10.0, -10.0, 10.0, 10.0)
      CALL SetWorldCoordinates(wr)
      CALL WorldRotate3(20.0, 0)
      CALL WorldRotate3(-45.0, 1)
      CALL SelectColor (15)
      DO i = 0, 4
        CALL ClearViewportXX
        CALL SelectColor(i + 1)
        SELECT CASE (i)
          CASE (0)
           CALL Draw3DAxes(10.0, 10.0, 10.0)

          CASE (1)
          CALL WorldScale3(.5, .5, .5)
           CALL Draw3DAxes(10.0, 10.0, 10.0)

         CASE (2)
          CALL WorldScale3(2.0, 2.0, 2.0)
          CALL WorldRotate3(-40.0, 0)
          CALL Draw3DAxes(10.0, 10.0, 10.0)
         CASE (3)
          CALL WorldRotate3(40.0, 0)
          CALL WorldTran3(4.0, 3.0, 2.0)
          CALL Draw3DAxes(10.0, 10.0, 10.0)
         CASE (4)
          CALL WorldTran3(-4.0, -3.0, -2.0)
          CALL Persp(20.0)
          CALL Draw3DAxes(10.0, 10.0, 10.0)
        END SELECT
        CALL DrawFunction
        READ (*,*)
      END DO

      CALL Close3DGraphics

      END



      SUBROUTINE createFunction
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER  i,j
      REAL x, y, z
      RECORD /point3d/ contourMap(-15 : 15, -15 : 15)
      COMMON /Map/ contourmap

      DO i = -15, 15
        x = REAL(i) / 2.0
        DO  j = -15, 15
          z = REAL(j) / 2.0
          y = 3.0 * SIN(SQRT(x ** 2 + z ** 2))
          contourMap(i, j).x = x
          contourMap(i, j).y = y
          contourMap(i, j).z = z
        END DO
      END DO
      END !SUB

      SUBROUTINE DrawFunction()
      INCLUDE 'GRAFTYPE.FOR'
      INTEGER  i, j
      RECORD /point3D/ pv(0 : 5)
      RECORD /point3d/ contourMap(-15 : 15, -15 : 15)
      COMMON /Map/ contourmap

      DO j = -14,  15
        DO i = -14, 15
          pv(0).x = contourMap(i - 1, j - 1).x
          pv(0).y = contourMap(i - 1, j - 1).y
          pv(0).z = contourMap(i - 1, j - 1).z

          pv(1).x = contourMap(i, j - 1).x
          pv(1).y = contourMap(i, j - 1).y
          pv(1).z = contourMap(i, j - 1).z

          pv(2).x = contourMap(i, j).x
          pv(2).y = contourMap(i, j).y
          pv(2).z = contourMap(i, j).z

          pv(3).x = contourMap(i - 1, j).x
          pv(3).y = contourMap(i - 1, j).y
          pv(3).z = contourMap(i - 1, j).z

          pv(4).x = contourMap(i - 1, j - 1).x
          pv(4).y = contourMap(i - 1, j - 1).y
          pv(4).z = contourMap(i - 1, j - 1).z

          CALL PolyFill3D(pv, 1, 0, 5)
        END DO
      END DO
      END !SUBROUTINE

