DashboardItemDistance

Inherits DashboardItem

This DashboardItem displays the distance between two points. The points can be defined either by the location of a scene graph node, the surface of a scene graph node’s bounding sphere, the location of the current focus node, or the position of the camera. These definitions can be mixed and matched to calculate any combination of positions.

The resulting text can be formatted in the FormatString and the measurement unit is chosed by changing the Simplification and RequestedUnit parameters.

Members

Name

Documentation

Type

Description

Optional

DestinationType

The type of position that is used as the destination to calculate the distance.

String

In list { Node, Node Surface, Focus, Camera }

No

SourceType

The type of position that is used as the source to calculate the distance.

String

In list { Node, Node Surface, Focus, Camera }

No

DestinationNodeIdentifier

If a scene graph node is selected as type, this value specifies the identifier of the node that is to be used as the destination for computing the distance.

String

Value of type ‘String’

Yes

FontName

This value is the name of the font that is used. It can either refer to an internal name registered previously, or it can refer to a path that is used.

String

Value of type ‘String’

Yes

FontSize

This value determines the size of the font that is used to render the distance.

Double

Value of type ‘Double’

Yes

FormatString

The format string that is used for formatting the distance string. This format receives four parameters: The name of the source, the name of the destination the value of the distance and the unit of the distance.

String

Value of type ‘String’

Yes

RequestedUnit

If the simplification is disabled, this distance unit is used as a destination to convert the meters into.

String

In list { Nanometer, Micrometer, Millimeter, Centimeter, Decimeter, Meter, Kilometer, AU, Lighthour, Lightday, Lightmonth, Lightyear, Parsec, Kiloparsec, Megaparsec, Gigaparsec, Gigalightyear, Thou, Inch, Foot, Yard, Chain, Furlong, Mile, League, Nautical Mile }

Yes

Simplification

If this value is enabled, the distance is displayed in nuanced units, such as km, AU, light years, parsecs, etc. If this value is disabled, the unit can be explicitly requested.

Boolean

Value of type ‘Boolean’

Yes

SourceNodeIdentifier

If a scene graph node is selected as type, this value specifies the identifier of the node that is to be used as the source for computing the distance.

String

Value of type ‘String’

Yes

Inherited members from DashboardItem

Name

Documentation

Type

Description

Optional

Identifier

The unique identifier for this DashboardItem.

Identifier

An identifier string. May not contain ‘.’, spaces, newlines, or tabs

No

Type

Determines the type of the DashbordItem that should be created.

String

Value of type ‘String’

No

Enabled

If this value is set to ‘true’ this dashboard item is shown in the dashboard. Otherwise it will be hidden.

Boolean

Value of type ‘Boolean’

Yes

GuiName

The name for the DashboardItem that is used when showing it in the user interface.

String

Value of type ‘String’

Yes

Asset Examples

NodeSurface-Camera

This example adds two invisible nodes and a dashboard item that shows the distance between those two nodes

 1local Node = {
 2  Identifier = "DashboardItemDistance_Example_NodeSurfaceCamera_Node",
 3  BoundingSphere = 200.0,
 4  GUI = {
 5    Name = "DashboardItemDistance - NodeSurface-Camera"
 6  }
 7}
 8
 9local Item = {
10  Identifier = "DashboardItemDistance_Example_NodeSurfaceCamera",
11  Type = "DashboardItemDistance",
12  SourceType = "Node Surface",
13  SourceNodeIdentifier = Node.Identifier,
14  DestinationType = "Camera"
15}
16
17asset.onInitialize(function()
18  openspace.addSceneGraphNode(Node)
19  openspace.dashboard.addDashboardItem(Item)
20end)
21
22asset.onDeinitialize(function()
23  openspace.dashboard.removeDashboardItem(Item)
24  openspace.removeSceneGraphNode(Node)
25end)
Node-Camera

This example adds an invisible node and a dashboard item that shows the distance between this node and the current focus node.

 1local Node = {
 2  Identifier = "DashboardItemDistance_Example_NodeCamera_Node",
 3  GUI = {
 4    Name = "DashboardItemDistance - Node-Camera"
 5  }
 6}
 7
 8local Item = {
 9  Identifier = "DashboardItemDistance_Example_NodeCamera",
10  Type = "DashboardItemDistance",
11  SourceType = "Node",
12  SourceNodeIdentifier = Node.Identifier,
13  DestinationType = "Camera"
14}
15
16asset.onInitialize(function()
17  openspace.addSceneGraphNode(Node)
18  openspace.dashboard.addDashboardItem(Item)
19end)
20
21asset.onDeinitialize(function()
22  openspace.dashboard.removeDashboardItem(Item)
23  openspace.removeSceneGraphNode(Node)
24end)
Node-Node

This example adds two invisible nodes and a dashboard item that shows the distance between those two nodes.

 1local Node1 = {
 2  Identifier = "DashboardItemDistance_Example_NodeNode_Node1",
 3  GUI = {
 4    Name = "DashboardItemDistance - Node-Node (Node 1)"
 5  }
 6}
 7
 8local Node2 = {
 9  Identifier = "DashboardItemDistance_Example_NodeNode_Node2",
10  Transform = {
11    Translation = {
12      Type = "StaticTranslation",
13      Position = { 2.0, 0.0, 0.0 }
14    }
15  },
16  GUI = {
17    Name = "DashboardItemDistance - Node-Node (Node 2)"
18  }
19}
20
21local Item = {
22  Identifier = "DashboardItemDistance_Example_NodeNode",
23  Type = "DashboardItemDistance",
24  SourceType = "Node",
25  SourceNodeIdentifier = Node1.Identifier,
26  DestinationType = "Node",
27  DestinationNodeIdentifier = Node2.Identifier
28}
29
30asset.onInitialize(function()
31  openspace.addSceneGraphNode(Node1)
32  openspace.addSceneGraphNode(Node2)
33  openspace.dashboard.addDashboardItem(Item)
34end)
35
36asset.onDeinitialize(function()
37  openspace.dashboard.removeDashboardItem(Item)
38  openspace.removeSceneGraphNode(Node2)
39  openspace.removeSceneGraphNode(Node1)
40end)
Node-Focus

This example adds an invisible node and a dashboard item that shows the distance between this node and the current focus node.

 1local Node = {
 2  Identifier = "DashboardItemDistance_Example_NodeFocus_Node",
 3  GUI = {
 4    Name = "DashboardItemDistance - Node-Focus"
 5  }
 6}
 7
 8local Item = {
 9  Identifier = "DashboardItemDistance_Example_NodeFocus",
10  Type = "DashboardItemDistance",
11  SourceType = "Node",
12  SourceNodeIdentifier = Node.Identifier,
13  DestinationType = "Focus"
14}
15
16asset.onInitialize(function()
17  openspace.addSceneGraphNode(Node)
18  openspace.dashboard.addDashboardItem(Item)
19end)
20
21asset.onDeinitialize(function()
22  openspace.dashboard.removeDashboardItem(Item)
23  openspace.removeSceneGraphNode(Node1)
24end)