FGCamera API

From FlightGear wiki
Jump to navigation Jump to search
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 API come from development version 1.3 of FGCamera, which looks abandoned. See FGCamera.
var fgcam_API = fgcamera.API("1.0 devel");

CameraList()

CameraCount()

Returns number of cameras in a list.

camera(index)

Returns camera object, or nil (if camera does not exist).

select()

Selects the camera (FlightGear will switch to this camera).

reset()

copy()

Creates and returns a copy of camera object.

delete()

Removes the camera from cameras list.

Example:

fgcam_API.CameraList().CameraByName("Pilot view").delete();

will delete camera named "Pilot view" from the cameras list.

name(name = nil)

Sets or returns the name of camera.

Example 1:

var L = fgcam_API.CameraList();
L.CameraByName("Pilot view").name("Passenger view");

will change the name of camera "Pilot view" to "Passenger view".

Example 2:

var n = fgcam_API.CameraList().CurrentCamera().name();
print(n);

will print currently selected camera's name.

id(id = nil)

Sets or returns ID of camera.

Example:

var reorder_cameras = func (dir) {
    var c = fgcam_API.CameraList().CurrentCamera();
    c.id(c.id() + dir);
}

index()

Returns the index of camera.

category(category = nil)

Sets or returns category of camera.


dialog(show = nil, name = nil)

panel(show = nil, name = nil)

settings("view adjustment")

Example 1:

fgcam_API.CameraList().CurrentCamera().settings("view adjustment")
    .FOV(65)
    .LinearVelocity(0.2)
    .AngularVelocity(30)
    .filter(0.5);

Example 2:

var s = fgcam_API.CameraList().CurrentCamera().settings("view adjustment");
var values = [s.FOV(), s.LinearVelocity(), s.AngularVelocity(), s.filter()];
FOV(fov = nil)
LinearVelocity(v_l = nil)
AngularVelocity(v_a = nil)
filter(coeff = nil)

settings("view movement")

LinearInterpolation(linterp = nil)
chained(chained = nil)
filter(coeff = nil)

settings("mouse look")

sensitivity(sensitivity = nil)
filter(filter = nil)

settings("head tracker")

loadFromXML(path)

loads camera settings from *.xml file.

<PropertyList>
    <camera>
        ...
    </camera>
</PropertyList>

saveToXML(path)

Saves camera settings to *.xml file.


effect("DHM")

HeadMass(mass = nil)
scale(scale = nil)
LoadRelease(release = nil)
ConstantG(dof, factor = nil)
ImpulseG(dof, factor = nil)
HeadBank(factor = nil)
HeadPitch(factor = nil)
damping(dof, damping = nil)
limit(dof, limit = nil)

effect("RND")

CameraByID(id)

Returns camera object, or nil if camera does not exist.

CameraByName(name)

Returns camera object, or nil if camera does not exist.

CurrentCamera()

Returns currently selected camera object with additional methods (see below)

storeOffsets()

Sets current camera location as default. Each time the camera is selected it will move to this location.

moveTo([x, y, z, heading, pitch, roll])

Moves the camera to a new position.

clear()

Removes all the cameras from a list. Returns camera list object.

addCamera(name = nil, type = nil)

Creates new camera. Returns newly created camera object.

setFromXML(path)

Loads list of cameras from *.xml file.

Example:

var input_path = getprop("/sim/fg-root" ~ "/Aircraft/Cub/fgcamera/cub_cameras.xml");
fgcam_API.CameraList().setFromXML(input_path);

saveToXML(path)

Saves list of cameras to *.xml file

Example:

var output_path = getprop("/sim/fg-home" ~ "/aircraft-data/fgcamera/cub_custom_cameras.xml");
fgcam_API.CameraList().saveToXML(output_path);