AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
LineTest.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 UnityEngine;
5 using System.Collections;
6 
7 namespace HoloToolkit.Examples.GazeRuler
8 {
12  public class LineTest : MonoBehaviour
13  {
14 
15  public GameObject start;
16  public GameObject end;
17  public GameObject line;
18  public GameObject text;
19 
20  // Update is called once per frame
21  private void Update()
22  {
23  var distance = Vector3.Distance(start.transform.position, end.transform.position);
24  var midPoint = (start.transform.position + end.transform.position) * 0.5f;
25  var direction = end.transform.position - start.transform.position;
26  line.transform.position = midPoint;
27  line.transform.localScale = new Vector3(distance, 1.0f, 1.0f);
28  line.transform.rotation = Quaternion.LookRotation(direction);
29  line.transform.Rotate(Vector3.down, 90f);
30  text.transform.position = midPoint + new Vector3(0, 0.6f, 0);
31  text.transform.rotation = Quaternion.LookRotation(direction.x + direction.y + direction.z < 0 ? direction * -1 : direction);
32  text.transform.Rotate(Vector3.up, -90f);
33 
34  Debug.Log(Vector3.Angle(direction, Vector3.forward));
35  }
36  }
37 }
it&#39;s a test case, we try create line correctly between two points
Definition: LineTest.cs:12