Howto:Configure views in FlightGear

From FlightGear wiki
Revision as of 04:15, 20 June 2006 by 68.48.113.245 (talk) (Starting transfer of Jim Wilson's 24 April 2002 how to)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This mini-HOWTO explains how to configure views in FlightGear. Views define the position of the eye in the rendered scene and what if any object the eye is focused on or tracking. The eye is the imaginary or constructed eye that is simulated by the 3D rendering. It makes the picture on your screen represent what things would look like if you were standing or sitting at a given location.

Formerly there were two views hard coded into FlightGear, but as this document describes, 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.

Types of Views

There are two basic types of views:

LookFrom - This type requires a single coordinate position. The direction of the view is independant of any particular object. Adjusting the heading and pitch offsets moves the direction of observation around. In the default Flight Gear configuration panning with the mouse will move the view around as if the observer was turning their head.

LookAt - This type requires a two coordinate positions. The direction of the view is always oriented toward a target and tracks the target if it moves.

(see configuration examples below for usage of the <type> paramter)

Defining Positions

There are two methods to define a postion and orientation for use in configuring a view. One method is tied to a model which means the view references the position and orientation of a model (e.g. Aircraft 3D Model) and the other is an idependant postion which simply means that the view references location data directly (via the Flight Gear property tree):

Tied to a Model - This method allows definition of the "eye", that is where you are looking from and/or the "target" or objected being looked at based on a model position and orientation. The following illustrates defining the positon of a "Cockpit View" that is positioned and oriented according to the position and orientation of a model:

<sim>
  <view>
    <name>Cockpit View</name>
    <type>lookfrom</type>
    <internal type="bool">true</internal>
    <config>
      <from-model type="bool">true</from-model>
      <from-model-idx type="int">0</from-model-idx>
    </config>
  </view>
</sim>


Syntax for the eye position is:

   <from-model type="bool">true or false</from-model>
   <from-model-idx type="int">modelnumber</from-model-idx>

Syntax for the target or at position used in views of type "lookat" is:

   <at-model type="bool">true or false</at-model>
   <at-model-idx type="int">modelnumber</at-model-idx>

Note that from-model or at-model must be true in order for the position and orientation data from the model to be used.

Independant Position - This method allows definition of the eye, that is where you are looking from or the target (objected being looked at) based on arbitrary position and orientation data obtained from the property tree (i.e. any source). The following illustrates a Tower defined as a "lookat", a view that can be used to track or follow a moving model:


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

    </config>
  </view>
</sim>

Note that the definition is constructed as a path to a numeric data item in the global property tree. If you are unfamiliar with these properties, take a look at the "Property Picker" dialog while Flight Gear is running and you can see the kinds of values in use. You may define your own static values, say for a fixed location of an observer, by adding the following xml to your setup (prefrences.xml or another file):

<somepath>

 <ground-observer-lon-deg>48.6124</ground-observer-lon-deg>
 <ground-observer-lat-deg>63.1243</ground-observer-lat-deg>
 <ground-observer-alt-ft>123.5</ground-observer-alt-ft>

</somepath>

These values can then then be referenced in your view by including their path in the definition. For example to reference the above longitude for the ground observer:

<sim>

 <view>
   <config>
     <eye-lat-deg-path>/somepath/ground-observer-lat-deg></eye-lon-deg-path>
     ..


All three longitude, latitude, and altitude must be defined to have a valid position (otherwise the missing items default to 0). You may also define orientation such as heading (the direction to look toward) and pitch (the angle up or down to be looking). In the case of a cockpit view the orientation will be that of the aircraft itself, but in the case of a "lookfrom" view like a ground observer or tower it can be an arbitrary view direction that is either static, or changing. Syntax for the eye position and orientation is:

   <eye-lat-deg-path>path-to-property-value</eye-lat-deg-path>
   <eye-lon-deg-path>path-to-property-value</eye-lon-deg-path>
   <eye-alt-ft-path>path-to-property-value</eye-alt-ft-path>
   <eye-roll-deg-path>path-to-property-value</eye-roll-deg-path>
   <eye-pitch-deg-path>path-to-property-value</eye-pitch-deg-path>
   <eye-heading-deg-path>path-to-property-value</eye-heading-deg-path>

Syntax for the target or at position used in views of type "lookat" is:

   <target-lat-deg-path>path-to-property-value</target-lat-deg-path>
   <target-lon-deg-path>path-to-property-value</target-lon-deg-path>
   <target-alt-ft-path>path-to-property-value</target-alt-ft-path>