Board index FlightGear Development Aircraft

Modelling a 3D 'RADAR Beam'

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Modelling a 3D 'RADAR Beam'

Postby robbo » Tue Jan 30, 2018 11:25 am

I have had a good look around on the forums, but I am not able to discern if it is possible (without C++ intervention) to model a RADAR beam emanating from an aircraft. I have seen other simulations where a semi-transparent colour-shaded cone is able to be rendered to show where the RADAR beam is pointing from the aircraft (I know you can't see this in real life, its the 'virtual' beam that I am interested in modelling) and would like to reproduce this effect. i would also like to be able to control the parameters of that cone such as its length, diameter, pointing angle, transparency etc.

Is it possible to do this and if so, could somebody offer me some guidance on how to achieve this please?

many thanks,

Robbo
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Thorsten » Tue Jan 30, 2018 11:35 am

You could start with just using a semi-transparent 3d model of a cone for the beam and use animations to control its properties.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Modelling a 3D 'RADAR Beam'

Postby Hooray » Tue Jan 30, 2018 11:47 am

I believe, for the maths, you could take a look at the Aim9/fox2 implementation (by xiii, Nasal: fox2.nas).
From a visualization standpoint, you could also use a Canvas HUD (in fact, even a transparent Canvas GUI dialog may suffice, depending on your requirements):

Drawing lines in the sky/environment
TheTom wrote:If you want to do something similar like a HUD, you could place a transparent canvas in front of the pilots viewpoint and draw the lines onto it. If you calculate the direction from the pilots viewpoint to the according position in the environment and intersect an imaginary line between this two points with the canvas you can draw it exactly where the point is located in the environment. You just need the two angles describing the direction to the point (up/down and left/right).


Canvas HUD : how to rotate+translate
TheTom wrote:createTransform creates a new matrix on top of the existing matrix stack. A while ago I've added an example for a HUD built using the Canvas to the wiki: http://wiki.flightgear.org/Canvas_HUD
It doesn't use SVG but manually creates everything instead. As loading an SVG should basically do the same than handcrafting icons there shouldn't be much of a difference.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Tue Jan 30, 2018 1:46 pm

Thanks for the quick responses.

On the face of it, Thorsten's suggestions sound like what I am looking for; I will look into this further, but a 3D model I can attach to an aircraft (or position relative to it) and animate with code would probably achieve what I am looking for!

Hooray, perhaps my explanation was not particularly clear; what I would like to achieve is to attach these radar-beam's to the front of AI aircraft so that I can see the visualisation from outside of the cockpit rather than seeing it from within the cockpit or as a separate 'radar-display' type view. The beam and the AI aircraft would be controlled through script. I suppose in simple terms if you could imagine i wanted to implement a programmatically controlled lighthouse where you can see the light-beam emanating from the lighthouse model.

I could be wrong, but I thought that 'canvas' was a 2D environment and renders in a separate 'window'! according to the wiki page: it is a
http://wiki.flightgear.org/Canvas wrote:'Dynamic 2D drawing at runtime using the property tree and scripting (for instruments, HUDs, GUIs)'
. I am not sure it will solve my problem, unless I am missing something. Perhaps you could elaborate, are there any specific examples similar to what I would like to achieve that I could look at perhaps?

Thanks for your help guys.

Robbo
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Hooray » Tue Jan 30, 2018 3:08 pm

A Canvas works in terms of so called "placements" - that determine where a Canvas texture shows up (e.g. GUI dialog, aircraft instrument or scenery object). So, depending on your requirements, a Canvas doesn't necessarily show up in a separate "window", it can also be a part of the scene/aircraft cockpit - which is how HUDs are working.


For the sake of completeness, I believe that you could also use effects/shaders to accomplish this (Thorsten would be the right person to ask for details).
Anyway, given your requirements (so far), I would say the closest thing we currently have matching your requirements is the so called "glideslope tunnel:"

http://wiki.flightgear.org/Glideslope_Tunnel
Image

You can find the code for this in $FG_ROOT/Nasal: https://sourceforge.net/p/flightgear/fg ... tunnel.nas

This should be fairly easy to adapt according to your requirements - it works via FlightGear scripting (Nasal), the put_model() API: http://wiki.flightgear.org/Nasal_library/geo

The whole geo module should come in handy when working on such stuff: http://wiki.flightgear.org/Nasal_library/geo

Besides, the whole approach should also work using a hybrid approach - including effects/shaders, as well as the Canvas system, i.e. if you need to do something really fancy.

PS: It would seem like a good idea to search the forum/wiki and devel list for "glideslope/tunnel" to come up with related code snippets/efforts and ideas.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Fri Feb 02, 2018 9:09 am

Ahh, thanks! I think the penny had dropped now; it seem that the canvas is more powerful than I had first understood from the documentation. I will look into this, thanks Hooray.

Whilst we are on the subject of Nasal. I am trying to use the tanker.nas to work out how I can add an aircraft (ai) to the scene and then control its position/orientation. I tried the 'geo.put_model(path, coord, course)', It shows on screen, but I don't seem to be able to control the position information held under /models/my_model... after it is placed on the screen using the propertyTree. I tried an alternative method by creating a simple scenario xml and loading that scenario at startup and i was able to fully control this through /ai/models/my_model.

So how do I create an ai model using nasal at run time that I can then control using the propertyTree?

This was the code that I extracted from tanker.nas and modified, but it does not seem to create a model in the scene; what am i missing?
Code: Select all
var m = { };
      m.callsign = "";
      m.kias = 0;
      m.heading = 120;
      m.interval = 10;
      m.roll = 0;
      m.coord = geo.aircraft_position();
      m.anchor = m.coord.apply_course_distance(getprop("/orientation/heading-deg"), 100);

      var n = props.globals.getNode("models", 1);
      for (var i = 0; 1; i += 1)
         if (n.getChild("model", i, 0) == nil)
            break;
      m.model = n.getChild("model", i, 1);

      var n = props.globals.getNode("ai/models", 1);
      for (var i = 0; 1; i += 1)
         if (n.getChild("tanker", i, 0) == nil)
            break;
      m.ai = n.getChild("tanker", i, 1);

      m.ai.getNode("id", 1).setIntValue("5");
      m.ai.getNode("callsign", 1).setValue(m.callsign ~ "");
      m.ai.getNode("valid", 1).setBoolValue(1);

      m.latN = m.ai.getNode("position/latitude-deg", 1);
      m.lonN = m.ai.getNode("position/longitude-deg", 1);
      m.altN = m.ai.getNode("position/altitude-ft", 1);
      m.hdgN = m.ai.getNode("orientation/true-heading-deg", 1);
      m.pitchN = m.ai.getNode("orientation/pitch-deg", 1);
      m.rollN = m.ai.getNode("orientation/roll-deg", 1);
      m.ktasN = m.ai.getNode("velocities/true-airspeed-kt", 1);
      m.vertN = m.ai.getNode("velocities/vertical-speed-fps", 1);
      
      m.model.getNode("path", 1).setValue('Models/Aircraft/H-60.ac');
      m.model.getNode("latitude-deg-prop", 1).setValue(m.latN.getPath());
      m.model.getNode("longitude-deg-prop", 1).setValue(m.lonN.getPath());
      m.model.getNode("elevation-ft-prop", 1).setValue(m.altN.getPath());
      m.model.getNode("heading-deg-prop", 1).setValue(m.hdgN.getPath());
      m.model.getNode("pitch-deg-prop", 1).setValue(m.pitchN.getPath());
      m.model.getNode("roll-deg-prop", 1).setValue(m.rollN.getPath());

props.globals.getNode("ai/models/tanker/callsign", 1).setValue("test");
props.globals.getNode("ai/models/tanker/position/altitude-ft", 1).setValue("1500");
props.globals.getNode("ai/models/tanker/position/latitude-deg", 1).setValue("50.107982");
props.globals.getNode("ai/models/tanker/position/longitude-deg", 1).setValue("14.245417");
props.globals.getNode("ai/models/tanker/orientation/pitch-deg", 1).setValue("0");
props.globals.getNode("ai/models/tanker/orientation/roll-deg", 1).setValue("0");
props.globals.getNode("ai/models/tanker/orientation/true-heading-deg", 1).setValue("0");
props.globals.getNode("ai/models/tanker/velocities/true-airspeed-kt", 1).setValue("0");
props.globals.getNode("ai/models/tanker/velocities/vertical-speed-fps", 1).setValue("0");


Thanks for any help :)
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Thorsten » Fri Feb 02, 2018 11:05 am

