Walk view: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Added a 3rd option.)
m (Robot: Cosmetic changes)
Line 1: Line 1:
{{stub}}
{{stub}}
==Easy walk==
== Easy walk ==
This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.
This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.
===walk.nas===
=== walk.nas ===
  # view nodes and offsets --------------------------------------------
  # view nodes and offsets --------------------------------------------
  var zNoseNode = props.globals.getNode("sim/view/config/y-offset-m", 1);
  var zNoseNode = props.globals.getNode("sim/view/config/y-offset-m", 1);
Line 19: Line 19:
  }
  }
  }
  }
===-set.xml===
=== -set.xml ===
  <input>
  <input>
   <keyboard>
   <keyboard>
Line 43: Line 43:
  </input>
  </input>


==Advanced walk with jump and parachute==
== Advanced walk with jump and parachute ==
This advanced mode is way more complicated than the easy walk (see above). With this mode you can jump out of the plane and land with a parachute.
This advanced mode is way more complicated than the easy walk (see above). With this mode you can jump out of the plane and land with a parachute.
===walk.nas===
=== walk.nas ===
''See the [[Pilatus PC-6 Porter‎]]'s <tt>PC-6/Nasal/walk.nas</tt>''
''See the [[Pilatus PC-6 Porter‎]]'s <tt>PC-6/Nasal/walk.nas</tt>''


===-set.xml===
=== -set.xml ===
  <walker>
  <walker>
   <outside type="bool">false</outside>
   <outside type="bool">false</outside>
Line 244: Line 244:
  </keyboard>
  </keyboard>


==Another option for internal walk views==
== Another option for internal walk views ==


Another option is to use the WalkView module available in Aircraft/Generic/WalkView/ (in FlightGear 2.2.0 or later).
Another option is to use the WalkView module available in Aircraft/Generic/WalkView/ (in FlightGear 2.2.0 or later).
Line 325: Line 325:
   ...
   ...
  </input>
  </input>
[[es:Walk View]]


[[Category:Aircraft enhancement]]
[[Category:Aircraft enhancement]]
[[Category:Nasal]]
[[Category:Nasal]]
[[es:Walk View]]

Revision as of 19:31, 8 March 2011

This article is a stub. You can help the wiki by expanding it.

Easy walk

This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.

walk.nas

# view nodes and offsets --------------------------------------------
var zNoseNode = props.globals.getNode("sim/view/config/y-offset-m", 1);
var xViewNode = props.globals.getNode("sim/current-view/z-offset-m", 1);
var yViewNode = props.globals.getNode("sim/current-view/x-offset-m", 1);
var hViewNode = props.globals.getNode("sim/current-view/heading-offset-deg", 1);

var walk_about = func(wa_distance) {
	var i = getprop("sim/current-view/view-number");
	if (i == view.indexof("Pilot View") or i == view.indexof("Model View") or i == view.indexof("View 8")) {
		var wa_heading_rad = hViewNode.getValue() * 0.01745329252;
		var new_x_position = xViewNode.getValue() - (math.cos(wa_heading_rad) * wa_distance);
		var new_y_position = yViewNode.getValue() - (math.sin(wa_heading_rad) * wa_distance);
		xViewNode.setValue(new_x_position);
		yViewNode.setValue(new_y_position);
	}
}

-set.xml

<input>
 <keyboard>
  <key n="119">
   <name>w</name>
    <desc>Walk forward toward view</desc>
    <repeatable>true</repeatable>
    <binding>
     <command>nasal</command>
     <script>walk.walk_about(0.1)</script>
    </binding>
  </key>
  <key n="87">
   <name>W</name>
   <desc>Walk backward from view</desc>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>walk.walk_about(-0.1)</script>
   </binding>
  </key>
 </keyboard>
</input>

Advanced walk with jump and parachute

This advanced mode is way more complicated than the easy walk (see above). With this mode you can jump out of the plane and land with a parachute.

walk.nas

See the Pilatus PC-6 Porter‎'s PC-6/Nasal/walk.nas

-set.xml

<walker>
 <outside type="bool">false</outside>
 <walking type="bool">false</walking>
 <speed type="double">0.000006</speed>
 <latitude-deg type="double">0.0</latitude-deg>
 <longitude-deg type="double">0.0</longitude-deg>
 <altitude-at-exit-ft type="double">0.0</altitude-at-exit-ft>
 <altitude-ft type="double">0.0</altitude-ft>
 <heading-deg type="double">0.0</heading-deg>
 <pitch-deg type="double">0.0</pitch-deg>
 <roll-deg type="double">0.0</roll-deg>
 <internal>
  <x-offset-m type="double">4.3</x-offset-m>
  <y-offset-m type="double">0.0</y-offset-m>
  <z-offset-m type="double">0.0</z-offset-m>
  <heading-deg type="double">0.0</heading-deg>
 </internal>
 <keep-inside-offset-x type="double">0.0</keep-inside-offset-x>
 <keep-inside-offset-y type="double">0.0</keep-inside-offset-y>
 <keep-inside-offset-z type="double">0.0</keep-inside-offset-z>
 <keep-pitch-offset-deg type="double">0.0</keep-pitch-offset-deg>
 <key-triggers>
  <forward type="double">0</forward>
  <outside-toggle type="bool">0</outside-toggle>
  <slide type="double">0</slide>
 </key-triggers>
 <parachute-opened-altitude-ft type="double">0</parachute-opened-altitude-ft>
 <parachute-opened-sec type="double">0</parachute-opened-sec>
 <starting-trajectory-lat type="double">0</starting-trajectory-lat>
 <starting-trajectory-lon type="double">0</starting-trajectory-lon>
 <time-of-exit-sec type="double">0</time-of-exit-sec>
