<?xml version="1.0" encoding="UTF-8"?>
<!--
**************************************************************************

Beagle Pup Model

Copyright (c) 2015 Richard Senior

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

**************************************************************************
-->

<PropertyList>

  <params>
    <beacon-state>sim/multiplay/generic/int[0]</beacon-state>
    <landing-light-volts>sim/multiplay/generic/float[1]</landing-light-volts>
    <nav-light-volts>sim/multiplay/generic/float[2]</nav-light-volts>
    <taxi-light-volts>sim/multiplay/generic/float[4]</taxi-light-volts>
  </params>

  <model>
    <name>Cockpit</name>
    <path>cockpit.xml</path>
    <usage>interior</usage>
  </model>

  <!--===================================================================-->
  <!-- MATERIAL AND LIVERY                                               -->
  <!--===================================================================-->

  <animation>
    <type>material</type>
    <object-name>Exterior</object-name>
    <object-name>FlapLeft</object-name>
    <object-name>FlapRight</object-name>
    <object-name>AileronLeft</object-name>
    <object-name>AileronRight</object-name>
    <object-name>ElevatorLeft</object-name>
    <object-name>ElevatorRight</object-name>
    <object-name>Rudder</object-name>
    <object-name>Propeller</object-name>
    <object-name>HubCapLeft</object-name>
    <object-name>HubCapRight</object-name>
    <object-name>HubCapFront</object-name>
    <property-base>sim/model/livery</property-base>
    <texture-prop>texture</texture-prop>
  </animation>

  <effect>
    <inherits-from>Aircraft/Beagle-Pup/Models/Effects/chrome</inherits-from>
    <object-name>WheelMountFrontChrome</object-name>
  </effect>

  <effect>
    <inherits-from>Aircraft/Beagle-Pup/Models/Effects/glass</inherits-from>
    <object-name>Windscreen</object-name>
    <object-name>WindowPilot</object-name>
    <object-name>WindowCoPilot</object-name>
    <object-name>WindowPilotRear</object-name>
    <object-name>WindowCoPilotRear</object-name>
  </effect>

  <effect>
    <inherits-from>Aircraft/Beagle-Pup/Models/Effects/reflect</inherits-from>
    <object-name>Exterior</object-name>
    <object-name>ExteriorFittings</object-name>
    <object-name>FlapLeft</object-name>
    <object-name>FlapRight</object-name>
    <object-name>AileronLeft</object-name>
    <object-name>AileronRight</object-name>
    <object-name>ElevatorLeft</object-name>
    <object-name>ElevatorRight</object-name>
    <object-name>Rudder</object-name>
    <object-name>Propeller</object-name>
    <object-name>HubCapLeft</object-name>
    <object-name>HubCapRight</object-name>
    <object-name>HubCapFront</object-name>
  </effect>

  <!--===================================================================-->
  <!-- CONTROL SURFACES                                                  -->
  <!--===================================================================-->

  <animation>
    <type>rotate</type>
    <object-name>AileronLeft</object-name>
    <property>surface-positions/left-aileron-pos-norm</property>
    <factor>-28</factor>
    <axis>
      <x1-m>2.7523</x1-m>
      <y1-m>-2.8229</y1-m>
      <z1-m>-0.0438</z1-m>
      <x2-m>2.5900</x2-m>
      <y2-m>-4.5868</y2-m>
      <z2-m>0.1626</z2-m>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>AileronRight</object-name>
    <property>surface-positions/right-aileron-pos-norm</property>
    <factor>28</factor>
    <axis>
      <x1-m>2.7523</x1-m>
      <y1-m>2.8236</y1-m>
      <z1-m>-0.0759</z1-m>
      <x2-m>2.5900</x2-m>
      <y2-m>4.5864</y2-m>
      <z2-m>0.1726</z2-m>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>ElevatorLeft</object-name>
    <property>surface-positions/elevator-pos-norm</property>
    <factor>30</factor>
    <center>
      <x-m>5.8959</x-m>
      <y-m>-1.4150</y-m>
      <z-m>0.2192</z-m>
    </center>
    <axis>
      <x>0.0</x>
      <y>1.0</y>
      <z>0.0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>ElevatorRight</object-name>
    <property>surface-positions/elevator-pos-norm</property>
    <factor>30</factor>
    <center>
      <x-m>5.8959</x-m>
      <y-m>1.4150</y-m>
      <z-m>0.2192</z-m>
    </center>
    <axis>
      <x>0.0</x>
      <y>1.0</y>
      <z>0.0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>Rudder</object-name>
    <property>surface-positions/rudder-pos-norm</property>
    <factor>-25</factor>
    <axis>
      <x1-m>6.6435</x1-m>
      <y1-m>0.0019</y1-m>
      <z1-m>1.1905</z1-m>
      <x2-m>6.3064</x2-m>
      <y2-m>0.0019</y2-m>
      <z2-m>-0.1910</z2-m>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>FlapLeft</object-name>
    <property>surface-positions/flap-pos-norm</property>
    <factor>-39.5</factor>
    <axis>
      <x1-m>2.9433</x1-m>
      <y1-m>-0.7705</y1-m>
      <z1-m>-0.2990</z1-m>
      <x2-m>2.7535</x2-m>
      <y2-m>-2.8173</y2-m>
      <z2-m>-0.0701</z2-m>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>FlapRight</object-name>
    <property>surface-positions/flap-pos-norm</property>
    <factor>-39.5</factor>
    <axis>
      <x1-m>2.7536</x1-m>
      <y1-m>2.8121</y1-m>
      <z1-m>-0.0516</z1-m>
      <x2-m>2.9433</x2-m>
      <y2-m>0.7675</y2-m>
      <z2-m>-0.2989</z2-m>
    </axis>
  </animation>

  <!--===================================================================-->
  <!-- GEAR                                                              -->
  <!-- The order of animation is important in this section               -->
  <!--===================================================================-->

  <animation>
    <type>translate</type>
    <object-name>HubCapFront</object-name>
    <object-name>WheelMountFront</object-name>
    <object-name>WheelMountFrontChrome</object-name>
    <object-name>WheelFront</object-name>
    <object-name>ScissorBottom</object-name>
    <property>gear/gear/compression-norm</property>
    <factor>-0.3</factor>
    <offset-m>0.07</offset-m>
    <axis>
      <x1-m>1.1145</x1-m>
      <y1-m>0.0003</y1-m>
      <z1-m>-0.5206</z1-m>
      <x2-m>0.9955</x2-m>
      <y2-m>0.0003</y2-m>
      <z2-m>-1.0747</z2-m>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>ScissorTop</object-name>
    <expression>
      <rad2deg>
        <asin>
          <mod>
            <div>
              <difference>
                <product>
                  <property>gear/gear/compression-norm</property>
                  <value>0.3</value> <!-- Match translate factor -->
                </product>
                <value>0.07</value> <!-- Match translate offset -->
              </difference>
              <value>0.2400</value>
            </div>
            <value>1</value>
          </mod>
        </asin>
      </rad2deg>
    </expression>
    <center>
      <x-m>1.1406</x-m>
      <y-m>-0.0006</y-m>
      <z-m>-0.6588</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>-1</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>ScissorBottom</object-name>
    <expression>
      <rad2deg>
        <asin>
          <mod>
            <div>
              <difference>
                <product>
                  <property>gear/gear/compression-norm</property>
                  <value>0.3</value> <!-- Match translate factor -->
                </product>
                <value>0.07</value> <!-- Match translate offset -->
              </difference>
              <value>0.2400</value>
            </div>
            <value>1</value>
          </mod>
        </asin>
      </rad2deg>
    </expression>
    <center>
      <x-m>1.1091</x-m>
      <y-m>-0.0006</y-m>
      <z-m>-0.8091</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>WheelLeft</object-name>
    <object-name>HubCapLeft</object-name>
    <property>gear/gear[1]/compression-norm</property>
    <factor>70</factor>
    <offset-deg>-8</offset-deg>
    <center>
      <x-m>2.4311</x-m>
      <y-m>-1.2079</y-m>
      <z-m>-1.0583</z-m>
    </center>
    <axis>
      <x>-1</x>
      <y>0</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>WheelRight</object-name>
    <object-name>HubCapRight</object-name>
    <property>gear/gear[2]/compression-norm</property>
    <factor>70</factor>
    <offset-deg>-8</offset-deg>
    <center>
      <x-m>2.4309</x-m>
      <y-m>1.2155</y-m>
      <z-m>-1.0590</z-m>
    </center>
    <axis>
      <x>1</x>
      <y>0</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>HubCapFront</object-name>
    <object-name>WheelMountFront</object-name>
    <object-name>WheelMountFrontChrome</object-name>
    <object-name>WheelFront</object-name>
    <property>fdm/jsbsim/fcs/steer-pos-deg</property>
    <condition>
      <property>gear/gear/wow</property>
    </condition>
    <factor>1</factor>
    <axis>
      <x1-m>1.1145</x1-m>
      <y1-m>0.0003</y1-m>
      <z1-m>-0.5206</z1-m>
      <x2-m>0.9955</x2-m>
      <y2-m>0.0003</y2-m>
      <z2-m>-1.0747</z2-m>
    </axis>
  </animation>

  <animation>
    <object-name>HubCapFront</object-name>
    <object-name>WheelFront</object-name>
    <type>spin</type>
    <property>gear/gear/rollspeed-ms</property>
    <factor>-53.6478</factor>
    <center>
      <x-m>0.9957</x-m>
      <y-m>0.1412</y-m>
      <z-m>-1.0745</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <object-name>HubCapLeft</object-name>
    <object-name>WheelLeft</object-name>
    <type>spin</type>
    <property>gear/gear/rollspeed-ms</property>
    <factor>-53.6478</factor>
    <center>
      <x-m>2.4311</x-m>
      <y-m>-1.2666</y-m>
      <z-m>-1.0583</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </axis>
  </animation>

  <animation>
    <object-name>HubCapRight</object-name>
    <object-name>WheelRight</object-name>
    <type>spin</type>
    <property>gear/gear/rollspeed-ms</property>
    <factor>-53.6478</factor>
    <center>
      <x-m>2.4309</x-m>
      <y-m>1.2701</y-m>
      <z-m>-1.0590</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </axis>
  </animation>

  <!--===================================================================-->
  <!-- PROPELLER                                                         -->
  <!--===================================================================-->

  <animation>
    <type>select</type>
    <object-name>Propeller</object-name>
    <condition>
      <less-than>
        <property>engines/engine/rpm</property>
        <value>500</value>
      </less-than>
    </condition>
  </animation>

  <animation>
    <type>select</type>
    <object-name>PropellerBlur</object-name>
    <condition>
      <and>
        <not>
          <property>sim/current-view/internal</property>
        </not>
        <greater-than-equals>
          <property>engines/engine/rpm</property>
          <value>500</value>
        </greater-than-equals>
      </and>
    </condition>
  </animation>

  <animation>
    <type>spin</type>
    <object-name>Propeller</object-name>
    <property>engines/engine/rpm</property>
    <center>
      <x-m>0.3142</x-m>
      <y-m>0.0</y-m>
      <z-m>0.0</z-m>
    </center>
    <axis>
      <x>-1.0</x>
      <y>0.0</y>
      <z>0.0</z>
    </axis>
  </animation>

  <animation>
    <type>spin</type>
    <object-name>PropellerBlur</object-name>
    <property>engines/engine/rpm</property>
    <center>
      <x-m>0.3142</x-m>
      <y-m>0.0</y-m>
      <z-m>0.0</z-m>
    </center>
    <axis>
      <x>-1.0</x>
      <y>0.0</y>
      <z>0.0</z>
    </axis>
  </animation>

  <!--===================================================================-->
  <!-- PROCEDURAL LIGHTS (ALS)                                           -->
  <!--===================================================================-->

  <model>
    <name>ProceduralBeacon</name>
    <path>Effects/Lights/beacon.xml</path>
    <offsets>
      <x-m>4.1450</x-m>
      <y-m>0.0</y-m>
      <z-m>0.5852</z-m>
    </offsets>
  </model>

  <animation>
    <type>select</type>
    <object-name>ProceduralBeacon</object-name>
    <condition>
      <property alias="../../../params/beacon-state"/>
    </condition>
  </animation>

  <animation>
    <type>material</type>
    <object-name>Beacon</object-name>
    <condition>
      <property alias="../../../params/beacon-state"/>
    </condition>
    <emission>
      <red>1.0</red>
      <green>0.5</green>
      <blue>0.5</blue>
    </emission>
  </animation>

  <model>
    <name>ProceduralTail</name>
    <path>Effects/Lights/tail.xml</path>
    <offsets>
      <x-m>6.9974</x-m>
      <y-m>0.0</y-m>
      <z-m>1.3133</z-m>
    </offsets>
  </model>

  <animation>
    <type>select</type>
    <object-name>ProceduralTail</object-name>
    <condition>
      <property alias="../../../params/nav-light-volts"/>
    </condition>
  </animation>

  <animation>
    <type>rotate</type>
    <object-name>TailLight</object-name>
    <object-name>ProceduralTail</object-name>
    <property>surface-positions/rudder-pos-norm</property>
    <factor>-25</factor>
    <axis>
      <x1-m>6.6435</x1-m>
      <y1-m>0.0019</y1-m>
      <z1-m>1.1905</z1-m>
      <x2-m>6.3064</x2-m>
      <y2-m>0.0019</y2-m>
      <z2-m>-0.1910</z2-m>
    </axis>
  </animation>

  <model>
    <name>ProceduralNavLeft</name>
    <path>Effects/Lights/nav-left.xml</path>
    <offsets>
      <x-m>2.1575</x-m>
      <y-m>-4.8707</y-m>
      <z-m>0.1680</z-m>
    </offsets>
  </model>

  <model>
    <name>ProceduralNavRight</name>
    <path>Effects/Lights/nav-right.xml</path>
    <offsets>
      <x-m>2.1575</x-m>
      <y-m>4.8715</y-m>
      <z-m>0.1680</z-m>
    </offsets>
  </model>

  <animation>
    <type>select</type>
    <object-name>ProceduralNavLeft</object-name>
    <object-name>ProceduralNavRight</object-name>
    <condition>
      <property alias="../../../params/nav-light-volts"/>
    </condition>
  </animation>


  <animation>
    <type>material</type>
    <object-name>NavLightLeft</object-name>
    <condition>
      <property alias="../../../params/nav-light-volts"/>
    </condition>
    <emission>
      <red>1.0</red>
      <green>0.0</green>
      <blue>0.0</blue>
    </emission>
  </animation>

  <animation>
    <type>material</type>
    <object-name>NavLightRight</object-name>
    <condition>
      <property alias="../../../params/nav-light-volts"/>
    </condition>
    <emission>
      <red>0.0</red>
      <green>1.0</green>
      <blue>0.0</blue>
    </emission>
  </animation>

  <animation>
    <type>material</type>
    <object-name>TailLight</object-name>
    <condition>
      <property alias="../../../params/nav-light-volts"/>
    </condition>
    <emission>
      <red>1.0</red>
      <green>1.0</green>
      <blue>1.0</blue>
    </emission>
  </animation>

  <model>
    <name>ProceduralLanding</name>
    <path>Effects/Lights/landing.xml</path>
    <offsets>
      <x-m>1.80</x-m>
      <y-m>2.6361</y-m>
      <z-m>-0.10</z-m>
    </offsets>
  </model>

  <animation>
    <type>select</type>
    <object-name>ProceduralLanding</object-name>
    <condition>
      <property alias="../../../params/landing-light-volts"/>
    </condition>
  </animation>

  <model>
    <name>ProceduralTaxi</name>
    <path>Effects/Lights/taxi.xml</path>
    <offsets>
      <x-m>0.4200</x-m>
      <y-m>0.0</y-m>
      <z-m>-0.3972</z-m>
    </offsets>
  </model>

  <animation>
    <type>select</type>
    <object-name>ProceduralTaxi</object-name>
    <condition>
      <property alias="../../../params/taxi-light-volts"/>
    </condition>
  </animation>

</PropertyList>
