MQ-9/Models/MQ-9.xml
2019-06-27 22:44:16 +02:00

778 lines
20 KiB
XML
Executable File

<?xml version="1.0"?>
<PropertyList include="MQ-9-bombableinclude.xml">
<!-- Model -->
<path>MQ-9.ac</path>
<offsets>
<pitch-deg>-3</pitch-deg>
<heading-deg>0</heading-deg>
<roll-deg>0</roll-deg>
<x-m>0</x-m>
<y-m>0</y-m>
<z-m>0</z-m>
</offsets>
<!-- Invisible -->
<animation>
<type>select</type>
<object-name>Sensor</object-name>
<object-name>SensorMount1</object-name>
<condition>
<not>
<property>sim/current-view/internal</property>
</not>
</condition>
</animation>
<!-- Stores -->
<model>
<name>Stores</name>
<path>Aircraft/MQ-9/Models/Stores/Stores.xml</path>
</model>
<!-- Multiplayer sounds -->
<sound>
<path>Aircraft/MQ-9/Sounds/MP-Sounds.xml</path>
</sound>
<!-- Rembrandt transparent -->
<effect>
<inherits-from>Effects/model-transparent</inherits-from>
<condition>
<greater-than>
<property>sim/multiplay/generic/float[6]</property>
<value>9</value>
</greater-than>
<property>/sim/rendering/rembrandt/enabled</property>
</condition>
<object-name>Disk</object-name>
<object-name>BladesBlur</object-name>
</effect>
<!-- Effects -->
<model>
<path>Aircraft/MQ-9/Models/Effects/Effects.xml</path>
</model>
<!-- Lights -->
<model>
<path>Aircraft/MQ-9/Models/Lights/LightPack.xml</path>
</model>
<nasal>
<load><![CDATA[
var root = cmdarg();
var rootindex = root.getIndex();
var mpPath = "/ai/models/multiplayer["~ rootindex ~"]/";
var lightsPath = mpPath~"lightpack/"; #path to the property node, where all internal values are placed
props.globals.initNode(mpPath~"sim/is-MP-Aircraft", 1, "BOOL");
srand();
#wherever you want to add randomization of time, use something like: + rand()*0.05-0.025 (included by default where appropriate)
#list of switches for lights - if you don't intend to use some light, assign it nil value instead, like whateverSwitch = nil; and you don't need to care about anything else
#IMPORTANT: don't put / on the start of the string, it's already included in the mpPath property
var navSwitch = mpPath~"controls/lighting/nav-lights-switch";
var beaconSwitch = mpPath~"controls/lighting/beacon-switch";
var strobeSwitch = mpPath~"controls/lighting/strobe-switch";
var landingSwitch = mpPath~"controls/lighting/landing-lights-switch";
var taxiSwitch = mpPath~"controls/lighting/taxi-light-switch";
var probeSwitch = mpPath~"controls/lighting/probe-light-switch";
var whiteSwitch = mpPath~"controls/lighting/white-light-switch";
#switch this from 1 to 0 if you want to use advanced cyclical fading animation of the the nav lights instead of being stable on when the switch is on
navStillOn = 1;
#I need to set listener on some MP transferred properties; this doesn't seem to work well sometimes, so I mirror them to the original location on any change
#This also simplifies work as I can use almost the same code for MP as is the local Nasal. Furthermore, I can use meaningful property names in the model XML files instead of referencing the MP properties.
var mpVar = {
new: func(propIn, propOut) {
var m = { parents: [mpVar] };
m.propIn = propIn;
m.propOut = propOut;
if(propIn==nil) return m;
m.value = getprop(propIn);
setprop(propOut, m.value);
return m;
},
check: func {
if(me.propIn==nil) return;
var newValue = getprop(me.propIn);
if(newValue != me.value) {
setprop(me.propOut, newValue);
me.value = newValue;
#print("value of "~me.propOut~" changed: "~newValue);
}
},
};
#init any property copy object needed in this array (anything you need to transfer over MP, but you are using the original paths in your xmls)
#also used for properties you are using a listener on, or properties which you maybe want to manipulate during the <unload>
#if you're just using the pack, change the values according to the MP bindings in the -set.xml file
#you don't need to delete the entries if the path is nil - it gets skipped automatically and the MP path is just ignored
var mirrorValues = [
mpVar.new(mpPath~"sim/multiplay/generic/int[7]", mpPath~"sim/crashed"),
mpVar.new(mpPath~"sim/multiplay/generic/int[0]", navSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[1]", beaconSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[1]", strobeSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[2]", landingSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[3]", taxiSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[3]", probeSwitch),
mpVar.new(mpPath~"sim/multiplay/generic/int[0]", whiteSwitch),
];
#loop at the default MP transfer frequency (10Hz)
var mirrorTimer = maketimer(0.1, func {
foreach(var mir; mirrorValues) {
mir.check();
}
});
mirrorTimer.start();
#### NAV LIGHTS ####
#class for a periodic fade in/out animation - for flashing, use rather standard aircraft.light.new(), as in Beacon and Strobe section
var lightCycle = {
#constructor
new: func(propSwitch, propOut) {
m = { parents: [lightCycle] };
props.globals.initNode(propOut, 0, "DOUBLE");
props.globals.initNode(propSwitch, 1, "BOOL");
m.fadeIn = 0.4 + rand()*0.05-0.025; #fade in time
m.fadeOut = 0.4 + rand()*0.05-0.025; #fade out time
m.stayOn = 1.5 + rand()*0.05-0.025; #stable on period
m.stayOff = 1 + rand()*0.05-0.025; #stable off period
m.turnOff = 0.12; #fade out time when turned off
m.phase = 0; #phase to be run on next timer call: 0 -> fade in, 1 -> stay on, 2 -> fade out, 3 -> stay off
m.cycleTimer = maketimer(0.1, func {
if(getprop(propSwitch)) {
if(m.phase == 0) {
interpolate(propOut, 1, m.fadeIn);
m.phase = 1;
m.cycleTimer.restart(m.fadeIn);
}
else if(m.phase == 1){
m.phase = 2;
m.cycleTimer.restart(m.stayOn);
}
else if(m.phase == 2){
interpolate(propOut, 0, m.fadeOut);
m.phase = 3;
m.cycleTimer.restart(m.fadeOut);
}
else if(m.phase == 3){
m.phase = 0;
m.cycleTimer.restart(m.stayOff);
}
}
else {
interpolate(propOut, 0, m.turnOff); #kills any currently ongoing interpolation
m.phase = 0;
}
});
m.cycleTimer.singleShot = 1;
if(propSwitch==nil) {
m.listen = nil;
return m;
}
m.listen = setlistener(propSwitch, func{m.cycleTimer.restart(0);}); #handle switch changes
m.cycleTimer.restart(0); #start the looping
return m;
},
#destructor
del: func {
if(me.listen!=nil) removelistener(me.listen);
me.cycleTimer.stop();
},
};
#By default, the switch property is initialized to 1 (only if no value is already assigned). Don't change the class implementation! To override this, set the property manually. You don't need to care if any other code already does it for you.
var navLights = nil;
if(!navStillOn) {
navLights = lightCycle.new(navSwitch, lightsPath~"nav-lights-intensity");
### Uncomment and tune those to customize times ###
#navLights.fadeIn = 0.4; #fade in time
#navLights.fadeOut = 0.4; #fade out time
#navLights.stayOn = 3 + rand()*0.05-0.025; #stable on period
#navLights.stayOff = 0.6; #stable off period
#navLights.turnOff = 0.12; #fade out time when turned off
}
### BEACON ###
var beacon = nil;
if(beaconSwitch!=nil) {
props.globals.initNode(beaconSwitch, 1, "BOOL");
beacon = aircraft.light.new(lightsPath~"beacon-state",
[0.0, 1.0 + rand()*0.05-0.025], beaconSwitch);
}
### STROBE ###
var strobe = nil;
if(strobeSwitch!=nil) {
props.globals.initNode(strobeSwitch, 1, "BOOL");
strobe = aircraft.light.new(lightsPath~"strobe-state",
[0.0, 0.87 + rand()*0.05-0.025], strobeSwitch);
}
### LIGHT FADING ###
#class for controlling fade in/out behavior - propIn is a control property (handled as a boolean) and propOut is interpolated
#all light brightness animations in xmls depend on propOut (Rembrandt brightness, material emission, flares transparency, ...)
var lightFadeInOut = {
#constructor
new: func(propSwitch, propOut) {
m = { parents: [lightFadeInOut] };
m.fadeIn = 0.3; #some sane defaults
m.fadeOut = 0.4;
if(propSwitch==nil) {
m.listen = nil;
return m;
}
props.globals.initNode(propSwitch, 1, "BOOL");
m.isOn = getprop(propSwitch);
props.globals.initNode(propOut, m.isOn, "DOUBLE");
m.listen = setlistener(propSwitch,
func {
if(m.isOn and !getprop(propSwitch)) {
interpolate(propOut, 0, m.fadeOut);
m.isOn = 0;
}
if(!m.isOn and getprop(propSwitch)) {
interpolate(propOut, 1, m.fadeIn);
m.isOn = 1;
}
}
);
return m;
},
#destructor
del: func {
if(me.listen!=nil) removelistener(me.listen);
},
};
fadeLanding = lightFadeInOut.new(landingSwitch, lightsPath~"landing-lights-intensity");
fadeTaxi = lightFadeInOut.new(taxiSwitch, lightsPath~"taxi-light-intensity");
fadeProbe = lightFadeInOut.new(probeSwitch, lightsPath~"probe-light-intensity");
fadeWhite = lightFadeInOut.new(whiteSwitch, lightsPath~"white-light-intensity");
if(navStillOn) {
navLights = lightFadeInOut.new(navSwitch, lightsPath~"nav-lights-intensity");
navLights.fadeIn = 0.1;
navLights.fadeOut = 0.12;
}
#manipulate times if defaults don't fit your needs:
#fadeLanding.fadeIn = 0.5;
#fadeLanding.fadeOut = 0.8;
### the rest of your model load embedded Nasal code ###
]]>
</load>
<unload>
stopFire();
disintegrated = 0;
removelistener(listenCrash);
#prevent multiple timers and listeners from running and fighting on next connect
#cleanly destroy MP property mirroring
mirrorTimer.stop();
mirrorTimer = nil;
mirrorValues = nil;
#cleanly destroy nav lights
if(navStillOn) {
navLights.del();
}
else {
if(navSwitch!=nil) setprop(navSwitch, 0);
navLights.del();
if(navSwitch!=nil) navLights.cycleTimer = nil;
navLights = nil;
}
#cleanly destroy beacon
if(beaconSwitch!=nil) setprop(beaconSwitch, 0);
beacon.del();
beacon = nil;
#cleanly destroy strobe
if(strobeSwitch!=nil) setprop(strobeSwitch, 0);
strobe.del();
strobe = nil;
#cleanly destroy light fade in/out animation objects
fadeLanding.del();
fadeTaxi.del();
fadeProbe.del();
fadeWhite.del();
### the rest of your model unload embedded Nasal code ###
</unload>
</nasal>
<!-- Normal Map -->
<effect>
<inherits-from>Aircraft/MQ-9/Models/Effects/Normal</inherits-from>
<object-name>MQ-9</object-name>
</effect>
<!-- Specular Map -->
<effect>
<inherits-from>Aircraft/MQ-9/Models/Effects/Specular</inherits-from>
<object-name>MQ-9</object-name>
</effect>
<!-- Liveries -->
<nasal>
<load>
var livery_update = aircraft.livery_update.new("Aircraft/MQ-9/Models/Liveries");
</load>
<unload>
livery_update.stop();
</unload>
</nasal>
<animation>
<type>material</type>
<object-name>MQ-9</object-name>
<property-base>sim/model/livery</property-base>
<texture-prop>texture</texture-prop>
<texture>Aircraft/MQ-9/Models/Liveries/MQ-9.jpg</texture>
</animation>
<animation>
<type>material</type>
<object-name>Disk</object-name>
<texture-prop>texture</texture-prop>
<texture>Aircraft/MQ-9/Models/Liveries/Disk.png</texture>
</animation>
<animation>
<type>material</type>
<object-name>BladesBlur</object-name>
<texture-prop>texture</texture-prop>
<texture>Aircraft/MQ-9/Models/Liveries/Disk.png</texture>
</animation>
<!-- Animations -->
<!-- Ailerons -->
<animation>
<type>rotate</type>
<object-name>AileronR</object-name>
<property>surface-positions/left-aileron-pos-norm</property>
<factor>20</factor>
<axis>
<x1-m> 0.6977</x1-m>
<y1-m> 5.5070</y1-m>
<z1-m> 0.4481</z1-m>
<x2-m> 0.6255</x2-m>
<y2-m> 8.8878</y2-m>
<z2-m> 0.4392</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>AileronL</object-name>
<property>surface-positions/left-aileron-pos-norm</property>
<factor>20</factor>
<axis>
<x1-m> 0.6977</x1-m>
<y1-m> -5.5070</y1-m>
<z1-m> 0.4481</z1-m>
<x2-m> 0.6255</x2-m>
<y2-m> -8.8878</y2-m>
<z2-m> 0.4392</z2-m>
</axis>
</animation>
<!-- Flaps -->
<animation>
<type>rotate</type>
<object-name>FlapR2</object-name>
<property>surface-positions/flap-pos-norm</property>
<factor>40</factor>
<axis>
<x1-m> 0.7273</x1-m>
<y1-m> 2.5708</y1-m>
<z1-m> 0.4576</z1-m>
<x2-m> 0.6968</x2-m>
<y2-m> 5.5070</y2-m>
<z2-m> 0.4495</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>FlapL2</object-name>
<property>surface-positions/flap-pos-norm</property>
<factor>-40</factor>
<axis>
<x1-m> 0.7273</x1-m>
<y1-m> -2.5708</y1-m>
<z1-m> 0.4576</z1-m>
<x2-m> 0.6968</x2-m>
<y2-m> -5.5070</y2-m>
<z2-m> 0.4495</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>FlapR1</object-name>
<property>surface-positions/flap-pos-norm</property>
<factor>40</factor>
<axis>
<x1-m> 0.7302</x1-m>
<y1-m> 0.7240</y1-m>
<z1-m> 0.4589</z1-m>
<x2-m> 0.7196</x2-m>
<y2-m> 2.5708</y2-m>
<z2-m> 0.4545</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>FlapL1</object-name>
<property>surface-positions/flap-pos-norm</property>
<factor>-40</factor>
<axis>
<x1-m> 0.7302</x1-m>
<y1-m> -0.7240</y1-m>
<z1-m> 0.4589</z1-m>
<x2-m> 0.7196</x2-m>
<y2-m> -2.5708</y2-m>
<z2-m> 0.4545</z2-m>
</axis>
</animation>
<!-- Elevators -->
<animation>
<type>rotate</type>
<object-name>ElevatorR</object-name>
<property>surface-positions/elevator-pos-norm</property>
<factor>-20</factor>
<axis>
<x1-m> 3.4018</x1-m>
<y1-m> 0.4181</y1-m>
<z1-m> 0.6136</z1-m>
<x2-m> 3.5428</x2-m>
<y2-m> 2.9323</y2-m>
<z2-m> 2.3741</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>ElevatorL</object-name>
<property>surface-positions/elevator-pos-norm</property>
<factor>20</factor>
<axis>
<x1-m> 3.4018</x1-m>
<y1-m>-0.4181</y1-m>
<z1-m> 0.6136</z1-m>
<x2-m> 3.5428</x2-m>
<y2-m>-2.9323</y2-m>
<z2-m> 2.3741</z2-m>
</axis>
</animation>
<!-- Rudder -->
<animation>
<type>rotate</type>
<object-name>Rudder</object-name>
<property>surface-positions/rudder-pos-norm</property>
<factor>-20</factor>
<axis>
<x1-m> 3.3652</x1-m>
<y1-m> 0.0000</y1-m>
<z1-m> 0.2360</z1-m>
<x2-m> 3.4900</x2-m>
<y2-m> 0.0000</y2-m>
<z2-m>-0.7541</z2-m>
</axis>
</animation>
<!-- Landing gear -->
<animation>
<type>rotate</type>
<object-name>WheelN</object-name>
<object-name>JawN</object-name>
<property>surface-positions/rudder-pos-norm</property>
<factor>-20</factor>
<center>
<x-m>-2.9145</x-m>
<y-m> 0.0000</y-m>
<z-m>-1.2683</z-m>
</center>
<axis>
<x>0.0</x>
<y>0.0</y>
<z>1.0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>WheelN</object-name>
<object-name>JawN</object-name>
<object-name>Strut1N</object-name>
<object-name>Strut2N</object-name>
<object-name>Scissor1N</object-name>
<object-name>Scissor2N</object-name>
<property>gear/gear[1]/position-norm</property>
<factor>130</factor>
<offset-deg>-130</offset-deg>
<center>
<x-m>-2.0705</x-m>
<y-m> 0.0000</y-m>
<z-m> 0.1760</z-m>
</center>
<axis>
<x>0.0</x>
<y>1.0</y>
<z>0.0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>WheelL</object-name>
<object-name>StrutL</object-name>
<property>gear/gear[1]/position-norm</property>
<factor>98</factor>
<offset-deg>-98</offset-deg>
<axis>
<x1-m> 0.0559</x1-m>
<y1-m>-0.3306</y1-m>
<z1-m> 0.3248</z1-m>
<x2-m> 0.0559</x2-m>
<y2-m>-0.2413</y2-m>
<z2-m> 0.2317</z2-m>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>WheelR</object-name>
<object-name>StrutR</object-name>
<property>gear/gear[2]/position-norm</property>
<factor>-98</factor>
<offset-deg>98</offset-deg>
<axis>
<x1-m> 0.0559</x1-m>
<y1-m> 0.3306</y1-m>
<z1-m> 0.3248</z1-m>
<x2-m> 0.0559</x2-m>
<y2-m> 0.2413</y2-m>
<z2-m> 0.2317</z2-m>
</axis>
</animation>
<!-- Gear Compression -->
<animation>
<type>translate</type>
<object-name>WheelN</object-name>
<object-name>JawN</object-name>
<object-name>Scissor1N</object-name>
<object-name>Scissor2N</object-name>
<object-name>Strut1N</object-name>
<property>gear/gear[0]/compression-norm[0]</property>
<factor>0.60</factor>
<axis>
<x1-m>-2.7232</x1-m>
<y1-m> 0.0000</y1-m>
<z1-m>-0.6690</z1-m>
<x2-m>-2.5221</x2-m>
<y2-m> 0.0000</y2-m>
<z2-m>-0.4077</z2-m>
</axis>
</animation>
<animation>
<type>translate</type>
<object-name>WheelR</object-name>
<object-name>StrutR</object-name>
<property>gear/gear[2]/compression-norm[0]</property>
<factor>0.1</factor>
<axis>
<x1-m>-0.0728</x1-m>
<y1-m> 1.7594</y1-m>
<z1-m>-1.0981</z1-m>
<x2-m>-0.0728</x2-m>
<y2-m> 1.7594</y2-m>
<z2-m>-0.8998</z2-m>
</axis>
</animation>
<animation>
<type>translate</type>
<object-name>WheelL</object-name>
<object-name>StrutL</object-name>
<property>gear/gear[1]/compression-norm[0]</property>
<factor>0.1</factor>
<axis>
<x1-m>-0.0728</x1-m>
<y1-m>-1.7594</y1-m>
<z1-m>-1.0981</z1-m>
<x2-m>-0.0728</x2-m>
<y2-m>-1.7594</y2-m>
<z2-m>-0.8998</z2-m>
</axis>
</animation>
<!-- Propeller -->
<animation>
<type>spin</type>
<object-name>Propeller</object-name>
<object-name>Blades</object-name>
<property>engines/engine[0]/n2</property>
<factor>3</factor>
<center>
<x-m>4.4823</x-m>
<y-m>0.0000</y-m>
<z-m>0.7577</z-m>
</center>
<axis>
<x>1.0</x>
<y>0.0</y>
<z>0.0</z>
</axis>
</animation>
<animation>
<type>select</type>
<object-name>Blades</object-name>
<condition>
<less-than>
<property>engines/engine[0]/n2</property>
<value>50.0001</value>
</less-than>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>BladesFlat</object-name>
<condition>
<greater-than>
<property>engines/engine[0]/n2</property>
<value>50.000</value>
</greater-than>
<less-than>
<property>engines/engine[0]/n2</property>
<value>70.0001</value>
</less-than>
</condition>
</animation>
<animation>
<type>spin</type>
<object-name>BladesFlat</object-name>
<property>engines/engine[0]/n2</property>
<center>
<x-m>4.4823</x-m>
<y-m>0.0000</y-m>
<z-m>0.7577</z-m>
</center>
<axis>
<x>1.0</x>
<y>0.0</y>
<z>0.0</z>
</axis>
</animation>
<animation>
<type>select</type>
<object-name>Disk</object-name>
<condition>
<greater-than>
<property>engines/engine[0]/n2</property>
<value>70.0000</value>
</greater-than>
</condition>
</animation>
<animation>
<type>spin</type>
<object-name>Disk</object-name>
<property>engines/engine[0]/n2</property>
<factor>.5</factor>
<center>
<x-m>4.4823</x-m>
<y-m>0.0000</y-m>
<z-m>0.7577</z-m>
</center>
<axis>
<x>1.0</x>
<y>0.0</y>
<z>0.0</z>
</axis>
</animation>
<!-- Sensor -->
<animation>
<type>rotate</type>
<object-name>Sensor</object-name>
<object-name>SensorMount1</object-name>
<property>sim/model/turret[0]/heading</property>
<axis>
<x> 0</x>
<y> 0</y>
<z>-1</z>
</axis>
<center>
<x-m>-4.1425</x-m>
<y-m> 0.0000</y-m>
<z-m>-0.0697</z-m>
</center>
</animation>
<animation>
<type>rotate</type>
<object-name>Sensor</object-name>
<property>sim/model/turret[0]/pitch</property>
<offset-deg>0</offset-deg>
<axis>
<x>0</x>
<y>1</y>
<z>0</z>
</axis>
<center>
<x-m>-4.1425</x-m>
<y-m> 0.0000</y-m>
<z-m>-0.0697</z-m>
</center>
</animation>
</PropertyList>