Checklist/Tutorial: Auto view direction to marker
This change automatically changes the view direction to look at a <marker> if any is defined for a checklist item or tutorial step. Both the tutorial and checklist features support a <marker> element which can be used by an aircraft developer to display a magenta circle around an item of interest (typically a control in the cockpit). Previously aircraft developers had to add a <view> element to move the viewpoint to look at the marker, while users of checklists had to look for the marker manually. Now: - For checklists, pressing the "?" button on a checklist will pan the viewpoint to the marker. - For tutorials, if there is not a <view> element defined for a tutorial step, the view will automatically pan to the marker.
This commit is contained in:
parent
99ecc9a563
commit
9e2ee8b969
4 changed files with 65 additions and 6 deletions
|
@ -21,7 +21,8 @@ with the following tags
|
|||
hand side
|
||||
<marker> - A tutorial marker (displayed when the user presses the ? button)
|
||||
This can be easily placed using the Help->Display Tutorial Marker.
|
||||
Contains x-m, y-m, z-m and scale tag.
|
||||
Contains x-m, y-m, z-m and scale tag. The view will automatically
|
||||
change so the marker is in the center of the screen.
|
||||
<condition> - Optional standard FlightGear condition node that evaluates when the
|
||||
checklist item has been completed.
|
||||
<binding> - Zero or more bindings to execute the checklist item. Allows the user
|
||||
|
|
|
@ -356,8 +356,8 @@ copilot view etc. Default view-number is 0 (captain's view).
|
|||
<field-of-view>55</field-of-view> default: 55; smaller zooms in
|
||||
</view> bigger zooms out
|
||||
|
||||
|
||||
|
||||
If a <marker> is set by no <view>, the tutorial will automatically change the view
|
||||
direction so the marker is in the center of the screen.
|
||||
|
||||
|
||||
-- <marker> -------------------------------------------------------------------
|
||||
|
@ -387,9 +387,8 @@ model in its animation xml file:
|
|||
...
|
||||
</PropertyList>
|
||||
|
||||
|
||||
|
||||
|
||||
If a <marker> is set by no <view>, the tutorial will automatically change the view
|
||||
direction so the marker is in the center of the screen.
|
||||
|
||||
-- <message>/<audio> ----------------------------------------------------------
|
||||
|
||||
|
|
|
@ -347,12 +347,43 @@ var remove_models = func {
|
|||
var set_view = func(node = nil) {
|
||||
node != nil or return;
|
||||
var v = node.getChild("view");
|
||||
var m = node.getChild("marker");
|
||||
if (v != nil) {
|
||||
# when changing view direction, switch to view 0 (captain's view),
|
||||
# unless another view is explicitly specified
|
||||
v.initNode("view-number", 0, "INT", 0);
|
||||
view.point.move(v);
|
||||
return 1;
|
||||
} elsif (m != nil) {
|
||||
# We don't have a specific view, but there is a marker we should
|
||||
# direct the viewpoint towards.
|
||||
|
||||
# Determine offset to the marker.
|
||||
var vx = getprop("/sim/current-view/x-offset-m"); # Port/Starboard (+ve starboard)
|
||||
var vy = getprop("/sim/current-view/y-offset-m"); # Up/Down (+ve up)
|
||||
var vz = getprop("/sim/current-view/z-offset-m"); # Fore/Aft (+ve aft)
|
||||
|
||||
# BUT the marker has a different coordinate system!
|
||||
var x = m.getNode("x-m", 1).getValue(); # Fore/Aft (+ve aft)
|
||||
var y = m.getNode("y-m", 1).getValue(); # Port/Starboard (+ve starboard)
|
||||
var z = m.getNode("z-m", 1).getValue(); # Up/Down (+ve up)
|
||||
|
||||
# So we need to do a coordinate transformation as we calculate the angles
|
||||
var hdg = math.atan2(y-vx, x-vz) * R2D + 180;
|
||||
var pitch = math.atan2((z-vy), math.sqrt((x-vz)*(x-vz) + (y-vx)*(y-vx))) * R2D;
|
||||
|
||||
if (! ((hdg > 160) and (hdg < 200))) {
|
||||
# Making the assumption we're in the cockpit, there are limits to where we can look
|
||||
# that are enforced by the view system. So we can't look into the region of heading
|
||||
# 160-200.
|
||||
var v = props.Node.new();
|
||||
v.setValues({
|
||||
"heading-offset-deg" : hdg,
|
||||
"pitch-offset-deg": pitch,
|
||||
});
|
||||
view.point.move(v);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -325,8 +325,36 @@
|
|||
"scale/value": scale,
|
||||
"arrow-enabled": 1,
|
||||
});
|
||||
|
||||
# Determine offset to the marker.
|
||||
var vx = getprop("/sim/current-view/x-offset-m"); # Left/right (+ve right)
|
||||
var vy = getprop("/sim/current-view/y-offset-m"); # Up/Down (+ve up)
|
||||
var vz = getprop("/sim/current-view/z-offset-m"); # Forward/backwards (+ve aft)
|
||||
|
||||
# BUT the marker has a different coordinate system!
|
||||
# x = fore/aft (+ve aft)
|
||||
# y = left/right (+ve right)
|
||||
# z = up/down (+ve up)
|
||||
|
||||
# So we need to do a coordinate transformation as we calculate the angles
|
||||
var hdg = math.atan2(y-vx, x-vz) * R2D + 180;
|
||||
var pitch = math.atan2((z-vy), math.sqrt((x-vz)*(x-vz) + (y-vx)*(y-vx))) * R2D;
|
||||
|
||||
if (! ((hdg > 160) and (hdg < 200))) {
|
||||
# Making the assumption we're in the cockpit, there are limits to where we can look
|
||||
# that are enforced by the view system. So we can't look into the region of heading
|
||||
# 160-200.
|
||||
var v = props.Node.new();
|
||||
v.setValues({
|
||||
"heading-offset-deg" : hdg,
|
||||
"pitch-offset-deg": pitch,
|
||||
});
|
||||
view.point.move(v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
var nextPage = func() {
|
||||
var currentPage = getprop("/sim/gui/dialogs/checklist/selected-page");
|
||||
var s = getprop("/sim/gui/dialogs/checklist/selected-checklist");
|
||||
|
|
Loading…
Add table
Reference in a new issue