5H1N0B1 wrote in Mon Nov 02, 2015 12:08 pm:The way I coded the radar is independant of the displaying because my first goal is missile implementation, but it can be/should be re used in anyway you want.
Yes, I do remember - we we were once talking about coming up with a dedicated/separate "Radar" class that could be reused elsewhere, including not just other aircraft, but also missiles, and possibly ground stations.
I have not yet looked at your code - but in the original m2000-5/Canvas thread, we were talking about the "TFC" (=traffic) layer which is processing AI/MP properties and returns a list (vector) of nodes to the caller (MapStructure layer) - you could basically integrate your radar2.nas code there and it should just work if you don't have any explicit aircraft dependencies/assumptions in it.
To be on the safe side, you may want to hook this up to tanker.nas and/or some other scripted AI object that can be radar-guided.
You could also get in touch with Red Leader who has been working on a dedicated framework for scriptable AI objects.
The instrument/visualization side of this can be greatly simplified if you only use a single MapStructure layer that loads your radar2.nas code to simulate your own radar. Note that, due the way MapStructure is structured, you don't even need to have an actual aircraft to load/use your radar2.nas code - you could just as well test the code in standalone mode using a GUI dialog, which is how this works:
http://wiki.flightgear.org/Canvas_Snipp ... o_a_Canvas
The steps for searching/filtering AI/MP traffic nodes can be seen in $FG_ROOT/Nasal/canvas/map/TFC.lcontroller - there, you can find a searchCmd_default() function which is handling all the search logic - you could basically yank/replace this with your own code.
Alternatively, you can copy the TFC (=traffic) files and use them as a template for your own "RADAR" layer.
If you are interested in focusing on just the radar, I can help you work out the details for using MapStructure - regardless of any particular aircraft/use-case, so that other aircraft developers can reuse your radar code elsewhere, including AI missiles etc.
The whole process is covered at: http://wiki.flightgear.org/Canvas_MapSt ... new_Layers
The radar/atc specifics we discussed a while ago, would still apply: http://wiki.flightgear.org/Canvas_Radar ... ADAR_Layer
If you want me to help with the MapStructure side of this, so that your code can be easily reused elsewhere, I basically need a self-contained Nasal file that has no external dependencies, and which provides a class with a search function - where I only need to pass in:
- my current position
- range to search
- type of traffic/echos (i.e. MP/AI or both)
For starters, that is everything I need - and you should ideally provide a method that returns a vector of objects (traffic echos), with each target inheriting from geo.Coord or having a corresponding member.
As long as this is in place, it would only take a few minutes to reuse your code in a MapStructure layer - so that this can be used for arbitrary purposes - in fact, the way MapStructure works, you can even add a virtual radar instance to existing MP/AI traffic and "see" their radar view, which is how this works (showing virtual NDs for different AI aircraft):
Subject: How to display Airport Chart?
Hooray wrote:Since I wanted to test if the navdisplay.mfd file has been sufficiently decoupled from the main aircraft/use, I put a quick hack together:
compare groundspeed/headings etc in the main aircraft and in the canvas window.
(this is the same backend code, just with a driver hash to use AI traffic as the data source, rather than the main FG aircraft - and it's working NICELY, this is even superior to the built-in map dialog ! obviously AI aircraft doesn't have any cockpit buttons, so I had to use the property browser to set up the ND...)