AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
Line.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using HoloToolkit.Unity;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.UX
8 {
9  public class Line : LineBase
10  {
11  [Header("Line Settings")]
12  public Vector3 Start = Vector3.zero;
13  public Vector3 End = Vector3.one;
14 
15  public override int NumPoints
16  {
17  get
18  {
19  return 2;
20  }
21  }
22 
23  protected override Vector3 GetPointInternal(int pointIndex)
24  {
25  switch (pointIndex)
26  {
27  case 0:
28  default:
29  return Start;
30 
31  case 1:
32  return End;
33  }
34  }
35 
36  protected override void SetPointInternal(int pointIndex, Vector3 point)
37  {
38  switch (pointIndex)
39  {
40  case 0:
41  default:
42  Start = point;
43  break;
44 
45  case 1:
46  End = point;
47  break;
48  }
49  }
50 
51  protected override Vector3 GetPointInternal(float normalizedDistance)
52  {
53  return Vector3.Lerp(Start, End, normalizedDistance);
54  }
55 
56  protected override float GetUnclampedWorldLengthInternal()
57  {
58  return Vector3.Distance(Start, End);
59  }
60 
61  protected override Vector3 GetUpVectorInternal(float normalizedLength)
62  {
63  return transform.up;
64  }
65 
66 #if UNITY_EDITOR
67  [UnityEditor.CustomEditor(typeof(Line))]
68  public class CustomEditor : LineBaseEditor {
69  protected override void DrawCustomSceneGUI()
70  {
71  base.DrawCustomSceneGUI();
72 
73  LineBase line = (LineBase)target;
74  line.FirstPoint = SquareMoveHandle(line.FirstPoint);
75  line.LastPoint = SquareMoveHandle(line.LastPoint);
76  }
77  }
78 #endif
79  }
80 }
override Vector3 GetUpVectorInternal(float normalizedLength)
Gets the up vector at a normalized length along line (used for rotation)
Definition: Line.cs:61
override float GetUnclampedWorldLengthInternal()
Get the UNCLAMPED world length of the line
Definition: Line.cs:56
override void SetPointInternal(int pointIndex, Vector3 point)
Definition: Line.cs:36
override Vector3 GetPointInternal(int pointIndex)
Get a point based on point index Point index will be pre-clamped
Definition: Line.cs:23
override Vector3 GetPointInternal(float normalizedDistance)
Get a point based on normalized distance along line Normalized distance will be pre-clamped ...
Definition: Line.cs:51