A little polygon problem...

Started by
6 comments, last by Kirkbag 22 years, 2 months ago
Hey guys, i have a problem. i''m trying to draw a texture mapped blended box, with a sqaure hole in the middle of each wall. so i used 4 quads for every wall, leaving a hole in the middle, but the polygons don''t connect smoothly... and u can notice it especially while rotating the scene. i''m sure there''s a simple solution for this.
Advertisement
you could map a texture onto the quads, where in the middle a box is cut out (alpha == 0), so one can see through...

What do you mean by "do not connect smoothly" ?
You mean the quares between them, or the holes ?
At best, could you give a screenshot ?

The texture solution might not work depending on the problem. Moreover, it would cost more memory, more gpu time, and would need multitexturing if the cube already have a texture mapped. So, I''d recommend using it as a last resort.
Using 4 quads by wall is your mistake. Doing that, some vertices are connected to the border of a quad, while maths used for drawing the poly on screen aren't perfect, the vertices don't stay on the border of the quad.

To avoid this, make your wall using 8 quads like this :
  |--|--|--||@@|@@|@@||--|--|--||@@|##|@@||--|--|--||@@|@@|@@||--|--|--|  


(the @ are textured quads, the # is the whole)

Edited by - Melgo on January 16, 2002 7:01:47 AM
Melgo, if you draw :
  +--------+|\@@@@@@/||@\@@@@/@||@@+--+@@||@@|##|@@||@@|##|@@||@@+--+@@||@/@@@@\@||/@@@@@@\|+--------+  

what''s worse than drawing your set of 8 quads, stp ?

The connection seems to be same (at least, geometrically).
I think it works too.

The trick is just to avoid things like this :

  |--------||@@@@@@@@||--|--|--||@@|##|@@||--|--|--||@@@@@@@@||--------|or this|-----|--||@@@@@|@@||--|--|@@||@@|##|@@||@@|--|--||@@|@@@@@||--|-----|  


cause the polys won''t stay connected when you''ll translate, rotate or scale the scene.

Sorry if you don''t understand all, i read english a lot better than i write (that''s why i draw littles pictures in ascii)...
This is commonly refered to as the "T-Junctions" problem.

Y.
Thanks alot Melgo! that solved the problem, it''s good 2 know these things. this forum is the best resource around for openGL programmers!

This topic is closed to new replies.

Advertisement