home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / avogl.tar.gz / avogl.tar / vogl / examples / fobjvws.for < prev    next >
Text File  |  1992-09-22  |  3KB  |  195 lines

  1. c
  2. c Demonstrate just how much you can put in an object
  3. c
  4.     program fobjviews
  5.     
  6. $INCLUDE: 'fvogl.h'
  7. $INCLUDE: 'fvodevic.h'
  8.  
  9.     integer *2 val, vminx, vmaxx, vminy, vmaxy
  10.  
  11.     integer CUBE, TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT
  12.     parameter(CUBE = 1, TOPLEFT = 2, TOPRIGHT = 3,
  13.      +            BOTTOMLEFT = 4, BOTTOMRIGHT = 5)
  14.  
  15.     call winope('fobjvws', 7)
  16.  
  17.     call getvie(vminx, vmaxx, vminy, vmaxy)
  18.  
  19.     minx = vminx
  20.     maxx = vmaxx
  21.     miny = vminy
  22.     maxy = vmaxy
  23.  
  24.     call unqdev(INPUTC)
  25.     call qdevic(SPACEK)
  26.     call pushvi
  27.  
  28.     call hfont('futura.m', 8)
  29.     call htexts(0.5, 0.9)
  30.  
  31.     call color(BLACK)
  32.     call clear
  33.  
  34. c
  35. c make an object that represents the cube
  36. c
  37.     call makecu
  38.  
  39. c
  40. c set up an object which draws in the top left of the screen.
  41. c
  42.     call makeob(TOPLEFT)
  43.         call viewpo(minx, (maxx - minx) / 2,
  44.      +                     (maxy - miny) / 2, maxy)
  45.  
  46.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  47.  
  48.         call color(RED)
  49.  
  50.         call rect(-5.0, -5.0, 5.0, 5.0)
  51.  
  52.         call perspe(400, 1.0, 0.1, 1000.0)
  53.         call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0)
  54. c
  55. c          Call an object within another object
  56. c
  57.         call callob(CUBE)
  58.  
  59.         call color(GREEN)
  60.  
  61.         call move2(-4.5, -4.5)
  62.         call hchars('perspective/lookat', 18)
  63.     call closeo
  64.  
  65. c
  66. c now set up one which draws in the top right of the screen
  67. c
  68.     call makeob(TOPRIGHT)
  69.         call viewpo((maxx - minx) / 2, maxx,
  70.      +                      (maxy - miny) / 2, maxy)
  71.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  72.  
  73.         call color(GREEN)
  74.  
  75.         call rect(-5.0, -5.0, 5.0, 5.0)
  76.  
  77.         call window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0)
  78.         call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0)
  79.  
  80.         call callob(CUBE)
  81.  
  82.         call color(RED)
  83.  
  84.         call move2(-4.5, -4.5)
  85.         call hchars('window/lookat', 13)
  86.     call closeo
  87.  
  88. c
  89. c try the bottom left
  90. c
  91.     call makeob(BOTTOMLEFT)
  92.         call viewpo(minx, (maxx - minx) / 2,
  93.      +                      miny, (maxy - miny) / 2)
  94.  
  95.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  96.  
  97.         call color(MAGENT)
  98.  
  99.         call rect(-5.0, -5.0, 5.0, 5.0)
  100.  
  101.         call perspe(400, 1.0, 0.1, 1000.0)
  102.         call polarv(15.0, 300, 300, 300)
  103.  
  104.         call callob(CUBE)
  105.  
  106.         call color(YELLOW)
  107.  
  108.         call move2(-4.5, -4.5)
  109.         call hchars('perspective/polarview', 21)
  110.     call closeo
  111.  
  112. c
  113. c and the bottom right
  114. c
  115.     call makeob(BOTTOMRIGHT)
  116.         call viewpo((maxx - minx) / 2, maxx,
  117.      +                      miny, (maxy - miny) / 2)
  118.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  119.  
  120.         call color(CYAN)
  121.  
  122.         call rect(-5.0, -5.0, 5.0, 5.0)
  123.  
  124.         call window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0)
  125.         call polarv(8.0, -180, -30, 180)
  126.  
  127.         call callob(CUBE)
  128.  
  129.         call color(BLUE)
  130.  
  131.         call move2(-4.5, -4.5)
  132.         call hchars('window/polarview', 16)
  133.     call closeo
  134.  
  135. c
  136. c now draw them
  137. c
  138.     call callob(TOPLEFT)
  139.     call callob(TOPRIGHT)
  140.     call callob(BOTTOMLEFT)
  141.     call callob(BOTTOMRIGHT)
  142.  
  143.     idum = qread(val)
  144.  
  145.     call gexit
  146.  
  147.     end
  148.  
  149. c
  150. c makecube
  151. c
  152. c set up a cube
  153. c
  154.     subroutine makecu
  155.     integer CUBE
  156.     parameter (CUBE = 1)
  157.  
  158.     call makeob(CUBE)
  159.  
  160. c
  161. c The border around the cube
  162. c
  163.         call rect(-5.0, -5.0, 10.0, 10.0)
  164.  
  165. c
  166. c Make the cube from 4 squares
  167. c
  168.         call pushma
  169.         call side
  170.         call rotate(900, 'x')
  171.         call side
  172.         call rotate(900, 'x')
  173.         call side
  174.         call rotate(900, 'x')
  175.         call side
  176.         call popmat
  177.  
  178.     call closeo
  179.  
  180.     end
  181.  
  182. c
  183. c side
  184. c
  185. c define a face for the cube
  186. c
  187.     subroutine side
  188.  
  189.     call pushma
  190.         call transl(0.0, 0.0, 1.0)
  191.         call rect(-1.0, -1.0, 1.0, 1.0)
  192.     call popmat
  193.  
  194.     end
  195.