Skip to content

Commit 3af5a6e

Browse files
authored
Merge branch 'mrtk_development' into feature/doc_contribute
2 parents 76fd7fa + 2a953e3 commit 3af5a6e

File tree

97 files changed

+3400
-871
lines changed

Some content is hidden

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

97 files changed

+3400
-871
lines changed

Assets/MixedRealityToolkit.Examples/Demos/EyeTracking/Demo_ScrollPanZoom/Scripts/BaseClasses/PanZoomBase.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ public abstract class PanZoomBase : MonoBehaviour,
2727
/// Ability to pan using your eye gaze without any additional input (e.g., air tap or
2828
/// button presses).
2929
/// </summary>
30-
internal bool AutoGazePanIsActive = true;
30+
internal bool autoGazePanIsActive = true;
3131

3232
/// <summary>
3333
/// Horizontal panning speed. For example: 0.1f for slow panning. 0.6f for fast panning.
3434
/// </summary>
35-
internal float PanSpeedLeftRight; // Comment: This could be improved by using panning step sizes depending on the zoom level.
35+
internal float panSpeedLeftRight; // Comment: This could be improved by using panning step sizes depending on the zoom level.
3636

3737
/// <summary>
3838
/// Vertical panning speed. For example: 0.1f for slow panning. 0.6f for fast panning.
3939
/// </summary>
40-
internal float PanSpeedUpDown;
40+
internal float panSpeedUpDown;
4141

4242
/// <summary>
4343
/// Minimal distance in x and y from center of the target (0, 0) to trigger panning. Thus,
4444
/// values must range between 0 (always panning) and 0.5 (no panning).
4545
/// </summary>
46-
internal Vector2 MinDistFromCenterForAutoPan = new Vector2(0.2f, 0.2f);
46+
internal Vector2 minDistFromCenterForAutoPan = new Vector2(0.2f, 0.2f);
4747

4848
// ZOOM
4949
/// <summary>
@@ -68,11 +68,6 @@ public abstract class PanZoomBase : MonoBehaviour,
6868
/// </summary>
6969
internal float ZoomMaxScale = 1.0f;
7070

71-
/// <summary>
72-
/// Type of hand gesture to use for zooming
73-
/// </summary>
74-
internal MixedRealityInputAction ZoomGesture;
75-
7671
/// <summary>
7772
/// Size of the GameObject's collider when being looked at.
7873
/// </summary>
@@ -121,7 +116,7 @@ public abstract class PanZoomBase : MonoBehaviour,
121116
private Vector3 navPos = Vector3.zero;
122117
private bool isFocused = false;
123118
internal bool isZooming = false;
124-
public bool handZoomEnabledOnStartup = false;
119+
internal bool ZoomGestureEnabledOnStartup = false;
125120
private bool handZoomEnabled = false;
126121

127122
protected Vector3 originalRatio;
@@ -145,7 +140,7 @@ protected virtual void Start()
145140
{
146141
// Init children
147142
Initialize();
148-
handZoomEnabled = handZoomEnabledOnStartup;
143+
handZoomEnabled = ZoomGestureEnabledOnStartup;
149144
Initialize();
150145

151146
// Init eye tracking target
@@ -176,8 +171,8 @@ private Vector3 CustomColliderSizeOnLookAt
176171

177172
public void AutoPan()
178173
{
179-
PanHorizontally(ComputePanSpeed(cursorPos.x, PanSpeedLeftRight, MinDistFromCenterForAutoPan.x));
180-
PanVertically(ComputePanSpeed(cursorPos.y, PanSpeedUpDown, MinDistFromCenterForAutoPan.y));
174+
PanHorizontally(ComputePanSpeed(cursorPos.x, panSpeedLeftRight, minDistFromCenterForAutoPan.x));
175+
PanVertically(ComputePanSpeed(cursorPos.y, panSpeedUpDown, minDistFromCenterForAutoPan.y));
181176
}
182177

183178
/// <summary>
@@ -379,7 +374,7 @@ private void LateUpdate()
379374
/// </summary>
380375
private void AutomaticGazePanning()
381376
{
382-
if (AutoGazePanIsActive)
377+
if (autoGazePanIsActive)
383378
{
384379
AutoPan();
385380
}

Assets/MixedRealityToolkit.Examples/Demos/EyeTracking/Demo_ScrollPanZoom/Scripts/BaseClasses/PanZoomBase_RectTransf.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public override void ZoomIn()
5656
ZoomInOut_RectTransform(zoomDir * zoomSpeed, cursorPos);
5757

5858
// Panning across entire target (-0.5, +0.5) to move target of interest towards center while zooming in
59-
PanHorizontally(ComputePanSpeed(cursorPos.x, PanSpeedLeftRight, MinDistFromCenterForAutoPan.x));
60-
PanVertically(ComputePanSpeed(cursorPos.y, PanSpeedUpDown, MinDistFromCenterForAutoPan.y));
59+
PanHorizontally(ComputePanSpeed(cursorPos.x, panSpeedLeftRight, minDistFromCenterForAutoPan.x));
60+
PanVertically(ComputePanSpeed(cursorPos.y, panSpeedUpDown, minDistFromCenterForAutoPan.y));
6161
}
6262

6363
public override void ZoomOut()

Assets/MixedRealityToolkit.Examples/Demos/EyeTracking/Demo_ScrollPanZoom/Scripts/BaseClasses/PanZoomBase_Texture.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public string TextureShaderProperty
2626
}
2727
}
2828

