Howto:Animate canopy or doors
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 = aircraft.door.new ("/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:
<animation> <type>rotate</type> <object-name>canopy</object-name> <property>/controls/canopy/position-norm</property> <factor>55</factor> <!-- The rotation in degrees --> <center> <x-m>-2.7165</x-m> <y-m>0.0</y-m> <z-m>1.2040</z-m> </center> <axis> <x>0</x> <y>1</y> <z>0</z> </axis> </animation>
In the -set file add a binding to open/close the canopy. Eg.
<key n="4"> <name>Ctrl-d</name> <desc>Toggle Canopy</desc> <binding> <command>nasal</command> <script>MyAircraft.canopy.toggle();</script> </binding> </key>
The Nasal code runs the toggle method of object canopy created above.