home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / VOGLE / EXAMPLES / FOBJVWS.FOR < prev    next >
Text File  |  2000-02-11  |  3KB  |  182 lines

  1. c
  2. c Demonstrate just how much you can put in an object
  3. c
  4.     program fobjviews
  5.  
  6.     integer BLACK, RED, GREEN, YELLOW, BLUE, CYAN, MAGENTA
  7.     parameter(BLACK = 0, RED = 1, GREEN = 2, YELLOW = 3,
  8.      +            BLUE = 4, CYAN = 5, MAGENTA = 6)
  9.     
  10.     integer CUBE, TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT
  11.     parameter(CUBE = 1, TOPLEFT = 2, TOPRIGHT = 3,
  12.      +            BOTTOMLEFT = 4, BOTTOMRIGHT = 5)
  13.  
  14.     character *20 device
  15.  
  16.     print*,'Enter device name:'
  17.     read(*,'(A)')device
  18.     call vinit(device)
  19.     call pushviewport
  20.  
  21.     call textsize(0.5, 0.9)
  22.     call font('futura.m')
  23.  
  24.     call color(BLACK)
  25.     call clear
  26.  
  27. c
  28. c make an object that represents the cube
  29. c
  30.     call makecube
  31.  
  32. c
  33. c set up an object which draws in the top left of the screen.
  34. c
  35.     call makeobj(TOPLEFT)
  36.         call viewport(-1.0, 0.0, 0.0, 1.0)
  37.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  38.  
  39.         call color(RED)
  40.  
  41.         call rect(-5.0, -5.0, 5.0, 5.0)
  42.  
  43.         call perspective(40.0, 1.0, 0.1, 1000.0)
  44.         call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0)
  45. c
  46. c          Call an object within another object
  47. c
  48.         call callobj(CUBE)
  49.  
  50.         call color(GREEN)
  51.  
  52.         call move2(-4.5, -4.5)
  53.         call drawstr('perspective/lookat')
  54.     call closeobj
  55.  
  56. c
  57. c now set up one which draws in the top right of the screen
  58. c
  59.     call makeobj(TOPRIGHT)
  60.         call viewport(0.0, 1.0, 0.0, 1.0)
  61.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  62.  
  63.         call color(GREEN)
  64.  
  65.         call rect(-5.0, -5.0, 5.0, 5.0)
  66.  
  67.         call window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0)
  68.         call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0)
  69.  
  70.         call callobj(CUBE)
  71.  
  72.         call color(RED)
  73.  
  74.         call move2(-4.5, -4.5)
  75.         call drawstr('window/lookat')
  76.     call closeobj
  77.  
  78. c
  79. c try the bottom left
  80. c
  81.     call makeobj(BOTTOMLEFT)
  82.         call viewport(-1.0, 0.0, -1.0, 0.0)
  83.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  84.  
  85.         call color(MAGENTA)
  86.  
  87.         call rect(-5.0, -5.0, 5.0, 5.0)
  88.  
  89.         call perspective(40.0, 1.0, 0.1, 1000.0)
  90.         call polarview(15.0, 30.0, 30.0, 30.0)
  91.  
  92.         call callobj(CUBE)
  93.  
  94.         call color(YELLOW)
  95.  
  96.         call move2(-4.5, -4.5)
  97.         call drawstr('perspective/polarview')
  98.     call closeobj
  99.  
  100. c
  101. c and the bottom right
  102. c
  103.     call makeobj(BOTTOMRIGHT)
  104.         call viewport(0.0, 1.0, -1.0, 0.0)
  105.         call ortho2(-5.0, 5.0, -5.0, 5.0)
  106.  
  107.         call color(CYAN)
  108.  
  109.         call rect(-5.0, -5.0, 5.0, 5.0)
  110.  
  111.         call window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0)
  112.         call polarview(8.0, -18.0, -3.0, 18.0)
  113.  
  114.         call callobj(CUBE)
  115.  
  116.         call color(BLUE)
  117.  
  118.         call move2(-4.5, -4.5)
  119.         call drawstr('window/polarview')
  120.     call closeobj
  121.  
  122. c
  123. c now draw them
  124. c
  125.     call callobj(TOPLEFT)
  126.     call callobj(TOPRIGHT)
  127.     call callobj(BOTTOMLEFT)
  128.     call callobj(BOTTOMRIGHT)
  129.  
  130.     call getkey
  131.  
  132.     call vexit
  133.  
  134.     end
  135.  
  136. c
  137. c makecube
  138. c
  139. c set up a cube
  140. c
  141.     subroutine makecube
  142.     integer CUBE
  143.     parameter (CUBE = 1)
  144.  
  145.     call makeobj(CUBE)
  146.  
  147. c
  148. c The border around the cube
  149. c
  150.         call rect(-5.0, -5.0, 10.0, 10.0)
  151.  
  152. c
  153. c Make the cube from 4 squares
  154. c
  155.         call pushmatrix
  156.         call side
  157.         call rotate(90.0, 'x')
  158.         call side
  159.         call rotate(90.0, 'x')
  160.         call side
  161.         call rotate(90.0, 'x')
  162.         call side
  163.         call popmatrix
  164.  
  165.     call closeobj
  166.  
  167.     end
  168.  
  169. c
  170. c side
  171. c
  172. c define a face for the cube
  173. c
  174.     subroutine side
  175.  
  176.     call pushmatrix
  177.         call translate(0.0, 0.0, 1.0)
  178.         call rect(-1.0, -1.0, 1.0, 1.0)
  179.     call popmatrix
  180.  
  181.     end
  182.