Howto:Set view points

From FlightGear wiki
Revision as of 12:46, 21 February 2015 by Tomaskom (talk | contribs) (<limits> code block moved within the <config> tags (before the limits didn't work), explanation reordred accordingly)
Jump to navigation Jump to search

This howto teaches you how to set (custom) view points for your aircraft(s). In sim, the user can switch between various view points, by pressing the v/V keys.

Default views

Various default views are defined in $FG ROOT/preferences.xml and are used when there is no custom view defined for a certain view-number.

Custom views

It is possible to configure any number of views with XML configuration files. Views may be configured to switch between pilot and co-pilot, tower view, or view of an observer on the ground.

All of the codes mentioned in this article, should be placed between the <sim> and </sim> tag of your aircraft's -set.xml file.

<view n="0">
  <internal type="bool">true</internal>
    <x-offset-m type="double">-0.55</x-offset-m>
    <y-offset-m type="double">3.8</y-offset-m>
    <z-offset-m type="double">-24.05</z-offset-m>
    <default-field-of-view-deg type="double">65.0</default-field-of-view-deg>
    <from-model type="bool">true</from-model>
    <from-model-idx type="int">0</from-model-idx>
    <ground-level-nearplane-m type="double">6f</ground-level-nearplane-m>
      <enabled type="bool">true</enabled>
        <heading-max-deg type="double">140</heading-max-deg>
        <x-offset-max-m type="double">0.15</x-offset-max-m>
        <x-offset-threshold-deg type="double">65</x-offset-threshold-deg>
        <heading-max-deg type="double">140</heading-max-deg>
        <x-offset-max-m type="double">0.15</x-offset-max-m>
        <x-offset-threshold-deg type="double">65</x-offset-threshold-deg>
    <enabled type="bool">false</enabled>
  • name this will be displayed when the user switches to the corresponding view.
  • type can be:
    • lookat your "eyes" fly around a point in space, while remaining focused at that point. Used for external views of the aircraft like helicopter view.
    • lookfrom most resemblance to the human head (you look around from a fixed point). Used for pilot view.
  • internal if set to "true" indicates the view is from inside the aircraft, otherwise from outside of the aircraft
  • config Open the aircraft in a 3D editor to find these coordinates, or open the property browser in sim and edit the /sim/current-view properties for live feedback.
    • ?-offset-m the offset from the origin of your aircraft, in meters.
    • pitch-offset-deg the pitch of the view.
    • default-field-of-view-deg the larger this number, the wider the view. Around 55-65 is the most common setting.
  • limits you can limit the view movements, in order to simulate the fact that a human is unable to turn its head 360 degrees.
    • enabled set to true to enable limits.
    • left/right
      • heading-max-deg
      • x-offset-max-m
      • x-offset-threshold-deg
  • dynamic
    • enabled when set to true, this enables dynamic view, which rotates the view based on control input (to simulate a pilot looking into the direction he steers to).

Additionally, you can place the following line after the last </view> tag. It is used to define the distance to the aircraft of the default views: chase, helicopter

<chase-distance-m type="double" archive="y">-90.0</chase-distance-m>

View numbers

Each view point must have an unique id/number. If no number is set, numbers are assigned from 0 to n in order of existance in the .xml file. Numbers can be overriden by using the following line (where 1 can be any number):

<view n="1"> 

Since there are various default view points (pilot, helicopter, tower etc.), it is advised to assign numbers starting at 100, when custom views are created. This will make sure that they won't interfere with any default views that may be added in future.

Note that the view numbers do have impact on the order of views when skipping through them in sim with the v/V keys.


Chase view with fixed roll/pitch degrees

The configuration of a chase view without a rotating frutstum (the view does not tilt with the aircraft's roll and pitch) is easy. Since the aircraft model's orientation is contained in its location definition, you must set the from-model property to false so you may define your own source for position and orientation. Then define eye position properties for the appropriate values. If you leave eye-roll-deg and eye-pitch-deg out then they will be fixed at 0 degrees. Note that technically this example does rotate, but only on the heading.

   <name>Chase View</name>
     <from-model type="bool">false</from-model>
     <from-model-idx type="int">0</from-model-idx>

     <at-model type="bool">true</at-model>
     <at-model-idx type="int">0</at-model-idx>

     <ground-level-nearplane-m type="double">0.5f</ground-level-nearplane-m>

     <x-offset-m type="double">0</x-offset-m>
     <y-offset-m type="double">0</y-offset-m>
     <z-offset-m type="double">-25</z-offset-m>

Tower view

   <name>Tower View</name>

     <at-model type="bool">true</at-model>
     <at-model-idx type="int">0</at-model-idx>

     <ground-level-nearplane-m type="double">10.0f</ground-level-nearplane-m>


Additionally to this, there is a patch available here, that let you move the tower's viewpoint around by simply clicking on the terrain.

See also: Howto: Configure_views_in_FlightGear