Board index FlightGear Support Interfacing

Fixed Geometry and Explosion

Connecting two computers, using generic protocol, connecting with Matlab?

Fixed Geometry and Explosion

Postby JM_Olmos » Wed Sep 21, 2016 2:11 pm

Dear community,

As I have already posted, I am trying to simulate a vehicle flight in FlightSimulator from Matlab (with excellent results thanks to this forum). However, in order to improve a little bit the simulator, I want to place an existing geometry in a fixed place (ground). Moreover, I would like also to represent fire or an explosion in an specific time and location on the ground.

Any ideas/advices?

Thanks!
JM_Olmos
 
Posts: 9
Joined: Tue Jul 12, 2016 9:14 am

Re: Fixed Geometry and Explosion

Postby curt » Wed Sep 21, 2016 2:22 pm

It's been a while since I messed with submodels, but a FlightGear aircraft can be configured to spawn new objects that then follow some simple trajectory / rules. You can define some simple aero properties and then the model will follow basic physics, and can be affected by wind (or not) until it hits the ground or otherwise expires. When the object does hit the ground you can configure it to report the impact location. That could allow you to spawn a forest fire there, or perhaps spawn some other AI model there. If you want to compute the flight of your object externally, then I'm not sure if there is a way to easily represent the object in flight, but you should be able to spawn arbitrary "ai" models at arbitrary locations with a little nasal help.

This is a good starting point for submodels:

http://wiki.flightgear.org/Howto:Add_submodels

In my own work I often add "trajectory" markers (simple submodels that are unaffected by wind or gravity and just float motionless forever where they are spawned.) As I fly so I can see the precise path of the aircraft. If I'm working on anything repeatable I can see how consistent my flight controller can be when repeating a task under fairly realistic conditions. (Like flying a circle hold in wind.)

A while ago I had partial success with trying to model one vehicle carrying another vehicle. Typically the 2nd vehicle would be released at ground level or just above, but then I could use submodels to animate the release and record the precise location it is deposited. I tried to play some tricks with drawing a fake cargo vehicle suspended by the primary vehicle, and then hid that using an animation selection switch when the submodel was spawned (so the submodel gets swapped in at that point.) Then when submodel his the ground I sent a message to a second copy of FlightGear with the location and it spawned an interactive vehicle at that spot. With multplayer turned on, this second vehicle then is independently controllable through a second copy of FlightGear. The end result was being able to have one interactive vehicle deposit another interactive vehicle at a specific location and then the two could fly off to do their independent tasks ... and then I could reverse this for the pickup. I never got the transitions completely seamless so I was never completely happy with the result. But with a bit of hackery and trickery, quite a bit of complex behavior and interactions are possible.

Here's a crude example ... for ease of testing I was using the UFO flight model, but I wanted some sort of plausible looking test so I substituded in the osprey 3d model. But the ufo fdm doesn't spin the osprey propellors and that was a low priority at the time .... the drop/pickup mechanics was my focus.

https://www.youtube.com/watch?v=60mPe9-SV5Y
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1168
Joined: Thu Jan 01, 1970 1:00 am
Location: Minneapolis, MN

Re: Fixed Geometry and Explosion

Postby Thorsten » Wed Sep 21, 2016 3:08 pm

However, in order to improve a little bit the simulator, I want to place an existing geometry in a fixed place (ground).


geo.nas has a put_model method:

Code: Select all
# geo.put_model(<path>, <lat>, <lon> [, <elev:nil> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]]);
#                                 ... put model <path> at location <lat>/<lon> with given elevation
#                                     (optional, default: surface). <hdg>/<pitch>/<roll> are optional
#                                     and default to zero.


which allows you to spawn something at a given location - does that sound like what you need?

Moreover, I would like also to represent fire or an explosion in an specific time and location on the ground.


I gather that's typically placing a particle system rather than a 3d model - technology is the same.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Fixed Geometry and Explosion

Postby Hooray » Wed Sep 21, 2016 9:42 pm

Also note that there is the so called "wildfire" addon which was developed by AndersG, and which is used by other addons, e.g. the bombable addon to simulate fire effects - for details, refer to the wiki
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Fixed Geometry and Explosion

Postby JM_Olmos » Thu Sep 22, 2016 8:43 am

Thorsten wrote in Wed Sep 21, 2016 3:08 pm:
However, in order to improve a little bit the simulator, I want to place an existing geometry in a fixed place (ground).


geo.nas has a put_model method:

Code: Select all
# geo.put_model(<path>, <lat>, <lon> [, <elev:nil> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]]);
#                                 ... put model <path> at location <lat>/<lon> with given elevation
#                                     (optional, default: surface). <hdg>/<pitch>/<roll> are optional
#                                     and default to zero.


which allows you to spawn something at a given location - does that sound like what you need?

Moreover, I would like also to represent fire or an explosion in an specific time and location on the ground.


I gather that's typically placing a particle system rather than a 3d model - technology is the same.


That is exactly what I want. However I have no previous experience with Nasal functions (Not a real one) and I am not sure how to "execute" the function... I have tried to use the following function in the command line:
Code: Select all
geo.put_model(Aircraft\HL20\Models, 32.818, 44.385);