29+
[Tooltip("Underlying aspect ratio of the loaded texture to correctly determine scaling.")]
2930
[SerializeField]
30-
private float DefaultAspectRatio = 1.0f;
31+
private float defaultAspectRatio = 1.0f;
3132

3233
private float aspectRatio = -1;
3334

@@ -37,7 +38,7 @@ public override void Initialize()
3738
{
3839
if (aspectRatio == -1)
3940
{
40-
Initialize(DefaultAspectRatio);
41+
Initialize(defaultAspectRatio);
4142
}
4243
else
4344
{
@@ -141,8 +142,8 @@ public override void ZoomIn()
141142
ZoomInOut(zoomDir * zoomSpeed, cursorPos);
142143

143144
// Panning across entire target (-0.5, +0.5) to move target of interest towards center while zooming in
144-
PanHorizontally(ComputePanSpeed(cursorPos.x, PanSpeedLeftRight, MinDistFromCenterForAutoPan.x));
145-
PanVertically(ComputePanSpeed(cursorPos.y, PanSpeedUpDown, MinDistFromCenterForAutoPan.y));
145+
PanHorizontally(ComputePanSpeed(cursorPos.x, panSpeedLeftRight, minDistFromCenterForAutoPan.x));
146+
PanVertically(ComputePanSpeed(cursorPos.y, panSpeedUpDown, minDistFromCenterForAutoPan.y));
146147
}
147148
}
148149

