oprf_assets/missile-frigate/Models/missile_frigate.xml

216 lines
6.6 KiB
XML
Raw Normal View History

2016-12-22 16:31:49 +08:00
<?xml version="1.0"?>
<PropertyList>
<description>USS SanAntonio</description>
<author>Naval Postgraduate School SAVAGE project, Vivian Meazza, Heiko Schulz</author>
<status>early-production</status>
<path>LPD17.ac</path>
<nasal>
2017-01-10 15:04:01 +08:00
<load><![CDATA[
2016-12-22 16:31:49 +08:00
var wind_node = props.globals.getNode("/environment/wind-speed-kt");
var time_node = props.globals.getNode("/sim/time/elapsed-sec");
var roll_node = props.globals.getNode("/ai/models/LPD17-boats/roll");
var pitch_node = props.globals.getNode("/ai/models/LPD17-boats/pitch");
var loopid = 1;
var loop = func(id) {
if (id != loopid) return;
var rollcyclesec = 40.55;
var pitchcyclesec = 40.08;
var rolltimer = time_node.getValue()/rollcyclesec - int(time_node.getValue()/rollcyclesec);
var rollwave = math.sin(2*math.pi*rolltimer);
roll_node.setValue(rollwave*(wind_node.getValue()+1));
var pitchtimer = (time_node.getValue()+1)/pitchcyclesec - int((time_node.getValue()+1)/pitchcyclesec);
var pitchwave = math.sin(2*math.pi*pitchtimer);
pitch_node.setValue(pitchwave*(wind_node.getValue()+1));
settimer(func { loop(id); }, 0);
}
settimer(func { loop(loopid); }, 0);
2017-01-10 15:04:01 +08:00
var self = cmdarg();
var skip = 0;
var lat = self.getNode("rotors/main/blade[0]/flap-deg");
var lon = self.getNode("rotors/main/blade[1]/flap-deg");
var alt = self.getNode("rotors/main/blade[2]/flap-deg");
if (alt == nil or alt.getValue() == nil) {
skip = 1;
}
var objs = {};
var loop = func () {
if(alt.getValue() != 0) {
var objModel = objs["first"];
if (objModel == nil) {
# create model
#print("creating missile");
var n = props.globals.getNode("models", 1);
var i = 0;
for (i = 0; 1==1; i += 1) {
if (n.getChild("model", i, 0) == nil) {
break;
}
}
objModel = n.getChild("model", i, 1);
objModel.getNode("elevation",1).setDoubleValue(0);
objModel.getNode("latitude",1).setDoubleValue(0);
objModel.getNode("longitude",1).setDoubleValue(0);
objModel.getNode("elevation-ft-prop",1).setValue(objModel.getPath()~"/elevation");
objModel.getNode("latitude-deg-prop",1).setValue(objModel.getPath()~"/latitude");
objModel.getNode("longitude-deg-prop",1).setValue(objModel.getPath()~"/longitude");
objModel.getNode("heading-deg",1).setDoubleValue(0);
objModel.getNode("pitch-deg",1).setDoubleValue(0);
objModel.getNode("roll-deg",1).setDoubleValue(0);
objModel.getNode("path",1).setValue("Aircraft/JA37/Models/Armament/Weapons/MP_missile/mp_missile.xml");
var loadNode = objModel.getNode("load", 1);
loadNode.setBoolValue(1);
objs["first"] = objModel;
loadNode.remove();
}
}
var exist = 0;
if(alt.getValue() != 0) {
exist = 1;
var objModel = objs["first"];
if (objModel == nil) {
print("error: did not find mp missile.");
return;
}# else {
# print("found a missile!");
#}
objModel.getNode("latitude").setDoubleValue(lat.getValue());
objModel.getNode("longitude").setDoubleValue(lon.getValue());
objModel.getNode("elevation").setDoubleValue(alt.getValue()*M2FT);
}
if (exist == 0) {
# remove model
var objModel = objs["first"];
if (objModel != nil) {
objModel.remove();
delete(objs, "first");
}
}
if (self.getNode("valid") == 0 or self.getNode("valid") == nil) {
return;
}
settimer(loop, 0.05);
}
if (skip == 0) {
loop();
}
]]>
2016-12-22 16:31:49 +08:00
</load>
<unload>
loopid += 1;
</unload>
</nasal>
<animation>
<type>rotate</type>
<object-name>ShapeIndexedFaceS.005</object-name>
<object-name>ShapeIndexedFaceS.004</object-name>
<object-name>ShapeIndexedFaceS.002</object-name>
<object-name>ShapeIndexedFaceS</object-name>
<object-name>ShapeIndexedFaceSet</object-name>
<object-name>ShapeIndexedFaceS.001</object-name>
<object-name>ShapeIndexedFaceS.006</object-name>
<object-name>ShapeIndexedFaceS.007</object-name>
<property>/ai/models/LPD17-boats/roll</property>
<factor>0.02</factor>
<axis>
<x>0</x>
<y>1</y>
<z>0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>ShapeIndexedFaceS.005</object-name>
<object-name>ShapeIndexedFaceS.004</object-name>
<object-name>ShapeIndexedFaceS.002</object-name>
<object-name>ShapeIndexedFaceS</object-name>
<object-name>ShapeIndexedFaceSet</object-name>
<object-name>ShapeIndexedFaceS.001</object-name>
<object-name>ShapeIndexedFaceS.006</object-name>
<object-name>ShapeIndexedFaceS.007</object-name>
<property>/ai/models/LPD17-boats/pitch</property>
<factor>0.0025</factor>
<axis>
<x>1</x>
<y>0</y>
<z>0</z>
</axis>
</animation>
<animation>
<type>textranslate</type>
<object-name>rect</object-name>
<property>/sim/time/elapsed-sec</property>
<factor>-0.010</factor>
<axis>
<x>1</x>
<y>0</y>
<z>0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>ShapeIndexedFaceS.007</object-name>
<property>surface-positions/elevators-pos-norm</property>
<factor>-90.0</factor>
<center>
<x-m>94.936</x-m>
<y-m>0.00</y-m>
<z-m>3.968</z-m>
</center>
<axis>
<x>0</x>
<y>1</y>
<z>0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<object-name>ShapeIndexedFaceS.006</object-name>
<property>surface-positions/elevators-pos-norm</property>
<factor>90.0</factor>
<center>
<x-m>93.243</x-m>
<y-m>0.00</y-m>
<z-m>-6.464</z-m>
</center>
<axis>
<x>0</x>
<y>1</y>
<z>0</z>
</axis>
</animation>
<model>
<path>Aircraft/missile-frigate/Models/smoke.xml</path>
<offsets>
<x-m>1.2</x-m>
<y-m>0.00</y-m>
<z-m>-0.68</z-m>
<pitch-deg>0</pitch-deg>
</offsets>
</model>
</PropertyList>