Howto:Animate canopy or doors

From FlightGear wiki
Jump to navigation Jump to search

Nasal implementation

The default door implementation features simple door movement. It also supports advanced features like init with positions other than "closed", as well as transition methods for arbitary movement. See FGDATA Nasal/aircraft.nas

Example: A canopy

Create a canopy object that uses the method in aircraft.door for animation. In a Nasal file of the aircraft that loads at start-up add:

var canopy = ("/controls/canopy/", 5);

This creates a node in the property tree that contains two properties, /controls/canopy/position-norm and /controls/canopy/enabled, and sets the transition time to 5 seconds.

In the model file add the animation:

  <factor>55</factor> <!-- The rotation in degrees -->

In the -set file add a binding to open/close the canopy. Eg.

	<key n="4">
	        <desc>Toggle Canopy</desc>

The Nasal code runs the toggle method of object canopy created above.