Assets/MixedRealityToolkit.Examples/Demos/EyeTracking/Demo_ScrollPanZoom/Scripts/PanZoom_RectTransf.cs

Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,107 @@ public class PanZoom_RectTransf : PanZoomBase_RectTransf
1313
{
1414
[Tooltip("RectTransform from, for example, your TextMeshPro game object.")]
1515
[SerializeField]
16-
private RectTransform RectTransfToNavigate = null;
16+
private RectTransform rectTransfToNavigate = null;
1717

1818
[Tooltip("Reference to the viewport restricting the viewbox. This is important for identifying the max constrains for panning.")]
1919
[SerializeField]
20-
private RectTransform RefToViewPort = null;
20+
private RectTransform refToViewPort = null;
2121

22-
// Scroll
23-
[Tooltip("Ability to scroll using your eye gaze without any additional input (e.g., air tap or button presses).")]
22+
// Zoom
23+
[Tooltip("Zoom acceleration defining the steepness of logistic speed function mapping.")]
2424
[SerializeField]
25-
private bool AutoGazeScrollIsActive = true;
25+
private float zoomAcceleration = 10f;
2626

27-
[Tooltip("Horizontal scroll speed. For example: 0.1f for slow panning. 0.6f for fast panning.")]
27+
[Tooltip("Maximum zoom speed.")]
2828
[SerializeField]
29-
private float ScrollSpeed_x = 0.2f;
29+
private float zoomSpeedMax = 0.02f;
3030

31-
[Tooltip("Vertical scroll speed. For example: 0.1f for slow panning. 0.6f for fast panning.")]
31+
[Tooltip("Minimum scale of the texture for zoom in - e.g., 0.5f (half the original size)")]
3232
[SerializeField]
33-
private float ScrollSpeed_y = 0.2f;
33+
private float zoomMinScale = 0.1f;
3434

35-
[Tooltip("Minimal distance in x and y from center of the target's hit box (0, 0) to scroll. Thus, values must range between 0 (always scroll) and 0.5 (no scroll).")]
35+
[Tooltip("Maximum scale of the texture for zoom out - e.g., 1f (the original size) or 2.0f (double the original size).")]
3636
[SerializeField]
37-
private Vector2 MinDistFromCenterForAutoScroll = new Vector2(0.2f, 0.2f);
37+
private float zoomMaxScale = 1.0f;
3838

39-
[Tooltip("Set to true to prevent sudden scrolling when quickly looking around. This may make scrolling feel less responsive though.")]
39+
[Tooltip("Timed zoom: Once triggered, a zoom in/out will be performed for the given amount of time in seconds.")]
4040
[SerializeField]
41-
private bool UseSkimProofing = false;
41+
private float zoomTimeInSecToZoom = 0.5f;
4242

43-
[Tooltip("The lower the value, the slower the scrolling will speed up after skimming. Recommended value: 5.")]
43+
[Tooltip("Enable or disable hand gestures for zooming on startup.")]
4444
[SerializeField]
45-
[Range(0, 10)]
46-
private float SkimProofUpdateSpeed = 5f;
45+
private bool zoomGestureEnabledOnStartup = false;
4746

48-
// Zoom
49-
[Tooltip("Zoom acceleration defining the steepness of logistic speed function mapping.")]
47+
// Pan
48+
[Tooltip("Ability to scroll using your eye gaze without any additional input (e.g., air tap or button presses).")]
5049
[SerializeField]
51-
private float Zoom_Acceleration = 10f;
50+
private bool panAutoScrollIsActive = true;
5251

53-
[Tooltip("Maximum zoom speed.")]
52+
[Tooltip("Horizontal scroll speed. For example: 0.1f for slow panning. 0.6f for fast panning.")]
5453
[SerializeField]
55-
private float Zoom_SpeedMax = 0.02f;
54+
private float panSpeedHorizontal = 0.3f;
5655

57-
[Tooltip("Minimum scale of the texture for zoom in - e.g., 0.5f (half the original size)")]
56+
[Tooltip("Vertical scroll speed. For example: 0.1f for slow panning. 0.6f for fast panning.")]
5857
[SerializeField]
59-
private float Zoom_MinScale = 0.1f;
58+
private float panSpeedVertical = 0.3f;
6059

61-
[Tooltip("Maximum scale of the texture for zoom out - e.g., 1f (the original size) or 2.0f (double the original size).")]
60+
[Tooltip("Minimal distance in x and y from center of the target's hit box (0, 0) to scroll. Thus, values must range between 0 (always scroll) and 0.5 (no scroll).")]
6261
[SerializeField]
63-
private float Zoom_MaxScale = 1.0f;
62+
private Vector2 panMinDistFromCenter = new Vector2(0.2f, 0.2f);
6463

65-
[Tooltip("Timed zoom: Once triggered, a zoom in/out will be performed for the given amount of time in seconds.")]
64+
[Tooltip("Set to true to prevent sudden scrolling when quickly looking around. This may make scrolling feel less responsive though.")]
6665
[SerializeField]
67-
private float Zoom_TimeInSecToZoom = 0.5f;
66+
private bool useSkimProofing = false;
6867

69-
[Tooltip("Type of hand gesture to use to zoom in/out.")]
68+
[Tooltip("The lower the value, the slower the scrolling will speed up after skimming. Recommended value: 5.")]
7069
[SerializeField]
71-
private MixedRealityInputAction Zoom_Gesture = MixedRealityInputAction.None;
72-
73-
// The base PanAndZoom class can also be used with UV textures for which the dimensions are different to a RectTransform.
74-
// To allow to keep the speed values that users can assign consistent, let's internally convert the values.
75-
private float convertSpeedToUVSpace = -200.0f;
70+
[Range(0, 10)]
71+
private float skimProofUpdateSpeed = 5f;
7672

7773
protected override void Start()
7874
{
7975
// Assigning values to base PanZoom class
80-
AutoGazePanIsActive = AutoGazeScrollIsActive;
81-
PanSpeedLeftRight = ScrollSpeed_x * convertSpeedToUVSpace;
82-
PanSpeedUpDown = ScrollSpeed_y * convertSpeedToUVSpace;
83-
MinDistFromCenterForAutoPan = MinDistFromCenterForAutoScroll;
84-
useSkimProof = UseSkimProofing;
76+
// Zoom
77+
ZoomAcceleration = zoomAcceleration;
78+
ZoomSpeedMax = zoomSpeedMax;
79+
ZoomMinScale = zoomMinScale;
80+
ZoomMaxScale = zoomMaxScale;
81+
ZoomGestureEnabledOnStartup = zoomGestureEnabledOnStartup;
82+
timeInSecondsToZoom = zoomTimeInSecToZoom;
83+
84+
// Pan
85+
autoGazePanIsActive = panAutoScrollIsActive;
86+
panSpeedLeftRight = panSpeedHorizontal;
87+
panSpeedUpDown = panSpeedVertical;
88+
minDistFromCenterForAutoPan = panMinDistFromCenter;
89+
useSkimProof = useSkimProofing;
8590

8691
// Set up rect transform
87-
viewportRectTransf = RefToViewPort;
88-
navRectTransf = RectTransfToNavigate;
92+
viewportRectTransf = refToViewPort;
93+
navRectTransf = rectTransfToNavigate;
8994
navRectTransf.anchorMin = new Vector2(0.5f, 0.5f);
9095
navRectTransf.anchorMax = new Vector2(0.5f, 0.5f);
9196
navRectTransf.pivot = new Vector2(0.5f, 0.5f);
9297

93-
// Zoom
94-
ZoomAcceleration = Zoom_Acceleration;
95-
ZoomSpeedMax = Zoom_SpeedMax;
96-
ZoomMinScale = Zoom_MinScale;
97-
ZoomMaxScale = Zoom_MaxScale;
98-
ZoomGesture = Zoom_Gesture;
99-
timeInSecondsToZoom = Zoom_TimeInSecToZoom;
100-
10198
base.Start();
10299
}
103100

104101
protected override void Update()
105102
{
106-
UpdateValues(ref navRectTransf, RectTransfToNavigate);
107-
UpdateValues(ref ZoomAcceleration, Zoom_Acceleration);
108-
UpdateValues(ref ZoomSpeedMax, Zoom_SpeedMax);
109-
UpdateValues(ref ZoomMinScale, Zoom_MinScale);
110-
UpdateValues(ref ZoomMaxScale, Zoom_MaxScale);
111-
UpdateValues(ref ZoomGesture, Zoom_Gesture);
112-
UpdateValues(ref timeInSecondsToZoom, Zoom_TimeInSecToZoom);
113-
114-
UpdateValues(ref AutoGazePanIsActive, AutoGazeScrollIsActive);
115-
UpdateValues(ref PanSpeedLeftRight, ScrollSpeed_x * convertSpeedToUVSpace);
116-
UpdateValues(ref PanSpeedUpDown, ScrollSpeed_y * convertSpeedToUVSpace);
117-
UpdateValues(ref MinDistFromCenterForAutoPan, MinDistFromCenterForAutoScroll);
118-
UpdateValues(ref useSkimProof, UseSkimProofing);
119-
120-
if (UpdateValues(ref skimproof_UpdateSpeedFromUser, SkimProofUpdateSpeed))
103+
UpdateValues(ref navRectTransf, rectTransfToNavigate);
104+
UpdateValues(ref ZoomAcceleration, zoomAcceleration);
105+
UpdateValues(ref ZoomSpeedMax, zoomSpeedMax);
106+
UpdateValues(ref ZoomMinScale, zoomMinScale);
107+
UpdateValues(ref ZoomMaxScale, zoomMaxScale);
108+
UpdateValues(ref timeInSecondsToZoom, zoomTimeInSecToZoom);
109+
110+
UpdateValues(ref autoGazePanIsActive, panAutoScrollIsActive);
111+
UpdateValues(ref panSpeedLeftRight, panSpeedHorizontal);
112+
UpdateValues(ref panSpeedUpDown, panSpeedVertical);
113+
UpdateValues(ref minDistFromCenterForAutoPan, panMinDistFromCenter);
114+
UpdateValues(ref useSkimProof, useSkimProofing);
115+
116+
if (UpdateValues(ref skimproof_UpdateSpeedFromUser, skimProofUpdateSpeed))
121117
{
122118
SetSkimProofUpdateSpeed(skimproof_UpdateSpeedFromUser);
123119
}

0 commit comments

Comments
 (0)