OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: myke13021 on 30 Oct 2007, 00:00:40

Title: Determinating obstacles (landscape) in Line-of-sight
Post by: myke13021 on 30 Oct 2007, 00:00:40
Hi,

i'm writing a very simple radar tower simulation script. It works very well but there's a limitation right now: Contacts behind Hills are still shown.

What i need is a way to determine if there's an obstacle (landscape) between the radar and the vehicle (Air). I've looked at Mr.Peanuts BinoTarget, especially the function "binoLOS" but i as far as i understand the code, it uses Binoculars somehow. I don't know how i should adapt this to work with any 2 objects.

If someone could help me with this problem.

Thx

Myke out
Title: Re: Determinating obstacles (landscape) in Line-of-sight
Post by: Spooner on 30 Oct 2007, 04:27:24
The simple answer is that you need to move a gamelogic on a path between the tower and the plane (you must use setPosASL for this, say every couple of metres) and, if at any point its height above ground ((getPos _logic) select 2) is less than 0, then you have hit the landscape, meaning there must be some solid ground in the way between the tower and the aircraft. If you need further help with implementing this, then give us a shout.

(Mr Peanut's script only needs binoculars because that is how he limited it. The actual LOS calculations just use a weaponDirection vector taken when using binoculars, but could just as easily be from any weapon being used. You could work out a similar vector based on the locations (ASL) of the plane relative to the tower).
Title: Re: Determinating obstacles (landscape) in Line-of-sight
Post by: myke13021 on 30 Oct 2007, 09:16:35
@Spooner

thx mate, i guess there's no other way to do this. I hope you don't mind if i ask if you could write me a function for this, since it needs this fancy kind of math which i'm unable to do. Basically a function that returns true or false if landscape is hit would be nice. Also the testing could be aborted as soon theres a obstacle in the LOS.

One question though: as this is for air radar, range can be up to several kilometers and include maybe a dozen Planes and Choppers. How would such a function hit the performance in these circumstances?

Thx for your time, mate


Myke out

:EDITH:
It would be nice if i could pass max scandistance in meters (simulating radar range) as argument.
Title: Re: Determinating obstacles (landscape) in Line-of-sight
Post by: Spooner on 30 Oct 2007, 20:59:36
Doing a proper radar was one of the many things that I considered in the past, but I have plenty of scripts WIP. What else are you actually planning to implement once you have a script that does the LOS bit? A graphical display, I assume, because if not, you'll not be happy with my attached script (since it deals with the finding as well as LOS of the aircraft)?

On your request, I've thrown a script together which deals with terrain LOS, but it doesn't take into account buildings and other features (it could, but the speed cost would most probably be prohibitive assuming you have more than a couple of aircraft or are using anything like a reasonable range). I think I'd like to alter the logic a bit after doing some more research into how radar work though, before I'll consider it finished.