</walker>
<keyboard>
 </input>
  <key n="111">
  	<name>o</name>
  	<desc>Toggle walker outside/inside</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-toggle</command>
  	   <property>sim/walker/key-triggers/outside-toggle</property>
  	</binding>
  </key>
  <key n="119"> 
  	<name>w</name>
  	<desc>Walk forward</desc>
  	<repeatable>false</repeatable>
  	<binding n="0">
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>1</value>
  	</binding>
  	<binding n="1">
  	   <command>property-assign</command>
  	   <property>sim/walker/speed</property>
  	   <value>0.000006</value>
  	</binding>
  	<mod-up>
  	   <binding n="0">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	   <binding n="1">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/speed</property>
  	   	<value>0.000006</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="87"> 
  	<name>W</name>
  	<desc>Run forward</desc>
  	<repeatable>false</repeatable>
  	<binding n="0">
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>1</value>
  	</binding>
  	<binding n="1">
  	   <command>property-assign</command>
  	   <property>sim/walker/speed</property>
  	   <value>0.000018</value>
  	</binding>
  	<mod-up>
  	   <binding n="0">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	   <binding n="1">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/speed</property>
  	   	<value>0.000006</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="115"> 
  	<name>s</name>
  	<desc>Walk backward</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="97"> 
  	<name>a</name>
  	<desc>Slide left</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="65"> 
  	<name>A</name>
  	<desc>Slide left2, override default assignment</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="100"> 
  	<name>d</name>
  	<desc>Slide right</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="68"> 
  	<name>D</name>
  	<desc>Slide right2</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="114"> 
  	<name>r</name>
  	<desc>open parachute</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>nasal</command>
  	   <script>walk.open_chute()</script>
  	</binding>
  </key>
 </input>
</keyboard>

Another option for internal walk views

Another option is to use the WalkView module available in Aircraft/Generic/WalkView/ (in FlightGear 2.2.0 or later).

Load the WalkView module and the configuration from the -set file. The example below is from Nordstern and makes the view named "Walk View" into a walk view. See also Zeppelin NT and Short Empire for more examples.

<sim>
 ...
 <view n="103">
  <name>Walk View</name>
  <internal>true</internal>
  <config>
   <from-model type="bool">true</from-model>
   <from-model-idx type="int">0</from-model-idx>
   <x-offset-m type="double">  0.00 </x-offset-m>
   <y-offset-m type="double"> -7.50 </y-offset-m>
   <z-offset-m type="double"> 51.00 </z-offset-m>
   <heading-offset-deg type="double"> 0.0 </heading-offset-deg>
   <pitch-offset-deg type="double"> 0.0 </pitch-offset-deg>
   <default-field-of-view-deg type="double"> 65 </default-field-of-view-deg>
  </config>
 </view>
 ...
</sim>
<nasal>
 <walkview>
  <file>Aircraft/Generic/WalkView/walkview.nas</file>
  <script>
   # The keel walk-way is a long narrow path running in the fore-aft direction.
   # Additionally there is a path to the side engine cars.
   var keelConstraint =
     walkview.makeUnionConstraint(
       [
        walkview.makePolylinePath(
            [
             [ 10.0,  0.0,  -6.3],
             [ 15.0,  0.0,  -7.2],
             [ 20.0,  0.0,  -7.8],
             [ 25.0,  0.0,  -8.2],
             [ 30.0,  0.0,  -8.6],
             [ 35.0,  0.0,  -8.8],
             [ 40.0,  0.0,  -9.0],
             [ 50.0,  0.0,  -9.1],
             [ 65.0,  0.0,  -9.1],
             [ 70.0,  0.0,  -8.8],
             [ 80.0,  0.0,  -8.5],
             [ 90.0,  0.0,  -7.9],
             [ 95.0,  0.0,  -7.4],
             [100.0,  0.0,  -6.9],
             [105.0,  0.0,  -6.2],
             [110.0,  0.0,  -5.4],
            ],
            0.20),
        walkview.makePolylinePath(
            [
             [ 59.75, -4.90, -7.79],
             [ 59.75, -1.70, -9.05],
             [ 59.75,  1.70, -9.05],
             [ 59.75,  4.90, -7.79],
            ],
            0.20)
       ]);
   # Create the walker for the named view and the given movement restrictions.
   var rigger_walker = walkview.Walker.new("Walk View",
                                           keelConstraint);
  </script>
 </walkview>
 ...
</nasal>
<input>
 <keyboard include="../Generic/WalkView/walk-view-keys.xml">
  ...
 </keyboard>
 ...
</input>