Board index FlightGear Development Nasal

geo.nas - geo.put_model ?

Nasal is the scripting language of FlightGear.

geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 1:34 pm

Hi,

browsing through the nasal folder, I found geo.nas.
I found in the included documentation, a method called geo.put_model.

Now I have a lot of questions, I hope someone can help me....

Am I right this method places a model via nasal on a position given in geo.put_model? Even at runtime?
And would it be possible to run this from nasal included in static model of scenery?

I'm asking, because I would like to have an object in scenery which change its position with using the position of an AIship.
something like: (AIship (lat, long, elevation) --> StaticModel (lat, long, elevation of the ASIShip).

Or better said; I would like to replace the Model used by an AIShip-scenario with a model located in the scenery/objects/...-folder


Any ideas?
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby Thorsten » Fri Sep 24, 2010 3:41 pm

Am I right this method places a model via nasal on a position given in geo.put_model? Even at runtime?


My understanding is that this is what it does, yes. The Vulcan uses it for example to generate impact craters for the bombs if you'd like to study an example.

And would it be possible to run this from nasal included in static model of scenery?


I think so - Nasal seems to be pretty much Nasal, once it's executed.

I'm asking, because I would like to have an object in scenery which change its position with using the position of an AIship.


Not exactly sure what you want - do you want to update the position of the second model at runtime, or do you want to place an unmoving model next to it. Objects placed from Nasal at runtime don't move on their own, so if you want something dynamically adjusting position, you need more heavy-duty Nasal technology.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: geo.nas - geo.put_model ?

Postby DFaber » Fri Sep 24, 2010 4:16 pm

HHS wrote:Am I right this method places a model via nasal on a position given in geo.put_model? Even at runtime?


That's right, but it is a static model, like scenery models and there are no lat/lon properties to access and manipulate. However if it contains nasal it may be able to do something (although I haven't tried).

If you want to create a manipulatable model you need to create a property tree under /models (That's how the external Walkers are created). Once this model is existant in the FG World you have complete control via nasal, or just sync the lat/lon/heigth proerties.

Greetings
Detlef Faber
FlightGear Development:
http://flightgear-de.net

my 3D-Art:
https://www.sol2500.net
DFaber
 
Posts: 709
Joined: Fri Dec 01, 2006 8:51 pm
Location: Aachen, Germany
Version: GIT
OS: Linux

Re: geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 4:31 pm

Thorsten wrote:The Vulcan uses it for example to generate impact craters for the bombs if you'd like to study an example.


Thanks- that example helped me further, though it does not behaves as I hoped...

Not exactly sure what you want - do you want to update the position of the second model at runtime, or do you want to place an unmoving model next to it. Objects placed from Nasal at runtime don't move on their own, so if you want something dynamically adjusting position, you need more heavy-duty Nasal technology.


I wanted to have the first option: update the position of the second model at runtime.

Seems as it isn't working, so then I have to live with the limitation. :|
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 4:32 pm

Thanks Detlef, I will take a look
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby Thorsten » Fri Sep 24, 2010 4:39 pm

Have a look at tanker.nas, that's an example for a Nasal-created model moved at runtime. You just need to write info into /models/ in the tree and then update the position with a control loop - I've been making a living out of that...

(You can even have it twice as efficient as in the tanker script...)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 4:58 pm

Thorsten wrote:Have a look at tanker.nas, that's an example for a Nasal-created model moved at runtime. You just need to write info into /models/ in the tree and then update the position with a control loop - I've been making a living out of that...

(You can even have it twice as efficient as in the tanker script...)


Moving an AI-model (ship, carrier, tanker, thermals....) isn't the problem. That has been already solved as you can see here.
The pads are working, I can even steer them in all directions ("drive" them). Even Pushback over Mp independant of fdm should be theoretically possible.

Problem is that the model used is defined in the AIscenario_file. No chance to use something others than this model.
But I would give scenery developers the chance to use their own models. That's why I hope to find a way to synchronize the model with the AI-model....
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby Thorsten » Fri Sep 24, 2010 5:07 pm

Moving an AI-model (ship, carrier, tanker, thermals....) isn't the problem.


Yes, that's why I am telling you how you can spawn and control any model at runtime from Nasal...
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 5:12 pm

Detlef- you are genious! :D
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby HHS » Fri Sep 24, 2010 5:17 pm

Thorsten wrote:
Moving an AI-model (ship, carrier, tanker, thermals....) isn't the problem.


Yes, that's why I am telling you how you can spawn and control any model at runtime from Nasal...


Thanks for your help as well, I have solved my problem now with help of Detlef, but your hints and tips were very helpful as well!

It is very interesting what you can do all just with nasal! :shock:
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: geo.nas - geo.put_model ?

Postby TheEagle » Thu Apr 14, 2022 11:13 pm

Sorry for bumping this very old thread, but I simply can't find a way to move a model placed with geo.put_model. I have tried modifying any of the orientation and position properties of it's /models/model node, but nothing happens. I have also tried toggling the loaded node which had no effect either. After that I came across this thread and looked into $FGDATA/Nasal/tanker.nas and saw that there some {heading, pitch, roll, …}-deg-prop nodes are created in /models/model, which I all set to the respective properties in /orientation, but the model still didn't turn around when I turned the aircraft around … So I copied the code from tanker.nas and modified it a bit:
Code: Select all
   var n = props.globals.getNode("models", 1);
   for (var i = 0; 1; i += 1)
      if (n.getChild("model", i, 0) == nil)
         break;
   m = n.getChild("model", i, 1);
   m.getNode("path", 1).setValue(addon.basePath ~ "/Models/pod.xml");
   m.getNode("latitude-deg-prop", 1).setValue("/addons/latitude-deg");
   m.getNode("longitude-deg-prop", 1).setValue("/addons/longitude-deg");
   m.getNode("elevation-ft-prop", 1).setValue("/addons/elevation-ft");
   m.getNode("heading-deg-prop", 1).setValue("/addons/heading-deg");
   m.getNode("pitch-deg-prop", 1).setValue("/addons/pitch-deg");
   m.getNode("roll-deg-prop", 1).setValue("/addons/roll-deg");
   m.getNode("load", 1).remove();

And indeed, this DOES work ! But whyever doesn't this work with geo.put_model ? I don't get it.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3414
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: geo.nas - geo.put_model ?

Postby TheEagle » Fri Apr 15, 2022 11:38 pm

By some experimenting I found out that apparently the information for position is only read ONCE when loaded OR the -prop nodes are read ONCE, and there's no way of changing them later. So I am really expected to either remove and reload the model whenever I need to change the position sources, OR need to run a Nasal loop as fast as possible (at frame rate ?) to copy the aircraft position or a custom position into a custom property which the model is bound to ? :roll:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3414
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: geo.nas - geo.put_model ?

Postby wlbragg » Fri Apr 15, 2022 11:42 pm

Look in Mission Generator addon and Cargo Towing addon for many examples of manipulating ai traffic, ai scenario and geo introduced models. They can all be moved dynamically
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: geo.nas - geo.put_model ?

Postby wlbragg » Fri Apr 15, 2022 11:44 pm

The Space Shuttle also has some good examples.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: geo.nas - geo.put_model ?

Postby TheEagle » Sat Apr 16, 2022 12:00 am

Yes - I already looked in the Cargo towing addon and I saw that the position is updated by a Nasal timer ! :wink: Also I do not have time to look into this much further ATM as I've got to get something done with it until Sunday ! ;)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3414
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Next

Return to Nasal

Who is online

Users browsing this forum: No registered users and 4 guests