Path: chuka.playstation.co.uk!news From: Christoph Luerig Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Viewport clipping - dear god no! Date: Wed, 25 Nov 1998 08:08:32 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 75 Message-ID: <365BACF0.19D7C93F@immd9.informatik.uni-erlangen.de> References: <365B2BBF.91A@mdx.ac.uk> NNTP-Posting-Host: faui90.informatik.uni-erlangen.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04C-SGI [en] (X11; I; IRIX 6.3 IP32) Hello Harvey! In order to make your clipping algorithm more efficient, you can use a hierarchical approach. I assume that your objects, for instance the street consists of different pieces. You can group these pieces in a tree like structure, where the children of a father node are always somehow clusters in geometry space. Then you have to define a bounding box for each of the nodes. If you want to apply a visibility test to your scene, you start with the root node of your scene. Then you descend recursively the tree and stop descending, when you have found a bounding box, that does definitely not overlap with your viewing frustum. This way you can spare the checking of the several bounding boxes of the children. If you want to analyze a large area with a checkerboard structure for instance, you could use a Quadtree as a hierarchical basis. Also you should consider not to put a bounding box around every single object. In standard graphics pipeline every polygon is clipped against the viewing frustum before scan-conversion. The double checking with the bounding box for very simple objects will probably cost more than you gain for speed up. As for building the tree, if you are using a matrix tree anyway for your scene, that might be a good idea to introduce the bounding boxes. Also pay attention, that it might not be wise to develope the bounding box hierarchie for the complete scene. As you have a racing game, you have quite a lot of a priori knowledge about the scene and what might be seen of it. So you will probably not see these parts of the road that are behind you. As the global setting of the scene, like race track itself does not change, you may consider to spilt up your scene into several different regions and build lists wich regions might be seen from wich one. This method has the advantage, that you might also use it for different purposes like Level of Detail controle. You could put into the lists not only wich part of the scene might be visible, but also the level of detail. Let us say for instance you model some street segments as subscenes. You could model these subscenes in a very detailed version with fine textures and many smaller extra objects. The second version would just get the rough street and a very coarse structured texture (Antialiasing!). Then you can assign the coarser version to the regions in your list which are more far away and the finer version to regions which are pretty close to you. During the ongoing of the game you have just to find out in which region you are (do it incrementally), pick the look up table and render the appropriate sub-scenes in the indicated level of detail. These sub-scene could then be optimized by the bounding box hierarchie. Hope that helps, Christoph Harvey.C wrote: > Hi again. > > I wish I had some easy questions, but I don't. My 3d car racing game is > going okay at the moment, but in order to stick more objects in the > scene I need to find a quick way to clip objects to the current view. > I.e. find out which objects are visible and draw them. > Does anyone have a solution to this? I am currently using a variation > of a simple bounding box test where you find out what objects lie within > a square around the player. This is obviously not a good idea! > > I'd also like to mention that I have developed a rather fast function > that detects whether two lines have intersected - extremely handy > for 2d and 3d collision detection. I will put this up on my website > during the weekend. > -- > Regards | E-mail: hc054@mdx.ac.uk > Harvey | ICQ: 4269478 > > http://www.netyaroze-europe.com/~harveyc/