Advertisement

Viewcone? not really...but I need visibilty help

Started by August 01, 2000 11:47 PM
1 comment, last by AngryLlama 24 years, 5 months ago
Ok here is what i am doing and what i need: my 3d game uses a very simple map system. The map is Tile based (each tile is 10x10 GlUnits). Now.. the visblility seems to be: 2 tiles on the left 2 tiles on the right 8 tiles deep This means that the "View rectangle" is 40x80 units. I don not have to worry about height, because there is only one "level" and nothing over laps (heightwise) I can''t figureout how to go about seeing what tiles need to be drawn. I started playing with cos and sin and try to do scanlines, but all my attempts failed. Can anyone help me? -Paul
I am going to assume for the sake of discussion that your "camera" is allowed to move freely around the tiled world. At a quick glance, you have two options for visible surface determination.

The first is intelligent tile selection based on the camera''s current location and orientation in the world. The algorithm would be something along the lines of "Given a camera in tile X and a viewing angle of theta radians, which tiles are visible." A fixed number of angles could be covered in the method. Using this, some tiles may be tagged as visible even though they are not. Thus the drawback of the quick and dirty algorithm.

The second alternative is a planar viewing frustum. A rectangle can be used for a quicker but somewhat more inaccurate algorithm. The planar viewing frustum will be in global coordinates based on the location of the camera. Each of the four corners could be changed into the world space through a simple translate and rotate operation. Once the viewing frustum is computed, a series of simple rectangle intersection tests can be made to look for visible tiles. This involves more computations than the other algorithm but it is ultimately more accurate. Given the complexity of a tile, you may need to trade off search speed versus rendering speed. Some times, it may be faster to render the tile than to spend a lot of time checking to see if it is visible.

I am sure there are other ways of doing this, but these are the two ends of the spectrum. I hope it helped.

- Carl
Advertisement
well... i found a way to get my "4 corners" of the rectangle...

but i don't have a clue how to determine which tiles are inside it.

Try going to www.radioactivesoft.com/screenshots.htm ...You can see that the level is built with tiles in the mapeditor.. and the tiles are draw perspectivly In GL in the game.


Thanks,
Paul

Edited by - AngryLlama on August 2, 2000 11:31:19 AM

This topic is closed to new replies.

Advertisement