See what's going on with flipcode!




 

Landscape Visibility
Question submitted by (05 January 2000)




Return to The Archives
 
  I'm coding currently on a landscape-engine with Direct3D and all landscape-tiles (4-point-polygons) around the player of a radius are drawn. So polygons are drawn too if they are lying behind the players view! (invisible). How could I find out which landscape-tile is visible and which's not? Do you have some sourcecode examples for me? I've tried to code some stuff with the player-vector etc. ...but I failed!  
 

 
  Often times, clipping takes care of this. During the clipping process, each vertex is "coded". This coding involves determining the binary value of a few bits that represent if a vertex is on- or off-screen in any direction. These bits are later ANDed together to quickly determine if the polygon is on- or off-screen. This explanation is certainly not good enough to learn from. But you can start with a document on 3D clipping I wrote a while ago.

Since you're doing a terrain-based engine, you can take advantage of the 2-dimensional grid that you're working with. You might want to read up on quad-trees. Quad-trees are a popular way of storing your terrain data so that you can quickly cull out large clumps of land in the time it takes to cull a single polygon. They do this by storing the data heirarchically. If a polygon node in the tree is not visible, then all of the polygons in that node can be considered not visible. Quad-trees are certainly a viable option even for beginners, yet powerful enough to yield great results.



Response provided by Paul Nettle
 
 

This article was originally an entry in flipCode's Fountain of Knowledge, an open Question and Answer column that no longer exists.


 

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.