Line |
public class LineSelectorData
The LineSelectorData type exposes the following members.
Name | Description | |
---|---|---|
LineSelectorData(LineBaseNode, Boolean) | Constructor that use the positions defined in the lineNode. | |
LineSelectorData(Vector3, Boolean) | Constructor that use the positions from the specified array of Vector3 values. | |
LineSelectorData(LineBaseNode, SceneView, Boolean) | Constructor that use the positions defined in the lineNode. | |
LineSelectorData(Vector3, Boolean, SceneView) | Constructor that use the positions from the specified array of Vector3. |
Name | Description | |
---|---|---|
AdjustLineDistanceWithLineThickness | Gets or sets a Boolean that specifies if LastDistance value is adjusted by line thickness. If true then distance is measured from line edge, if false then distance is measured from center of the line. This value is used only if LineSelectorData is created from BaseLineVisual3D. | |
CheckBoundingBox | Gets or sets Boolean that specifies if performance is optimized by first checking the bounding box before calculating screen positions. See remarks for more info. Default value is true when the original positions count is more or equal to 30. | |
LastDistance | Gets a float value that specifies the closest distance of this line to the specified position. This value is calculated in GetClosestDistance method. | |
LastLinePositionIndex | Gets an index of the first position of the line segment that is closest to the specified position. This value is calculated in GetClosestDistance method. | |
LineNode | Gets a line SceneNode that was used to create this LineSelectorData. | |
MaxScreenPositionsBoundingBox | Gets the maximum position of a 2D bounding box of the positions on the screen. This property has a valid value only after calling CalculateViewPositions method. | |
MinScreenPositionsBoundingBox | Gets the minimum position of a 2D bounding box of the positions on the screen. This property has a valid value only after calling CalculateViewPositions method. | |
PositionsTransform | Gets or sets a Transform that is used to transform all positions. | |
SceneView | SceneView that is used to show the 3D scene with 3D lines. | |
UsedLineThickness | Gets or sets LineThickness that is used to adjust the actual distance from the line. This value can be automatically set from the LineSelectorData when it is created with BaseLineVisual3D and adjustLineDistanceWithLineThickness set to true. | |
ViewPositions | Gets an array of 2D view positions that were generated from 3D line positions by the CalculateViewPositions method. |
Name | Description | |
---|---|---|
CalculateViewPositions | CalculateViewPositions method converts the 3D line positions into 2D positions on the screen that can be used for calculating distance to specified 2D position. This method must be called before GetClosestDistance(Vector2, Single) or GetClosestPositionOnLine(Vector3, Vector3) methods can be called. The SceneView property must be set before calling this method. When calling CalculateViewPositions on multiple instances of LineSelectorData, it is recommended to use CalculateViewPositions that takes worldToViewMatrix and dpi scale. This is faster because SceneView.GetWorldToViewportMatrix is called only once. | |
CalculateViewPositions(Matrix4x4, Single, Single) | CalculateViewPositions method converts the 3D line positions into 2D positions on the screen that can be used for calculating distance to specified 2D position. This method must be called before GetClosestDistance(Vector2, Single) or GetClosestPositionOnLine(Vector3, Vector3) methods can be called. | |
GetClosestDistance | GetClosestDistance method calculates the closest distance of the line to the specified screenPosition. In case CheckBoundingBox is true (by default) the method returns float.MaxValue when the screenPosition is outside the bounding box. See remarks in the CheckBoundingBox for more info. Before calling this method the CalculateViewPositions method must be called. This method also sets the LastDistance property. To get the line segment index that is closest to the screenPosition read the LastLinePositionIndex property. | |
GetClosestPositionOnLine(Vector3, Vector3) | Gets the Vector3 that represents the closest position of the line segment with index LastLinePositionIndex to the specified ray. The ray is usually calculated by SceneView.GetRayFromCamera method. | |
GetClosestPositionOnLine(Int32, Vector3, Vector3) | Gets the Vector3 that represents the closest position of the line segment with index LastLinePositionIndex to the specified ray. The ray is usually calculated by SceneView.GetRayFromCamera method. | |
UpdateLinePositions | UpdateLinePositions method updates the 3D line positions that are used to calculate the distances. This method needs to be called when the 3D line positions are changed. |
LineSelectorData class can be used to get the closest line to the pointer or mouse position. It also gets the distance to the specified view position and the line segment index.
Before getting the closets distance by calling the GetClosestDistance(Vector2, Single) or GetClosestPositionOnLine(Vector3, Vector3), the CalculateViewPositions or [!:CalculateViewPositions(Matrix4x4, float, float)] method must be called.
When LineSelectorData is created with LineNode parameter, then LineNode's WorldMatrix will be used to transform all the line positions. It is also possible to apply custom transformation by setting the PositionsTransform property. In this case the LineNode's WorldMatrix is not used.
The class by default uses an optimized way of calculating the distance. See remarks in the CheckBoundingBox for more info.