|
I created this function after failing woefully to get the line of sight commands to work in Dark Basic. I didn't have any knowledge of the mathematics behind line of sight like rays projection and polygon collision detection. I decided to use the methods available within Dark Basic to create a quick hack solution but reliable enough to use in a game. |
DESCRIPTION
|
You basically have a source and target position. They can be represented as 3D points in 3D space. You then want to determine if the first point 'A' can see the second point 'B'. I created a line of sight object, basically a line-like 3D object and perform the necessary transformations like scaling, translation, rotation etc to ensure that one end of the object if on point A and the other end is on point B. All you have to do now is to perform collision checks between this line of sight object and all other objects in the 3D space. If there is a collision then point A and B cannot see one another. If there isn't a collision then point A and B can see each other. |
LINE OF SIGHT DEMO
|
The demo shows what i described above. The line of sight calculation is dependant on an external line of sight object. The calculation is encapsulated in a function that returns a '1' if there is a clear line of sight or a '0' if there is no clear line of sight. The function holds currently for only the X and Z axis (Y rotation). In other words the function does not handle changes in the Y axis. You can download it below. Name: Line of Sight Demo (.exe) Author: Dienye Boham Version: v1.0 Size: 696KB Date uploaded: 12/12/05 Download link: Download here |