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

  1.  
  2. c
  3. c Shows various combinations of viewing and
  4. c projection transformations.
  5. c
  6.     program fviews
  7.  
  8. #ifdef SGI
  9. #include "fgl.h"
  10. #include "fdevice.h"
  11. #else
  12. #include "fvogl.h"
  13. #include "fvodevice.h"
  14. #endif
  15.  
  16.     integer *2 val, vminx, vmaxx, vminy, vmaxy
  17.  
  18.     call winope('fviews', 6)
  19. c
  20. c we are interested in keyboard events
  21. c
  22.     call unqdev(INPUTC)
  23.     call qdevic(KEYBD)
  24.  
  25.     call color(BLACK)
  26.     call clear
  27. c
  28. c open a hershey font
  29. c
  30.     call hfont('times.r', 7)
  31.  
  32. c
  33. c we want to draw just within the boundaries of the screen
  34. c
  35.         call getvie(vminx, vmaxx, vminy, vmaxy)
  36.     maxx = vmaxx
  37.     minx = vminx
  38.     maxy = vmaxy
  39.     miny = vminy
  40.         call viewpo(maxx / 10, maxx / 10 * 9, maxy / 10, maxy / 10 * 9)
  41.  
  42. c
  43. c set the world size
  44. c
  45.     call ortho2(-5.0, 5.0, -5.0, 5.0)
  46.  
  47. c
  48. c draw a boundary frame
  49. c
  50.     call color(RED)
  51.     call rect(-5.0, -5.0, 5.0, 5.0)
  52.  
  53. c
  54. c set up a perspective projection with a field of view of
  55. c 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1,
  56. c and the far clipping plane at 1000.0.
  57. c
  58.     call perspe(400, 1.0, 0.1, 1000.0)
  59. c
  60. c we want the drawing to be done with our eye point at (5.0, 8.0, 5.0)
  61. c looking towards (0.0, 0.0, 0.0). The last parameter gives a twist
  62. c in degrees around the line of sight, in this case zero.
  63. c
  64.     call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0)
  65.  
  66.     call drawte
  67.  
  68. c
  69. c set the text size
  70. c
  71.     call htexts(0.6, 0.9)
  72.  
  73.     call move2(-4.5, -4.5)
  74.     call hchars('perspective/lookat', 18)
  75.  
  76.     idum = qread(val)
  77.  
  78. c
  79. c window can also be used to give a perspective projection. Its
  80. c arguments are 6 clipping planes, left, right, bottom, top, near,
  81. c and far.
  82. c
  83.     call window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0)
  84. c
  85. c as window replaces the current transformation matrix we must
  86. c specify our viewpoint again.
  87. c
  88.     call lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0)
  89.  
  90.     call color(BLACK)
  91.     call clear
  92.  
  93.     call color(GREEN)
  94.     call rect(-5.0, -5.0, 5.0, 5.0)
  95.  
  96.     call drawte
  97.  
  98.     call htexts(0.6, 0.9)
  99.     call move2(-4.5,-4.5)
  100.     call hchars('window/lookat', 13)
  101.  
  102.     idum = qread(val)
  103.  
  104. c
  105. c set up our original perspective projection again.
  106. c
  107.     call perspe(400, 1.0, 0.1, 1000.0)
  108. c
  109. c polarview also specifies our viewpoint, but, unlike lookat, in polar
  110. c coordinates. Its arguments are the distance from the world origin, an
  111. c azimuthal angle in the x-y plane measured from the y axis, an 
  112. c incidence angle in the y-z plane measured from the z axis, and a
  113. c twist around the line of sight.
  114. c
  115.     call polarv(15.0, 300, 300, 300)
  116.  
  117.     call color(BLACK)
  118.     call clear
  119.  
  120.     call color(MAGENT)
  121.     call rect(-5.0, -5.0, 5.0, 5.0)
  122.  
  123.     call drawte
  124.  
  125.     call move2(-4.5,-4.5)
  126.     call htexts(0.6, 0.9)
  127.     call hchars('perspective/polarview', 21)
  128.  
  129.     idum = qread(val)
  130.  
  131. c
  132. c once more with window for comparison
  133. c
  134.     call window(-4.0, 4.0, -4.0, 4.0, -4.0, 4.0)
  135.     call polarv(6.0, 2000, -3000, 7000)
  136.  
  137.     call color(BLACK)
  138.     call clear
  139.  
  140.     call color(YELLOW)
  141.     call rect(-5.0, -5.0, 5.0, 5.0)
  142.  
  143.     call drawte
  144.  
  145.     call move2(-4.5,-4.5)
  146.     call htexts(0.6, 0.9)
  147.     call hchars('window/polarview', 16)
  148.  
  149.     idum = qread(val)
  150.  
  151.     call gexit
  152.     
  153.     end
  154.  
  155. c
  156. c drawtetra 
  157. c generate a tetrahedron as a series of move draws 
  158. c
  159. c
  160.     subroutine drawte
  161.     
  162.     integer WHITE
  163.     parameter (WHITE = 7)
  164.  
  165.     call move(-0.5,  0.866, -0.5)
  166.     call draw(-0.5, -0.866, -0.5)
  167.     call draw( 1.0,  0.0,   -0.5)
  168.     call draw(-0.5,  0.866, -0.5)
  169.     call draw( 0.0,  0.0,    1.5)
  170.     call draw(-0.5, -0.866, -0.5)
  171.     call move( 1.0,  0.0,   -0.5)
  172.     call draw( 0.0,  0.0,    1.5)
  173.     
  174. c    Label the vertices.
  175. c
  176.     call color(WHITE)
  177.     call htexts(0.3, 0.5)    
  178.     call move(-0.5,  0.866, -0.5)
  179.     call hdrawc('a')
  180.     call move(-0.5, -0.866, -0.5)
  181.     call hdrawc('b')
  182.     call move( 1.0,  0.0,   -0.5)
  183.     call hdrawc('c')
  184.     call move( 0.0,  0.0,    1.5)
  185.     call hdrawc('d')
  186.  
  187.     end
  188.