Octtre and viewing frustrum
I''m pretty new to 3d-programming but I''ve read the articles here on gamedev to get a general clue about how to "do it right". I think I understand the idea about viewing frustrum and octtrees, but I have a (hopefully) simple question about it. How do you calculate if a triangle is within the viewing frustrum? There must be a fast and reliable algorithm for this, but I haven''t found or figured one out yet. Some ideas would be much appreciated.
Best regards
Fredrich Claezon
you have to check if all 3 points are on the same side:
(above, below, right or left) of the screen. if this is true the thing is offscreen.
you can also check if all 3 points are all in the screen. this means the thing is visible and unclipped.
if both of the above are false, you have to clip it. note: this can also result in an invisible polygon!
earx
btw.. i think there should be tons of source about this on the net.
(above, below, right or left) of the screen. if this is true the thing is offscreen.
you can also check if all 3 points are all in the screen. this means the thing is visible and unclipped.
if both of the above are false, you have to clip it. note: this can also result in an invisible polygon!
earx
btw.. i think there should be tons of source about this on the net.
Thank you a lot, I think I''ve got the hang of it now. But you mention that this can result in an invisible polygon. Am I right when I say that this can occur at the corners of the viewing frustrum, so that a triangle that does not have all vertices on one side only is not supposed to be written, but will be handled as one which should?
/Fredrich
/Fredrich
to anser you question, yes this happens when all 3 points are outside the frustrum, but not all on the same side. for example:
points (a) and (b) are below and point (c) is left..
<code>
|
| (screen)
|
c |
-+------
|
a b
</code>
as you can see this tri is offscreen, but to know this you have to intersect the edges of the frustrum. i do this with sutherland hodgman (s-h). between each s-h pass you check if the result is off or onscreen.
earx
ps hope this picture isn''t garbled, otherwise load it into an ascii editor
points (a) and (b) are below and point (c) is left..
<code>
|
| (screen)
|
c |
-+------
|
a b
</code>
as you can see this tri is offscreen, but to know this you have to intersect the edges of the frustrum. i do this with sutherland hodgman (s-h). between each s-h pass you check if the result is off or onscreen.
earx
ps hope this picture isn''t garbled, otherwise load it into an ascii editor
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement