Howto:Set view points

From FlightGear wiki
Jump to navigation Jump to search
Merge-arrows.gif
It has been suggested that this article or section be merged with Howto:Configure views in FlightGear. This has been proposed since March 2016.

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">
  <name>Captain</name>
  <type>lookfrom</type>
  <internal type="bool">true</internal>
  <config>
    <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>
    <pitch-offset-deg>-10</pitch-offset-deg>
    <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>
    <limits>
      <enabled type="bool">true</enabled>
      <left>
        <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>
      </left>
      <right>
        <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>
      </right>
    </limits>
  </config>
  <dynamic>
    <enabled type="bool">false</enabled>
  </dynamic>
</view>
  • 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).

Remark on limits (for developers): If you plan to implement a view-handler for a view there must not <limits>...</limits> be used in the view definition. The limits need to be handled within the view handler instead. If <limits>...</limits> are present within the view definition no (additional) view handler will be invoked (experienced in FG 3.4)

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.

Examples

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.

 <view>
   <name>Chase View</name>
   <type>lookat</type>
   <config>
     <from-model type="bool">false</from-model>
     <from-model-idx type="int">0</from-model-idx>
     <eye-lat-deg-path>/position/latitude-deg</eye-lat-deg-path>
     <eye-lon-deg-path>/position/longitude-deg</eye-lon-deg-path>
     <eye-alt-ft-path>/position/altitude-ft</eye-alt-ft-path>
     <eye-heading-deg-path>/orientation/heading-deg</eye-heading-deg-path>

     <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>
   </config>
 </view>

Tower view

 <view>
   <name>Tower View</name>
   <type>lookat</type>
   <config>
     <eye-lat-deg-path>/sim/tower/latitude-deg</eye-lat-deg-path>
     <eye-lon-deg-path>/sim/tower/longitude-deg</eye-lon-deg-path>
     <eye-alt-ft-path>/sim/tower/altitude-ft</eye-alt-ft-path>
     <eye-roll-deg-path>/sim/tower/roll-deg</eye-roll-deg-path>
     <eye-pitch-deg-path>/sim/tower/pitch-deg</eye-pitch-deg-path>
     <eye-heading-deg-path>/sim/tower/heading-deg</eye-heading-deg-path>

     <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>

   </config>
 </view>

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

Related content

Wiki articles

Source code

External links