Skip to content

Commit b03a1a4

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/HoloToolkit-Unity into InputManagerRefactoring
2 parents c55e0c7 + c56554b commit b03a1a4

File tree

293 files changed

+27763
-5156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+27763
-5156
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
*.md text
55

66
*.prefab eol=lf
7+
*.meta eol=lf
8+
*.mat eol=lf
9+
*.anim eol=lf
10+
*.controller eol=lf
11+
*.asset eol=lf
712

813
.gitattributes text

Assets/HoloToolkit-Examples/ColorPicker/GazeableColorPicker.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using HoloToolkit.Unity.InputModule;
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.InputModule;
25
using UnityEngine;
36
using UnityEngine.Events;
47

5-
namespace Lighthouse
8+
namespace HoloToolkit.Examples.ColorPicker
69
{
710
public class GazeableColorPicker : MonoBehaviour, IFocusable, IInputClickHandler
811
{
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
using UnityEngine;
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 UnityEngine;
25
using System.Collections;
36

4-
public class DeleteLine : MonoBehaviour
7+
namespace HoloToolkit.Examples.GazeRuler
58
{
6-
/// <summary>
7-
/// when tip text is tapped, destroy this tip and relative objects.
8-
/// </summary>
9-
public void OnSelect()
9+
public class DeleteLine : MonoBehaviour
1010
{
11-
var parent = gameObject.transform.parent.gameObject;
12-
if (parent != null)
11+
/// <summary>
12+
/// when tip text is tapped, destroy this tip and relative objects.
13+
/// </summary>
14+
public void OnSelect()
1315
{
14-
Destroy(parent);
16+
var parent = gameObject.transform.parent.gameObject;
17+
if (parent != null)
18+
{
19+
Destroy(parent);
20+
}
1521
}
1622
}
17-
}
23+
}
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
using UnityEngine;
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 UnityEngine;
25
using System.Collections;
36

4-
/// <summary>
5-
/// interface for geometry class
6-
/// </summary>
7-
public interface IGeometry
7+
namespace HoloToolkit.Examples.GazeRuler
88
{
9-
void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject TextPrefab);
9+
/// <summary>
10+
/// interface for geometry class
11+
/// </summary>
12+
public interface IGeometry
13+
{
14+
void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject TextPrefab);
1015

11-
void Delete();
16+
void Delete();
1217

13-
void Clear();
18+
void Clear();
1419

15-
void Reset();
20+
void Reset();
21+
}
1622
}
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
using UnityEngine;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
23

3-
/// <summary>
4-
/// any geometry class inherit this interface should be closeable
5-
/// </summary>
6-
public interface IPolygonClosable
4+
using UnityEngine;
5+
6+
namespace HoloToolkit.Examples.GazeRuler
77
{
8-
//finish special ploygon
9-
void ClosePloygon(GameObject LinePrefab, GameObject TextPrefab);
10-
}
8+
/// <summary>
9+
/// any geometry class inherit this interface should be closeable
10+
/// </summary>
11+
public interface IPolygonClosable
12+
{
13+
//finish special polygon
14+
void ClosePolygon(GameObject LinePrefab, GameObject TextPrefab);
15+
}
16+
}
Lines changed: 106 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,143 @@
1-
using UnityEngine;
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 UnityEngine;
25
using HoloToolkit.Unity;
36
using System.Collections.Generic;
47
using HoloToolkit.Unity.InputModule;
58

