Board index FlightGear Development Aircraft

Aircraft model disintegration animation

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

Aircraft model disintegration animation

Postby Tomaskom » Mon Jul 28, 2014 8:56 pm

This is not me asking for help; instead, this is documentation and implementation HOWTO (will be moved to the wiki eventually) and place for you to ask questions.

Inspired by the recent work on aircraft damage systems, I decided to create animation of aircraft disintegration upon impact. It is based on Nasal and translate + rotate animations with heavy use of expressions. The basic idea is that aircraft freezes in place when it hits the ground, so I set up animations of aircraft parts continuing the movement, but no longer together :D They have some initial velocity and follow a parabolic curve until they hit the ground.

For those who don't want to read to the end - you can get my recently (pre)released L-159 ALCA which which features these animations. You can use it as reference implementation as well.
Disclaimer: it is still in the pre-release phase, so no texturing (some changes to the model are planned), no cockpit instruments yet etc.
http://fguk.eu/index.php/hangar/viewdow ... l-159-alca

Teaser video on YouTube (as seen in last newsletter):


Overall design

In the Nasal file, every part/group of parts of the model is initialized with coordinates of its center and some initial disintegration velocity, which should be directed away from the aircraft center. This could be easily randomized, but predefined values worked best for me. This initial disintegration speed is then later multiplied by disintegration severity, obtaining speed finally used for animation.
In the model XML file, one has to include translate and spin animation for every desired disintegration part. The animations read properties initialized by Nasal script and thanks to heavy use of expressions, the translate animations emulate a parabolic flight of each part until a timer set for every part separately stops it. This should result in parts laying on the ground when the surface is flat.
Details of the model can be simply hidden or grouped to one object with part they are placed on.

Upon impact, first thing that is done is a severity calculation. Then certain calculations are made for every disintegration part to set its initial speed and fall time (based on current AGL). Because of this, the animation works well only on approximately flat areas with zero slope. If the severity reaches certain value, explosion animation (and if on the ground, also fire with huge smoke) are triggered.
The disintegrate() function can be called externally by Nasal to emulate in-air disintegration/explosion, forcing custom severity is possible.


How to implement

In Disintegration.nas:
Add calls of the function initPart(name, dX, dY, dZ, vX=0, vY=0, vZ=0) for every part that is supposed to fly on a separate curve.
The Nasal code can be mirrored with some necessary adjustments in the <nasal> <load> </load> </nasal> part of the model XML file to achieve multiplayer support.

In the model XML file:
Include three translate (x,y,z) and up to three optional spin animations for every part.
The name string in the nasal initPart() call must match the property paths used for animation of that specific part in the model XML file. The center offsets dX, dY, dZ must match center of the spin animation. It is convenient to use the <name> animation for all the model pieces flying as one part during disintegration and to keep the name the same as in the nasal initPart() call for the sake of simplicity.
All the animations (especially spin) must be placed after any other animations applied on the parts, preferably as the last part of the model XML file. Spin must always be after the translation of the same part. Not following this will result in spinning around wrong point, which looks absolutely wrong.
All spin animations should include unique coefficients of rotation speed (which get multiplied by global rotation coefficient). This way the animation looks more random and natural.
In case you use separate file eg. for payload on underwing pylons, you may need to include the animations there as well.

For details and the actual code, see example implementation in the fresh L-159 ALCA public pre-release: http://fguk.eu/index.php/hangar/viewdow ... l-159-alca
The Nasal code is well commented, so it should be easy to understand the logic even without detailed study of the calculations used.
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Aircraft model disintegration animation

Postby Hooray » Mon Jul 28, 2014 9:41 pm

that's pretty impressive - flug and the T4T guys should love this! :D
It's funny how discussions we've had years ago actually end up becoming actual features over time !

I would really love to see this being turned into a generic module that can be used by flug/the bombable addon, and maybe even our AI missiles (e.g. fox2.nas)
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: 12057
Joined: Tue Mar 25, 2008 8:40 am

Re: Aircraft model disintegration animation

Postby Tomaskom » Mon Jul 28, 2014 10:09 pm

Hooray wrote in Mon Jul 28, 2014 9:41 pm:that's pretty impressive - flug and the T4T guys should love this! :D
It's funny how discussions we've had years ago actually end up becoming actual features over time !

I would really love to see this being turned into a generic module that can be used by flug/the bombable addon, and maybe even our AI missiles (e.g. fox2.nas)

Hehe, I didn't know some discussions like this took place!

Currently it can hardly be a generic module. Even when writing and tuning the Nasal part was lenghty, the most time consuming (and over time boring) part was applying the animation on all parts of the model. It took me several afternoons...
The only way I could see it as a generic module would be to write some code for autogeneration of the disintegration setup based on the .ac file :roll:
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Aircraft model disintegration animation

Postby omega95 » Wed Jul 30, 2014 8:13 pm

It shouldn't be difficult to write a nasal script that parses the ac file and generates the XML animations.

Also, it would seem smoother if the view position moved with the aircraft parts after the impact/dis-integration and slowed down to a stop, don't you think?
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1222
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Aircraft model disintegration animation

Postby Tomaskom » Thu Jul 31, 2014 5:14 pm

omega95 wrote in Wed Jul 30, 2014 8:13 pm:Also, it would seem smoother if the view position moved with the aircraft parts after the impact/dis-integration and slowed down to a stop, don't you think?


Yes, I'll try to do that, good idea :)

About the parser, yes, it should be possible. However, not enough time to dive into it now... I'll definitely try it at some point, right now I'm just drowning in unfinished work.
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)


Return to Aircraft

Who is online

Users browsing this forum: AhrefsBot [Bot], Thorsten and 2 guests