Archived

This topic is now archived and is closed to further replies.

Octtre and viewing frustrum

This topic is 5809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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

Share on other sites
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

Share on other sites
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

Share on other sites
Thank you again, your help is much appreciated. I now know how to do it! =) Now I''m planning to learn more about lod, so expect more questions coming up

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633742
• Total Posts
3013630
×