6-
/// <summary>
7-
/// mananger all lines in the scene
8-
/// </summary>
9-
public class LineManager : Singleton<LineManager>, IGeometry
9+
namespace HoloToolkit.Examples.GazeRuler
1010
{
11-
// save all lines in scene
12-
private Stack<Line> Lines = new Stack<Line>();
13-
14-
private Point lastPoint;
15-
16-
private const float defaultLineScale = 0.005f;
17-
18-
// place point and lines
19-
public void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject TextPrefab)
11+
/// <summary>
12+
/// mananger all lines in the scene
13+
/// </summary>
14+
public class LineManager : Singleton<LineManager>, IGeometry
2015
{
16+
// save all lines in scene
17+
private Stack<Line> Lines = new Stack<Line>();
2118

22-
var hitPoint = GazeManager.Instance.HitPosition;
19+
private Point lastPoint;
2320

24-
var point = (GameObject)Instantiate(PointPrefab, hitPoint, Quaternion.identity);
25-
if (lastPoint != null && lastPoint.IsStart)
26-
{
27-
var centerPos = (lastPoint.Position + hitPoint) * 0.5f;
21+
private const float defaultLineScale = 0.005f;
2822

29-
var directionFromCamera = centerPos - Camera.main.transform.position;
23+
// place point and lines
24+
public void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject TextPrefab)
25+
{
3026

31-
var distanceA = Vector3.Distance(lastPoint.Position, Camera.main.transform.position);
32-
var distanceB = Vector3.Distance(hitPoint, Camera.main.transform.position);
27+
Vector3 hitPoint = GazeManager.Instance.HitPosition;
3328

34-
Debug.Log("A: " + distanceA + ",B: " + distanceB);
35-
Vector3 direction;
36-
if (distanceB > distanceA || (distanceA > distanceB && distanceA - distanceB < 0.1))
29+
GameObject point = (GameObject)Instantiate(PointPrefab, hitPoint, Quaternion.identity);
30+
if (lastPoint != null && lastPoint.IsStart)
3731
{
38-
direction = hitPoint - lastPoint.Position;
32+
Vector3 centerPos = (lastPoint.Position + hitPoint) * 0.5f;
33+
34+
Vector3 directionFromCamera = centerPos - Camera.main.transform.position;
35+
36+
float distanceA = Vector3.Distance(lastPoint.Position, Camera.main.transform.position);
37+
float distanceB = Vector3.Distance(hitPoint, Camera.main.transform.position);
38+
39+
Debug.Log("A: " + distanceA + ",B: " + distanceB);
40+
Vector3 direction;
41+
if (distanceB > distanceA || (distanceA > distanceB && distanceA - distanceB < 0.1))
42+
{
43+
direction = hitPoint - lastPoint.Position;
44+
}
45+
else
46+
{
47+
direction = lastPoint.Position - hitPoint;
48+
}
49+
50+
float distance = Vector3.Distance(lastPoint.Position, hitPoint);
51+
GameObject line = (GameObject)Instantiate(LinePrefab, centerPos, Quaternion.LookRotation(direction));
52+
line.transform.localScale = new Vector3(distance, defaultLineScale, defaultLineScale);
53+
line.transform.Rotate(Vector3.down, 90f);
54+
55+
Vector3 normalV = Vector3.Cross(direction, directionFromCamera);
56+
Vector3 normalF = Vector3.Cross(direction, normalV) * -1;
57+
GameObject tip = (GameObject)Instantiate(TextPrefab, centerPos, Quaternion.LookRotation(normalF));
58+
59+
//unit is meter
60+
tip.transform.Translate(Vector3.up * 0.05f);
61+
tip.GetComponent<TextMesh>().text = distance + "m";
62+
63+
GameObject root = new GameObject();
64+
lastPoint.Root.transform.parent = root.transform;
65+
line.transform.parent = root.transform;
66+
point.transform.parent = root.transform;
67+
tip.transform.parent = root.transform;
68+
69+
Lines.Push(new Line
70+
{
71+
Start = lastPoint.Position,
72+
End = hitPoint,
73+
Root = root,
74+
Distance = distance
75+
});
76+
77+
lastPoint = new Point
78+
{
79+
Position = hitPoint,
80+
Root = point,
81+
IsStart = false
82+
};
83+
3984
}
4085
else
4186
{
42-
direction = lastPoint.Position - hitPoint;
87+
lastPoint = new Point
88+
{
89+
Position = hitPoint,
90+
Root = point,
91+
IsStart = true
92+
};
4393
}
94+
}
4495

45-
var distance = Vector3.Distance(lastPoint.Position, hitPoint);
46-
var line = (GameObject)Instantiate(LinePrefab, centerPos, Quaternion.LookRotation(direction));
47-
line.transform.localScale = new Vector3(distance, defaultLineScale, defaultLineScale);
48-
line.transform.Rotate(Vector3.down, 90f);
49-
50-
var normalV = Vector3.Cross(direction, directionFromCamera);
51-
var normalF = Vector3.Cross(direction, normalV) * -1;
52-
var tip = (GameObject)Instantiate(TextPrefab, centerPos, Quaternion.LookRotation(normalF));
53-
54-
//unit is meter
55-
tip.transform.Translate(Vector3.up * 0.05f);
56-
tip.GetComponent<TextMesh>().text = distance + "m";
57-
58-
var root = new GameObject();
59-
lastPoint.Root.transform.parent = root.transform;
60-
line.transform.parent = root.transform;
61-
point.transform.parent = root.transform;
62-
tip.transform.parent = root.transform;
63-
64-
Lines.Push(new Line
65-
{
66-
Start = lastPoint.Position,
67-
End = hitPoint,
68-
Root = root,
69-
Distance = distance
70-
});
71-
72-
lastPoint = new Point
73-
{
74-
Position = hitPoint,
75-
Root = point,
76-
IsStart = false
77-
};
7896

79-
}
80-
else
97+
// delete latest placed lines
98+
public void Delete()
8199
{
82-
lastPoint = new Point
100+
if (Lines != null && Lines.Count > 0)
83101
{
84-
Position = hitPoint,
85-
Root = point,
86-
IsStart = true
87-
};
88-
}
89-
}
90-
102+
Line lastLine = Lines.Pop();
103+
Destroy(lastLine.Root);
104+
}
91105

