FGCamera

From FlightGear wiki
Jump to navigation Jump to search
FGCamera Add-on
Developed by Marius_A (since 03/2014 to 2017), Slawek Mikula (2017-2022), Roman Ludwicki (2023-now)
Initial release Mar 2014
Latest release 1.2.7, Nov 9, 2024
Written in Nasal
Development status Under active development as of 08/2014
Type Addon
License GNU General Public License v2 and later
Website

FGCamera is an alternative FlightGear view system, written in Nasal, that adds features similar to EZdok Camera Addon for Flight Simulator X.

Currently available features:

  • 5 camera types:
    • Virtual cockpit,
    • Aircraft (look-at),
    • Aircraft (look-from),
    • World (look-at);
    • World (look-from);
  • Arbitrary number of preset views;
  • Smooth/discrete transition between the views of the same camera type.

Installation

  1. Download latest release.
  2. Extract zip (if downloaded as a zip) to a given location. For example let's say we have /myfolder/addons/fgcamera with contents of this addon.
  3. Add path to the addon in the Launcher application in 'Add-On' section OR run FlightGear with --addon option with path to FGCamera like --addon="/myfolder/addons/fgcamera".
Note  FGCamera uses dedicated views with names "FGCamera1", "FGCamera2", "FGCamera3", "FGCamera4", "FGCamera5" with view numbers 120, 121, 122, 123, 124.

Some aircraft models check for specific view name, and other check for specific view numbers. To be fully compatible with FGCamera, aircraft model should check the property "/sim/current-view/internal" instead of view name or view number.

Installation obsolete version 1.2.0 without add-on compatibility

Caution  create backup copies before overwriting.
  1. Download fgcamera_v1_2.zip
  2. Delete (if exist) FG HOME/aircraft-data/FGCamera;
  3. Delete (if exist) FG ROOT/Nasal/fgcamera;
  4. Copy fgcamera folder (from downloaded archive) to FG ROOT/Nasal;
  5. Copy modified mice.xml from "FG ROOT/nasal/fgcamera" to "FG ROOT/";
  6. Use FG ROOT/Nasal/fgcamera/fgcamera_cfg as config. If you use fgrun, open advanced settings, go to "General" and select config path (point to fgcamera_cfg.xml)
Note  make sure that File > Input Configuration > Click right mouse to cycle mouse behaviour (FG menu) is selected

Old development version 1.3 of FGCamera can be downloaded here.

User Interface

Menu "View -> "FGCamera"

Graphical user interface is used to create and manage camera views. FGCamera dialogs can be launched using menubar item View -> FGCamera.

Main Dialog

Main dialog v.1.2.7

First top section has following buttons:

  • "Import..." button allows you to load a camera preset for a specific aircraft. This is a good option for a start, where you don't have to create cameras from scratch, and you can always modify the loaded set.
  • "New camera..." button for create a new camera (opens new camera creation dialog).
  • "Options..." button opens FGCamera's global settings dialog.
  • "?" button opens help dialog.

In the next section, the list of cameras shows all the cameras that are created for the currently selected aircraft. Each camera has its own index, which is also an assigned key from 1, 2 to 0 for switching between cameras. Group (or category) of each camera is displayed as a suffix in square brackets (zero as default [0]). The active camera (currently selected view) is marked by <-.

You can change order of the selected camera by using "Up" and "Dn" buttons.

In the bottom you have "Current camera" section with controls assigned to selected camera:

  • The active camera be renamed using input box below the list of cameras. The second input box is used to define camera group.
  • Combobox to change current group of the selected camera (thanks to this you will be able to switch between cameras of the same group only using a mini-dialog),
  • "Copy camera" button creates a copy of currently selected camera,
  • "Confirm position" button, which you have to click after changing the position and rotation of the camera, to store the position and not lose it when switching to another camera. NOTE! This is needed to clearly indicate that you want to change the camera position and not that you were just looking around.
  • "Config..." button opens configuration dialog of current selected camera.
  • "Delete" button removes the active camera.

Bottom row of buttons:

  • "Save & close" button saves all the cameras data to disk and close main dialog.
  • "Save" button saves all the cameras data to disk.
  • "Close" closes the dialog (changes will not be saved to disk).

"FGCamera options" Dialog

"Options" Dialog v.1.2.7