But geo.nas is not recognised as an internal function...

EDIT: Ok, I have seen the nasal console :oops: . But there is a "Parse error: illegal character"
Last edited by JM_Olmos on Thu Sep 22, 2016 10:59 am, edited 1 time in total.
JM_Olmos
 
Posts: 9
Joined: Tue Jul 12, 2016 9:14 am

Re: Fixed Geometry and Explosion

Postby JM_Olmos » Thu Sep 22, 2016 8:45 am

Hooray wrote in Wed Sep 21, 2016 9:42 pm:Also note that there is the so called "wildfire" addon which was developed by AndersG, and which is used by other addons, e.g. the bombable addon to simulate fire effects - for details, refer to the wiki


Thanks for your answer. I have the wildfire option selected but I see no fire when it crashes... When I try to Load Wilfire Log in the options, FG stops working and closes everything...
JM_Olmos
 
Posts: 9
Joined: Tue Jul 12, 2016 9:14 am

Re: Fixed Geometry and Explosion

Postby AndersG » Thu Sep 22, 2016 11:32 am

JM_Olmos wrote in Thu Sep 22, 2016 8:45 am:Thanks for your answer. I have the wildfire option selected but I see no fire when it crashes... When I try to Load Wilfire Log in the options, FG stops working and closes everything...


Hmm.. loading a valid fire event log should not do that (nor should trying to load an invalid) but I have not tried that function for a long long time.
You can try the "pyromaniac.nas" script found at the below address to enable foam drop by shift+click on terrain and starting a fire by shit+ctrl+click on terrain to see if WildFire works for you (it does work for me with a current FG/git). Installation is by copying it into your FGDATA/Nasal/ directory or into the ~/.fgfs/Nasal/ in your home directory (for unix systems).
http://www.gidenstam.org/FlightGear/misc/WildFire/pyromaniac.nas

Note that it is only some ground types that are flammable - and newer scenery generations have introduced more ground types than what is currently supported in the WildFire code - and the default behaviour is non-ignitable.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2527
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Fixed Geometry and Explosion

Postby PINTO » Thu Sep 22, 2016 5:23 pm

JM_Olmos wrote in Thu Sep 22, 2016 8:43 am:That is exactly what I want. However I have no previous experience with Nasal functions (Not a real one) and I am not sure how to "execute" the function... I have tried to use the following function in the command line:
Code: Select all
geo.put_model(Aircraft\HL20\Models, 32.818, 44.385);

But geo.nas is not recognised as an internal function...

EDIT: Ok, I have seen the nasal console :oops: . But there is a "Parse error: illegal character"


You can create a "fire.nas" file and include in your aircraft's folder somewhere. Then in the -set.xml file, do a
Code: Select all
<nasal>
  <fire>
    <file>Aircraft/path/to/nasal/file/fire.nas</file> <!-- path is relative to any aircraft folders you have set up -->
  </fire>
</nasal>


Also, with your geo.put_model(), your path needs to be surrounded by quotations, and be a path to a valid model, not the folder the model is in. So

Code: Select all
geo.put_model("Aircraft/HL20/Models/fire.xml", 32.818, 44.385);
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 966
Joined: Wed Oct 21, 2015 7:28 pm
Callsign: pinto
Version: stable
OS: Win10

Re: Fixed Geometry and Explosion

Postby JM_Olmos » Fri Sep 23, 2016 9:09 am

PINTO wrote in Thu Sep 22, 2016 5:23 pm:
Also, with your geo.put_model(), your path needs to be surrounded by quotations, and be a path to a valid model, not the folder the model is in. So

Code: Select all
geo.put_model("Aircraft/HL20/Models/fire.xml", 32.818, 44.385);


Thanks, this works perfectly. Can I include it in the -set.xml to spawn it automatically? (Instead of using the Nasal console each time)

I do not understand the fire.nas thing. There is an existing fire.nas file in the Nasal folder? Or what shoul be in this file?

Regards from France!
JM_Olmos
 
Posts: 9
Joined: Tue Jul 12, 2016 9:14 am

Re: Fixed Geometry and Explosion

Postby PINTO » Fri Sep 23, 2016 7:26 pm

*.nas is the default extension of nasal files. You can include aircraft-specific nasal files in with your aircraft.

So, open up your text editor of choice, and copy the "geo.put_model("Aircraft/HL20/Models/fire.xml", 32.818, 44.385);" line in (only this line is okay), and save it as "fire.nas" or whatever you want to name it as. Save it in your aircraft folder. Usual convention is there is a ./Nasal folder that contains most/all of the scripts, but it's up to you where to save it.

Then, in your -set.xml, include these lines:

Code: Select all
<nasal>
  <fire>
    <file>Aircraft/path/to/fire.nas</file>
  </fire>
</nasal>


And that'll load the script automatically at run time.
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 966
Joined: Wed Oct 21, 2015 7:28 pm
Callsign: pinto
Version: stable
OS: Win10


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 2 guests