diff options
author | Wim Vriend <facetracknoir@gmail.com> | 2010-05-25 16:14:36 +0000 |
---|---|---|
committer | Wim Vriend <facetracknoir@gmail.com> | 2010-05-25 16:14:36 +0000 |
commit | a8f2a29dcc5fac905ef9a1d2305903cbb74b6b7c (patch) | |
tree | 0745bcf5563051ed74137fd7250ee0c41f79f47d /FaceTrackNoIR/ClientFiles/FlightGear |
First release Version 1.0.0 of FaceTrackNoIR
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@1 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR/ClientFiles/FlightGear')
4 files changed, 183 insertions, 0 deletions
diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml new file mode 100644 index 00000000..0d6e8005 --- /dev/null +++ b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml @@ -0,0 +1,99 @@ +<?xml version="1.0"?> + +<PropertyList> + <input> + <keyboard> + <key n="61"> + <name>= (equal sign)</name> + <desc>Reset Head Tracker</desc> + <binding> + <command>nasal</command> + <script>headtracker.reset()</script> + </binding> + </key> + </keyboard> + </input> + + <nasal> + <headtracker> + <script> + var Value = { + new: func(prop) { + var m = { parents: [Value] }; + m.prop = props.globals.getNode(prop, 1); + m.lowpass = aircraft.lowpass.new(0.7); + m.value = 0; + return m; + }, + apply: func(value) { + value = me.lowpass.filter(value); + me.prop.setDoubleValue(me.prop.getValue() - me.value + value); + me.value = value; + }, + }; + + + var x = Value.new("/sim/current-view/x-offset-m"); + var y = Value.new("/sim/current-view/y-offset-m"); + var z = Value.new("/sim/current-view/z-offset-m"); + var h = Value.new("/sim/current-view/heading-offset-deg"); + var p = Value.new("/sim/current-view/pitch-offset-deg"); + var r = Value.new("/sim/current-view/roll-offset-deg"); + + + var resetting = 0; + var status = nil; + + var reset = func { + if (status != 1) { + setprop("/sim/headtracker/control", 1); + resetting = 1; + view.resetViewPos(); + view.resetViewDir(); + x.value = y.value = z.value = h.value = p.value = r.value = 0; + } + } + + setlistener("/sim/headtracker/status", func(n) { + var s = n.getValue(); + if (!status and s) { + setprop("/sim/headtracker/control", 0); + resetting = 0; + } + status = s; + }, 1, 0); + + + var loop = func { + if (!view.index and !resetting) { + x.apply(getprop("/sim/headtracker/x-m")); + y.apply(getprop("/sim/headtracker/y-m")); + z.apply(getprop("/sim/headtracker/z-m")); + + h.apply(getprop("/sim/headtracker/heading-deg")); + p.apply(getprop("/sim/headtracker/pitch-deg")); + r.apply(-1 * getprop("/sim/headtracker/roll-deg")); + } + settimer(loop, 0); + } + + loop(); + + gui.popupTip("press '=' (equal sign) to reset head tracker", 20); + </script> + </headtracker> + </nasal> + + <sim> + <headtracker> + <x-m type="double">0</x-m> + <y-m type="double">0</y-m> + <z-m type="double">0</z-m> + <heading-deg type="double">0</heading-deg> + <pitch-deg type="double">0</pitch-deg> + <roll-deg type="double">0</roll-deg> + <status type="int">0</status> + <control type="int">0</control> + </headtracker> + </sim> +</PropertyList> diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml new file mode 100644 index 00000000..cd1d0dad --- /dev/null +++ b/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> + +<PropertyList> + <generic> + <input> + <binary_mode>true</binary_mode> + <binary_footer>none</binary_footer> + <byte_order>host</byte_order> + <record_length>52</record_length> + + <chunk> + <name>x</name> + <type>double</type> + <node>/sim/headtracker/x-m</node> + </chunk> + + <chunk> + <name>y</name> + <type>double</type> + <node>/sim/headtracker/y-m</node> + </chunk> + + <chunk> + <name>z</name> + <type>double</type> + <node>/sim/headtracker/z-m</node> + </chunk> + + <chunk> + <name>heading</name> + <type>double</type> + <node>/sim/headtracker/heading-deg</node> + </chunk> + + <chunk> + <name>pitch</name> + <type>double</type> + <node>/sim/headtracker/pitch-deg</node> + </chunk> + + <chunk> + <name>roll</name> + <type>double</type> + <node>/sim/headtracker/roll-deg</node> + </chunk> + + <chunk> + <name>status</name> + <type>int</type> + <node>/sim/headtracker/status</node> + </chunk> + </input> + + <output> + <binary_mode>true</binary_mode> + <binary_footer>none</binary_footer> + <byte_order>host</byte_order> + <record_length>4</record_length> + + <chunk> + <name>control</name> + <type>int</type> + <node>/sim/headtracker/control</node> + </chunk> + </output> + </generic> +</PropertyList> diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt b/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt new file mode 100644 index 00000000..db3bdd8e --- /dev/null +++ b/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt @@ -0,0 +1,16 @@ +FaceTrackNoIR for FlightGear.
+
+FaceTrackNoIR was made compatible with FlightGear with the help of Melchior Franz, who initially made a Linux headtracker. FaceTrackNoIR sends UDP-packets to FlightGear which contain 6DOF-data. The script and protocol provided by Melchior take care of receiving the data and moving 'the head' in-game.
+
+To make the FlightGear script work, copy the files in the subfolders to the corresponding folders in the FlightGear installation folder. Start FlightGear with the batch-file 'start_fg.bat'.
+
+
+Please let us know if you like the program, if you have ideas for improvements or any questions you might have.
+
+
+
+The FaceTrackNoIR team:
+
+Wim Vriend
+Ron Hendriks
+
diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat b/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat new file mode 100644 index 00000000..cd9829b5 --- /dev/null +++ b/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat @@ -0,0 +1 @@ +fgfs --generic=socket,in,25,localhost,5550,udp,headtracker --generic=socket,out,10,localhost,5551,udp,headtracker --prop:browser=/sim/headtracker "c:\Program Files\FlightGear\data\Nasal\headtracker.xml"
\ No newline at end of file |