Clicking "Options..." button you can define behavior of following options:

  • Mouse
    • "Press and hold right mouse to look around in FGCamera" – FGCamera changes the right mouse button behavior to "Click right mouse to cycle mouse behavior" (see File -> Mouse Configuration). Therefore, check this option if you want to look around while holding down the right mouse button. By default, this option is enabled.
    • "Force "Press and hold right mouse to look around" in FG views" – Using FGCamera, you can always switch to FlightGear's default views using the V/ Shift+V key. Check this option if you would like to look around in this mode by holding down the right mouse button. By default, this option is enabled.
  • Mini-dialog
    • "Enable mini-dialog" – enable/disable displaying the mini-dialog, in the lower left corner of the screen. Enabled by default.
    • "Mini-dialog type" – you can choose a "simple" mini-dialog or "slots" which additionally includes 0 to 9 buttons for changing cameras. By default, "simple" mini-dialog is using.
    • "Auto hide mini-dialog" – enabling this option will cause that by default the mini-dialog will be hidden, only pointing the mouse cursor to the lower left corner of the screen will display the mini-dialog. By default, this option is disable.
  • Keys
    • "Use Ctrl with numeric key" – By default, FGCamera overrides the default number key assignments, 0 to 9, using them to switch between cameras. This means you won't be able to use the number keys to control the aircraft, such as the 5 key to return the controls to neutral position, etc. Then you can enable this option to make FGCamera override the number keys with the Ctrl key held down. Then FlightGear's default number keys will work, and switching between cameras will be done with Ctrl+0 to Ctrl+9. By default, this option is disabled.
  • Extra handlers – these handlers are optional and most users don't need them, so they are disabled by default. However, you can always enable them as needed.
    • "Linux Track" – enable/disable Linux Track handler.
    • "TrackIR" – enable/disable TrackIR handler.

Bottom row of buttons:

  • "Save" – save all camera configurations and options to a file and close the window. NOTE! This button works like "Save" in the main "FGCamera" window, i.e. it also saves the cameras.
  • "Close" – just close the Options window (without saving to disk).

"Create new camera" Dialog

"Create new camera" Dialog
  • "Camera type" popup list is used to select camera type. Supported types:
    • "cockpit" – view from cockpit,
    • "aircraft (look at) – view on aircraft,
    • "aircraft (look from)" – view from the aircraft to the outside world,
    • "world (look at) n/a" – any perspective,
    • "world (look from)" – any perspective,
  • "Create" – creates new camera and selects it as an active camera.
  • "Cancel" – closes the dialog.

"Current Camera Config" Dialog

"Current Camera Config" Dialog v.1.2.7
  • "Show popup tip" – if selected, shows view name when the camera is selected.
  • "Show 2D panel" – if selected, shows preferred 2D panel when the camera is selected. You can also choose between two panels to show.
  • "Show dialog" – if selected, shows preferred GUI dialog when the camera is selected. First, type the name of the dialog, such as map for map display, then check the checkbox. To find the available dialog names in FlightGear, use "..." (browse) button. However, the aircraft may have additional dialogs defined. To find out what they are named, search the aircraft source code for the keyword dialog-name.
  • "Field of view" – default field of view in degrees. If you want a wider field of view, use a larger value. Default is 65 degrees.
  • "View movement" – group of inputs that controls view movement between preset views.
    • Transition time" – time to move camera from current position to preset position. Default is 1 second.
  • "View adjustment" – group of inputs that controls view adjustment behavior:
    • "Linear velocity" – translational velocity of camera in meters per second.
    • "Angular velocity" – angular velocity of camera in degrees per second.
    • "Lowpass filter" – "smoothness" of the camera movement.
  • Mouse look – group of inputs that controls mouse look behaviour:
    • "Mouse sensitivity" – self explanatory.
    • "Lowpass filter" – "smoothness" of the camera movement.
  • "DHM" – if selected, enables Dynamic Head Movement configured by "DHM..." button.
  • "RND" – if selected, enables Random movement generator configured by "RND..." button.
  • "Nasal" – if selected, enables Nasal scripts configured by "Nasal..." button.
  • "Close" – just closes the dialog.

"Dynamic Head Movement" Dialog

When selecting "DHM" on the Current Camera Config dialog, user is moved to the options regarding dynamic head movement. There you can define various options regarding this effect. When enabled and configured the camera will move according to defined options the same as normally would move the head of the pilot in the aircraft.