I am trying to use the tanker.nas to work out how I can add an aircraft (ai) to the scene and then control its position/orientation.


That actually was the right idea - just do as the tanker is created, and it'll work fine.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Fri Feb 02, 2018 11:12 am

Thanks Thorsten, its good to hear that I am heading in the right direction, however, I am not seeing any model being rendered on screen with the code I used above. Did I miss something obvious?
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Thorsten » Fri Feb 02, 2018 12:07 pm

The above code is a fragment, it lays some groundwork but doesn't actually load any model ((if it gets called, that it - m merely defines a hash).
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Fri Feb 02, 2018 2:25 pm

ahh, of course, doh!

I found this snippet of code (from here: viewtopic.php?f=30&t=31938#), in case anybody is following this thread that successfully instantiates a model and provides propertyTree control over it
Code: Select all
var n = props.globals.getNode("models", 1);
  var i = 0;
  for (i = 0; 1==1; i += 1) {
    if (n.getChild("model", i, 0) == nil) {
      break;
    }
  }
  var objModel = n.getChild("model", i, 1); # can set this value of i manually to the index of the aircraft to be loaded!

  objModel.getNode("elevation",1).setDoubleValue(1500);
  objModel.getNode("latitude",1).setDoubleValue(50.107982);
  objModel.getNode("longitude",1).setDoubleValue(14.245417);
  objModel.getNode("elevation-ft-prop",1).setValue(objModel.getPath()~"/elevation");
  objModel.getNode("latitude-deg-prop",1).setValue(objModel.getPath()~"/latitude");
  objModel.getNode("longitude-deg-prop",1).setValue(objModel.getPath()~"/longitude");
  objModel.getNode("heading",1).setDoubleValue(0);
  objModel.getNode("pitch",1).setDoubleValue(0);
  objModel.getNode("roll",1).setDoubleValue(0);
  objModel.getNode("heading-deg-prop",1).setValue(objModel.getPath()~"/heading");
  objModel.getNode("pitch-deg-prop",1).setValue(objModel.getPath()~"/pitch");
  objModel.getNode("roll-deg-prop",1).setValue(objModel.getPath()~"/roll");

  objModel.getNode("path",1).setValue("Models/Aircraft/H-60.xml"); # this is the model to be loaded.

  var loadNode = objModel.getNode("load", 1);
  loadNode.setBoolValue(1);
  loadNode.remove();
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Hooray » Fri Feb 02, 2018 6:15 pm

I would be very willing to help with additional pointers etc - but it would be great if you could add your findings/code snippets to the wiki and document your approch - this is one of the most frequently asked questions after all.

As a matter of fact, take a look at: http://wiki.flightgear.org/Scripted_AI_Objects

Thus, having a dedicated tutorial covering everything would be awesome.

For additional pointers, see: http://wiki.flightgear.org/Scripted_AI_ ... ed_content
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Sun Feb 04, 2018 5:28 pm

Hooray,

I am more than happy to write up a wiki or 'blog' with code snippets once I complete my locally working code with the two aspects that I am trying to achieve (one down, one to go!). Would you like me to put this under the 'scripted objects' area? or would you prefer that I send you the content to put somewhere specific?

Robbo
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Thorsten » Sun Feb 04, 2018 5:34 pm

Why can't you simply attach the cone to the aircraft as child model? Working in aircraft-relative coordinates is probably much preferable over working in global coordinates, for a Nasal-placed model this is going to be one hell of a coordinate transformation problem.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Modelling a 3D 'RADAR Beam'

Postby robbo » Sun Feb 04, 2018 5:38 pm

Thanks Thorsten, I was going to try that approach, the thing I wasn't sure about was creating a semi-transparent cone model that could be manipulated/animated at run time by propertyTree/NASAL. I'm going to look further into this in the coming week!
robbo
 
Posts: 19
Joined: Thu Sep 15, 2011 9:38 pm

Re: Modelling a 3D 'RADAR Beam'

Postby Hooray » Sun Feb 04, 2018 6:52 pm

feel free to create your own article, the "scriptable ai objects" article has meanwhile become stalled apparently, so it's really just a collection of pointers currently.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11317
Joined: Tue Mar 25, 2008 8:40 am

Next

Return to Aircraft

Who is online

Users browsing this forum: YandexBot [Bot] and 2 guests