home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sgi / 16658 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  3.0 KB

  1. Path: sparky!uunet!dove!poly2.nist.gov!fred
  2. From: fred@poly2.nist.gov (Frederick R. Phelan Jr.)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: Hidden line removal...
  5. Message-ID: <7017@dove.nist.gov>
  6. Date: 19 Nov 92 21:49:57 GMT
  7. References: <BxnnxK.CCK@cs.dal.ca>
  8. Sender: news@dove.nist.gov
  9. Lines: 93
  10.  
  11. In article <BxnnxK.CCK@cs.dal.ca>, lingley@ug.cs.dal.ca (William Lingley) writes:
  12. |> Is there an efficient way to draw a wire frame, but
  13. |> remove lines that would be hidden behind the solid portions
  14. |> of the structure in front of the others?  I know I can use the z-buffer
  15. |> and shade with the background color, but this still requires all
  16. |> panels to be drawn anyway.  Preferably it should be a faster draw than
  17. |> drawing the panels.  There was supposed to be an article on this in a magazine
  18. |> at one point in time.  A pointer to this would be nice as well.
  19. |> 
  20. |> adv-thanx-ance
  21. |> 
  22. |> William (lingley@scylla.drea.dnd.ca or lingley@ug.cs.dal.ca)
  23.  
  24. I've never heard of a way to do this without drawing the panels ...
  25. Please post if you find something.
  26.  
  27. Here's two different codes that I have managed to snitch from various resources
  28. including the net that do this.  Just change the fill color to the background color
  29. for wireframe.
  30.  
  31. void draw_hollow_tri_1()
  32. {
  33.                /* draws tri with verts p1, p2 and p3 with 
  34.                   yellow outline, red fill. */
  35.  
  36.                 /* Draw red fill. */
  37.                 c3f(red_col);
  38.                 lsetdepth(0xffff,0x7ffffe);
  39.                 bgnpolygon();
  40.                 v3f(p1); v3f(p2); v3f(p3);
  41.                 endpolygon();
  42.  
  43.                 /* Draw yellow outline. */
  44.                 c3f(yel_col);
  45.                 lsetdepth(0x1,0x7fffff);
  46.                 bgnclosedline();
  47.                 v3f(p1); v3f(p2); v3f(p3);
  48.                 endclosedline();
  49.  
  50. }
  51.  
  52.  
  53.  
  54. void draw_hollow_tri_2()
  55. {
  56.                /* draws tri with verts p1, p2 and p3 with 
  57.                   yellow outline, red fill. */
  58. /*
  59.  
  60.  From "The Hidden Charms of Z-Buffer", 
  61.  Kurt Akeley, IRIS Universe magazine,
  62.  issue 11.
  63.  
  64. */
  65.  
  66.                 zwritemask(0x0);
  67.                 c3f(red_col);
  68.                 bgnpolygon();
  69.                 v3f(p1); v3f(p2); v3f(p3);
  70.                 endpolygon();
  71.  
  72.                 c3f(yel_col);
  73.                 bgnclosedline();
  74.                 v3f(p1); v3f(p2); v3f(p3);
  75.                 endclosedline();
  76.  
  77.                 zwritemask(0xffffff);
  78.                 wmpack(0x0);
  79.  
  80.                 bgnpolygon();
  81.                 v3f(p1); v3f(p2); v3f(p3);
  82.                 endpolygon();
  83.  
  84.                 wmpack(0xffffffff);
  85.                 
  86. }
  87.  
  88.  
  89.  
  90. The second method has the disadvantage of three polygon draws
  91. to get one hollow polygon.  On the other hand, it is slightly
  92. sharper.
  93.  
  94.  
  95. Fred
  96. ---
  97. Fred Phelan
  98. fred@poly2.nist.gov
  99. /*___________________________________________________
  100.    ____ __  ___  __    ___       ___        ___ 
  101.   /__  /_/ /__  / /   /__/ /__/ /__   /    /__/ /\  /  
  102.  /    / ( /__  /_/   /    /  / /___  /___ /  / /  \/
  103. ___________________________________________________*/
  104.