"Random View Generator" Dialog

When selecting "RND" on the Current Camera Config dialog, one is moved to the Random View Generator dialog. There you can define predefined random movement. This option can simulate various aircrafts and situations. When selecting "Import" button, you can import predefined Random setting according to plane types e.g. for General Aircraft (GA) type. Using Ground/Air buttons you can define different random generator according to the aircraft state (in Air/on the Ground).

When pressing "Generator 1...", 2, 3 button you can define additional random signal generators, that can feed the data to main random generator engine.

When pressing "Curves" button, you can define additional output gain regarding velocity in knots.

"Execute Nasal Script" Dialog

Clicking the "Nasal..." button in the Current Camera Config dialog will open a new window for entering Nasal scripts.

This window is divided into two parts. In the upper part we can enter a script to be executed upon entry to the current camera. In the lower part we can enter a script to exit the current camera.

Each part has a checkbox, checking it means enabling the script execution. This way you can control which scripts are executed, independently from the main checkbox in the Current Camera Config dialog.

For example for Cessna 172P, where when entering the camera we have a script that turns on the flashlight (if ALS is enabled) and when leaving the camera we have the flashlight turned off.

Writing a script in the GUI of the current version of FlightGear is very inconvenient, so for each editor field we have the following buttons:

  • "Copy" – copy the script from the editor to the clipboard;
  • "Paste" – paste the script from the clipboard to the editor;
  • "Clear" – remove everything that the editor window contains.

For writing scripts I recommend using an external editor and here using only the above buttons.

Keyboard shortcuts

  • select preset cameras: 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 or Ctrl+1, Ctrl+2, Ctrl+3, Ctrl+4, Ctrl+5, Ctrl+6, Ctrl+7, Ctrl+8, Ctrl+9, Ctrl+0 if "Use Ctrl with numeric key" global option is enabled.
  • adjust camera position: Ctrl+/Ctrl+ (to move camera forward/backward), Ctrl+/Ctrl+ (to move camera left/right), Ctrl+Page Up/Ctrl+Page Down (to move camera up/down).
  • toggle aircraft control by mouse: Ctrl+Space.
Note  If you using keyboard to fly: throttle keys in numeric keyboard (9/3) aren't working with the camera if default FGCamera key assignments are used. Consider using "Use Ctrl with numeric key" global option or just use Page Up/Page Down keys

Key assignments can be customized by editing fgkeyboard.xml file inside add-on folder.

Aircraft integration API

This chapter documents some integration API for your aircraft Nasal code.

Walker compatibility callbacks

Callback / Variable Description
fgcamera.walker.getOutTime wait time in seconds after the getOutCallback executed
fgcamera.walker.getInTime wait time in seconds after the getInCallback executed
fgcamera.walker.getOutCallback() callback when getting out
fgcamera.walker.getInCallback() callback when getting in

The example code for the Cessna C182S which opens the door if not open yet.

#
# Example to open the door on the C182S/T when getting out or in:
# (this code should go to the aircraft nasal script)
#
if (addons.isAddonLoaded("a.marius.FGCamera")) {
    fgcamera.walker.getOutCallback = func {
        fgcamera.walker.getOutTime = getprop("/sim/model/door-positions/DoorL/opened") == 0 ? 2 : 0;
        c182s.DoorL.open();
    };

    fgcamera.walker.getInCallback = func {
        view.setViewByIndex(110); # so we stay outside (under the hood we are already switched one frame into the pilot seat, which we must roll back)
        fgcamera.walker.getInTime = getprop("/sim/model/door-positions/DoorL/opened") == 0 ? 2 : 0;
        c182s.DoorL.close();
    };
}

Commands

Current version of FGCamera has the following commands:

  • fgcamera-select - selects camera by index. If the camera does not exist, switches to camera 0;
  • fgcamera-adjust - adjusts view position and orientation;
  • fgcamera-next-category - cycles to next view category;
  • fgcamera-prev-category - cycles to previous view category;
  • fgcamera-next-in-category - cycles to next view in currently selected category;
  • fgcamera-prev-in-category - cycles to previous view in currently selected category;
  • fgcamera-reset-view - resets currently selected camera's position and orientation.

fgcamera-select

Uses one argument:

  • camera-id - integer number (camera-id ≥ 0);

Keyboard binding example:

<key n="49">
    <name>1</name>
    <repeatable type="bool">false</repeatable>
    <desc>Preset view 1</desc>
    <binding>
        <command>fgcamera-select</command>
        <camera-id>0</camera-id>
    </binding>
</key>

fgcamera-adjust

Uses two arguments:

  • velocity - camera movement velocity. Recommended values -1, 0, 1;
  • dof - affected degree of freedom. Valid values:
    • x - left/right,
    • y - up/down,
    • z - back/forward,
    • h - heading,
    • p - pitch,
    • r - roll.

Keyboard binding example:

<key n="360">
    <name> PageUp </name>
    <desc>Camera Up</desc>
    <binding>
        <command>fgcamera-adjust</command>
        <velocity>1</velocity>
        <dof>y</dof>
    </binding>
    <mod-up>
        <binding>
            <command>fgcamera-adjust</command>
            <velocity>0</velocity>
            <dof>y</dof>
        </binding>
    </mod-up>
</key>

Joystick POV hat binding example:

<axis>
    <number><windows>6</windows></number>
    <desc>View Direction</desc>
    <low>
        <binding>
            <command>fgcamera-adjust</command>
            <velocity>1</velocity>
            <dof>h</dof>
        </binding>
        <mod-up>
            <binding>
                <command>fgcamera-adjust</command>
                <velocity>0</velocity>
                <dof>h</dof>
            </binding>
        </mod-up>
    </low>
    <high>
        <binding>
            <command>fgcamera-adjust</command>
            <velocity>-1</velocity>
            <dof>h</dof>
        </binding>
        <mod-up>
            <binding>
                <command>fgcamera-adjust</command>
                <velocity>0</velocity>
                <dof>h</dof>
            </binding>
        </mod-up>
    </high>
</axis>

fgcamera-next-category

Binding example:

<!-- ... -->
    <binding>
        <command>fgcamera-next-category</command>
    </binding>
<!-- ... -->

fgcamera-prev-category

Binding example:

<!-- ... -->
    <binding>
        <command>fgcamera-prev-category</command>
    </binding>
<!-- ... -->

fgcamera-next-in-category

Binding example:

<!-- ... -->
    <binding>
        <command>fgcamera-next-in-category</command>
    </binding>
<!-- ... -->

fgcamera-prev-in-category

Binding example:

<!-- ... -->
    <binding>
        <command>fgcamera-prev-in-category</command>
    </binding>
<!-- ... -->

fgcamera-reset-view

Binding example:

<!-- ... -->
    <binding>
        <command>fgcamera-reset-view</command>
    </binding>
<!-- ... -->

Replay timestamps

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.
Caution  The timestamps come from development version 1.3, which looks abandoned.

[FGCamera v1.2.1]

<PropertyList>
    <timestamp>
        ...
    </timestamp>
    <timestamp>
        ...
    </timestamp>
    ...
</PropertyList>
    <timestamp>
        <time-str>0:00.0</time-str>
        <jump-to>7:15.0</jump-to>     <!-- optional -->
        <camera-id>0</camera-id>
    </timestamp>
    <timestamp>
        <time-str>0:00.0</time-str>
        <jump-to>5:25.8</jump-to>     <!-- optional -->
        <click-camera>
            <latitude-deg>37.62122627018694</latitude-deg>
            <longitude-deg>-122.3981490730425</longitude-deg>
            <altitude-ft>27.42773406108862</altitude-ft>
        </click-camera>
    </timestamp>

Development status (Apr 2015)

  • 60}% completed "AI/MP Missile view" mode [1];
  • 80}% completed Dynamic view movement;
  • Done Done Random camera movement (effects). Effects can be copied/pasted and imported from external files. New dialogs for RND effects management.
  • Done Done Alternative config (presets) that supports "keyboard+mouse" flight controls; modifying the script to fully support "keyboard+mouse" flight controls;
  • Done Done View Categories;
  • Done Done Making view name popup-tips optional (customizable for each view);
  • Done Done Each camera view can open GUI dialog;
  • 100}% completed Ability to load older version cameras (backward compatibility);
  • Done Done Each camera view can open 2d panel;
  • 40}% completed dedicated FGCamera API (e.g. for aircraft developers wanting to use fgcamera directly), intended to support versioning for stable APIs, without introducing regressions;
  • 80}% completed reimplement current FGCamera functionality using Property rules (reduce Nasal usage);

Gallery

Support

FGCamera forum thread