Board index FlightGear Development Nasal

Animation with explicit coordinates and orientation

Nasal is the scripting language of FlightGear.

Animation with explicit coordinates and orientation

Postby Kikokou-san » Fri Dec 01, 2017 11:09 am

Hi all,

I am currently working on a way to integrate a moving third party 3D object (e.g. missile) inside FlightGear.

I have the expected coordinates of the 3D object at every frame from an external application that I integrated into FlightGear C++ code (using a library).

My idea is to create and set several properties (x,y,z position, roll, yaw, pitch) for the 3D object in the property tree in the C++ code directly, and update their values each frame in the C++ code also, according to the inputs from my external app.

However, I absolutely don't know how to link these properties to the actual position and orientation of my 3D object.

I guess this can be done in Nasal but I am not sure how..

Let's say that I will include the 3D object in the aircraft.xml file so that it is loaded with the aircraft.

I had a look at the <animation> tag to see if I could animate the object directly using this tag, but as this only allows for "rotate" and "translate", I would have to compute every frame the translation and rotation matrices. And anyway, I am not sure that I can include nasal inside a rotate and translate animation tag.

I am looking for a more direct link between an object position and orientation, and properties of the property tree.

Any hint ?

Thanks and best regards
Kikokou-san
 
Posts: 26
Joined: Wed Mar 15, 2017 9:55 am

Re: Animation with explicit coordinates and orientation

Postby Thorsten » Fri Dec 01, 2017 11:57 am

Let's say that I will include the 3D object in the aircraft.xml file so that it is loaded with the aircraft.


There's two basic situations.

1) If you do the above, you are committed to an aircraft-relative coordinate system (and have to take care of all transformations relative to the aircraft yourself).

2) If you load the model via the Nasal model manager, you control its world position (but it doesn't get carried by the aircraft).

I am currently working on a way to integrate a moving third party 3D object (e.g. missile) inside FlightGear.


You know that there's more than one framework to do missiles already, right? There's also other custom solution, i.e. cargo-towing and stacking with the Aircrane, co-orbiting payloads which can be caught or released for the Shuttle,...

So why don't you look into existing solutions rather than re-inventing everything?
Thorsten
 
Posts: 9821
Joined: Mon Nov 02, 2009 8:33 am

Re: Animation with explicit coordinates and orientation

Postby Kikokou-san » Fri Dec 01, 2017 1:16 pm

Hi Thorsten,

Thank you for the reply.

No, sorry I did not know such framework already exist. Actually, I talked about a missile but I was looking more generally to integrate any 3D object whom coordinates and orientation would be given from an external source. I'm not so interested in missiles themselves :D

And there can be cases where I would be fine with aircraft coordinates, and other for which the earth coordinate would be better indeed.

I will have a look at the example you quoted to see how the models poses are linked to internal properties.

Best regards
Kikokou-san
 
Posts: 26
Joined: Wed Mar 15, 2017 9:55 am

Re: Animation with explicit coordinates and orientation

Postby Hooray » Sat Dec 02, 2017 12:18 pm

If you can come up with a generic set of requirements, it should be relatively straightforward to also come up with a generic "3d model injection" mechanism using one of the I/O options (FGIOChannel) - we already have several FDM related I/O options, including one protocol that allows driving the main fdm using an external FDM. Which in turn means, that the corresponding protocol would be well-suited to serve as a template for coming up with a mechanism for injecting/updating arbitrary 3D models - because that's really what this is all about: the external 3D model position source could just be considered another "FDM", right ? At that point, it doesn't matter how your FDM computes its own position (relative/absolute).

For the I/O and protocol handling stuff, my suggestion would be to look at some of the existing features that have overlapping requirements:

http://wiki.flightgear.org/Property_Tree/Sockets
http://wiki.flightgear.org/Slaving_for_Dummies
http://wiki.flightgear.org/Property_Tre ... ol_Slaving
http://wiki.flightgear.org/Remote_Properties
http://wiki.flightgear.org/Howto:Implem ... _Protocols

Finally, there already is a mechanism in place that can "inject" arbitrary 3D objects into the scene and update those as required, it's called the Multiplayer system - and that's what I'd recommend to use for tinkering with the underlying idea - it's implemented on top of the AI system, so whatever approach you end up doing, your experience will be useful anyway- even if you should decide to come up with your own custom hard-coded protocol.

Primarily, the advantage here is that the MP system is relatively well documented meanwhile, and it does have a buch of 3rd party middleware that may be helpful when debugging things - we even have scripts and programgs that can "inject" traffic into the fg world

http://wiki.flightgear.org/Multiplayer_protocol

http://wiki.flightgear.org/FGAIS
Image
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: 11124
Joined: Tue Mar 25, 2008 8:40 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest