AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
DistorterSphere.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 System.Collections;
5 using System.Collections.Generic;
6 using UnityEngine;
7 
8 namespace HoloToolkit.Unity.UX
9 {
10  public class DistorterSphere : Distorter
11  {
12  public Vector3 SphereCenter
13  {
14  get
15  {
16  return transform.TransformPoint(sphereCenter);
17  }
18  set
19  {
20  sphereCenter = transform.InverseTransformPoint(value);
21  }
22  }
23 
24  [SerializeField]
25  private Vector3 sphereCenter;
26  [SerializeField]
27  private float radius = 2f;
28 
29  protected override Vector3 DistortPointInternal(Vector3 point, float strength)
30  {
31  Vector3 direction = (point - SphereCenter).normalized;
32  return Vector3.Lerp(point, SphereCenter + (direction * radius), strength);
33  }
34 
35  protected override Vector3 DistortScaleInternal(Vector3 point, float strength)
36  {
37  return Vector3.one;
38  }
39 
40  private void OnDrawGizmos()
41  {
42  Gizmos.color = Color.red;
43  Gizmos.DrawWireSphere(SphereCenter, radius);
44  }
45  }
46 }
override Vector3 DistortPointInternal(Vector3 point, float strength)
Internal function where position distortion is done
override Vector3 DistortScaleInternal(Vector3 point, float strength)
Internal function where scale distortion is done