92-
// delete latest placed lines
93-
public void Delete()
94-
{
95-
if (Lines != null && Lines.Count > 0)
96-
{
97-
var lastLine = Lines.Pop();
98-
Destroy(lastLine.Root);
99106
}
100107

101-
}
102-
103-
// delete all lines in the scene
104-
public void Clear()
105-
{
106-
if (Lines != null && Lines.Count > 0)
108+
// delete all lines in the scene
109+
public void Clear()
107110
{
108-
while (Lines.Count > 0)
111+
if (Lines != null && Lines.Count > 0)
109112
{
110-
var lastLine = Lines.Pop();
111-
Destroy(lastLine.Root);
113+
while (Lines.Count > 0)
114+
{
115+
Line lastLine = Lines.Pop();
116+
Destroy(lastLine.Root);
117+
}
112118
}
113119
}
114-
}
115120

116-
// reset current unfinished line
117-
public void Reset()
118-
{
119-
if (lastPoint != null && lastPoint.IsStart)
121+
// reset current unfinished line
122+
public void Reset()
120123
{
121-
Destroy(lastPoint.Root);
122-
lastPoint = null;
124+
if (lastPoint != null && lastPoint.IsStart)
125+
{
126+
Destroy(lastPoint.Root);
127+
lastPoint = null;
128+
}
123129
}
124130
}
125-
}
126131

127132

128-
public struct Line
129-
{
130-
public Vector3 Start { get; set; }
133+
public struct Line
134+
{
135+
public Vector3 Start { get; set; }
131136

132-
public Vector3 End { get; set; }
137+
public Vector3 End { get; set; }
133138

134-
public GameObject Root { get; set; }
139+
public GameObject Root { get; set; }
135140

136-
public float Distance { get; set; }
141+
public float Distance { get; set; }
142+
}
137143
}

0 commit comments

Comments
 (0)