Skip to content

Commit 01c7b2b

Browse files
authored
Merge pull request #2 from arnebp/master
Release 1.1.0.0
2 parents 9e1a6a5 + 1c4f538 commit 01c7b2b

247 files changed

Lines changed: 7624 additions & 12379 deletions

File tree

Some content is hidden

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

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log #
22
---
33

4+
Version 1.1.0.0 (2016-09-26)
5+
---
6+
7+
- Scene flow and interaction improvements
8+
- Project Restructuring for easier export/import
9+
- New key input mapping
10+
- Updated EyeTribe C# SDK dependency to v.0.9.77.5
11+
412
Version 1.0.0.1 (2016-06-07)
513
---
614

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is a collection of tools and utilities for [EyeTribe Dev Kit](https://thee
88

99
An [EyeTribe Tracker](https://theeyetribe.com/products/) or [EyeTribe VR Tracker](https://theeyetribe.com/wp-content/uploads/2016/01/vr-product-sheet.pdf) is required to use this library. This dev kit supports both ***remote eye-tracking*** and ***vr eye-tracking***.
1010

11-
Developed for and tested against [Unity 5.4b20](https://unity3d.com/unity/beta). **Note:** This is a Unity **BETA** version.
11+
Developed for and tested against [Unity 5.4.1](https://store.unity.com/download?ref=update).
1212

1313
Prerequisites
1414
----
@@ -39,33 +39,35 @@ Build for desired target platform using Unity Build Settings.
3939

4040
Keyboard:
4141

42+
- Fire1: Left Ctrl
43+
- Fire2: Left Alt
44+
- Fire3: Left Shift
45+
- Fire4: Space
4246
- Esc: Exit app
4347
- 1: Show/Hide GazeIndicator
4448
- 2: Toggle raw/smooth gaze data
45-
- 3: Show/Hide debug output
49+
- 3: Show/Hide Gaze Info
4650
- 4: Show/Hide CalibrationArea
4751
- 5: Reduce CalibrationArea Width
4852
- 6: Increase CalibrationArea Width
4953
- 7: Reduce CalibrationArea Height
5054
- 8: Increase CalibrationArea Height
51-
- Space: Start Calibration
52-
- Return/enter: Start next scene (if calibrated)
53-
- Control/Command: Select (interaction scene)
5455

5556
GamePad:
5657

57-
- Fire1/X: Start Calibration *or* Select (interaction scene)
58-
- Fire2/Y: Start next scene (if calibrated)
59-
- Fire3/A: Show/Hide GazeIndicator
60-
- Fire4/B: Show/Hide debug output
61-
- Back: Go one scene back or exit
58+
- Fire1: X Button
59+
- Fire2: Y Button
60+
- Fire3: A Button, Show/Hide GazeIndicator
61+
- Fire4: B Button, Show/Hide Gaze Info
62+
- Back: Go Back or Exit
6263

6364
GearVR Touchpad:
6465

65-
- Back: Go one scene back or exit
66-
- Horizontal Swipe: Start Start Calibration
67-
- Vertical Swipe: Show/Hide debug output
68-
- Tap: Start next scene (if calibrated) *or* Select (interaction scene)
66+
- Fire1: Tap
67+
- Fire2: Swipe Down
68+
- Fire3: Swipe Back, Show/Hide GazeIndicator
69+
- Fire4: Double-Tap, Show/Hide Gaze Info
70+
- Back: Go Back or Exit
6971

7072

7173
Unity-Commons
@@ -79,7 +81,7 @@ Find the latest ***EyeTribe.Unity.dll*** under [releases](https://github.com/Eye
7981

8082
Should you choose extend this library and build it yourself, the project needs to know your Unity installation path. To set this up, open the project file *'./unity-commons/commons/unity-commons.csproj'* with a text editor. Then modify the property *$(YourUnityFolder)* to the path of your Unity installation.
8183

82-
<YourUnityFolder>C:\Program Files\Unity 5.4b20\</YourUnityFolder>
84+
<YourUnityFolder>C:\Program Files\Unity\</YourUnityFolder>
8385

8486
Open the project in [Visual Studio Express 2013](https://www.microsoft.com/en-us/download/details.aspx?id=44914) or similar and build. Note that [.Net Framwork 3.5 SP1](https://www.microsoft.com/en-us/download/details.aspx?id=22) is a requirement to build a Unity supported library.
8587

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="EyeTribe.ClientSdk" version="0.9.77.2" targetFramework="net35" />
3+
<package id="EyeTribe.ClientSdk" version="0.9.77.5" targetFramework="net35" />
44
<package id="ILRepack.MSBuild.Task" version="1.0.9" targetFramework="net35" />
5-
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net35" />
5+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net35" />
66
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
77
</packages>

unity-commons/commons/scripts/CanvasUtils.cs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,7 @@
1313
namespace EyeTribe.Unity
1414
{
1515
public class CanvasUtils
16-
{
17-
public static void SetRendererEnabled(RectTransform rt, bool isEnabled)
18-
{
19-
if (null != rt)
20-
{
21-
UIBehaviour[] uis = rt.GetComponentsInChildren<UIBehaviour>();
22-
foreach (UIBehaviour uib in uis)
23-
{
24-
uib.enabled = isEnabled;
25-
}
26-
}
27-
}
28-
29-
public static bool IsRendererEnabled(RectTransform rt)
30-
{
31-
if (null != rt)
32-
return rt.GetComponent<UIBehaviour>().enabled;
33-
return false;
34-
}
35-
16+
{
3617
public static RectTransform GetUiComponentFromTag(Canvas canvas, String tag)
3718
{
3819
RectTransform[] components = canvas.GetComponentsInChildren<RectTransform>();

unity-commons/commons/scripts/ExtensionMethods.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ public static Vector3 ToVec3(this Point2D gp)
123123
return new Vector3((float)gp.X, (float)gp.Y, 0f);
124124
}
125125

126+
public static Vector3 GetWorldPositionFromGaze(this Point2D gp, Camera cam, float depth)
127+
{
128+
if (null != cam)
129+
{
130+
return cam.ScreenToWorldPoint(
131+
new Vector3(
132+
(float)gp.X,
133+
(float)(cam.pixelHeight - gp.Y),
134+
depth)
135+
);
136+
}
137+
138+
return Vector3.zero;
139+
}
140+
126141
#endregion
127142

128143
#region Point3D Extensions
@@ -263,11 +278,27 @@ public static RectTransform GetChildRectTransformFromTag(this Canvas canvas, str
263278

264279
#region Camera Extensions
265280

281+
/// <summary>
282+
/// Find the bounds of the Camera viewport in Unity units (meters) at a desired distance.
283+
/// </summary>
284+
/// <param name="depth"/>distance from camera to use</param>
285+
/// <returns>Unity Vector2</returns>
266286
public static Vector2 GetPerspectiveWorldScreenBounds(this Camera camera, float depth)
287+
{
288+
return GetPerspectiveDegreeBounds(camera, camera.fieldOfView, depth);
289+
}
290+
291+
/// <summary>
292+
/// Find the bounds of custom Camera viewport in Unity units (meters) at a desired distance.
293+
/// </summary>
294+
/// <param name="degrees"/>width of custom fov in degrees</param>
295+
/// <param name="depth"/>distance from camera to use</param>
296+
/// <returns>Unity Vector2</returns>
297+
public static Vector2 GetPerspectiveDegreeBounds(this Camera camera, float degrees, float depth)
267298
{
268299
Vector3 position = camera.transform.position + camera.transform.forward * depth;
269300

270-
float h = Mathf.Tan(camera.fieldOfView * Mathf.Deg2Rad * 0.5f) * depth * 2f;
301+
float h = Mathf.Tan(degrees * Mathf.Deg2Rad * 0.5f) * depth * 2f;
271302

272303
return new Vector2(h * camera.aspect, h);
273304
}

unity-commons/commons/scripts/EyeTribeSDK.cs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919

2020
namespace EyeTribe.Unity
2121
{
22-
public class EyeTribeSDK : MonoBehaviour, IGazeListener, IConnectionStateListener, ITrackerStateListener, ICalibrationResultListener
22+
public class EyeTribeSDK : MonoBehaviour, IGazeListener, IConnectionStateListener, ITrackerStateListener,
23+
ICalibrationResultListener, ICalibrationStateListener
2324
{
2425
public static event Action<bool> OnConnectionStateChange;
2526
public static event Action<GazeManager.TrackerState> OnTrackerStateChange;
26-
public static event Action<bool, CalibrationResult> OnCalibration;
27+
public static event Action<bool, CalibrationResult> OnCalibrationResult;
28+
public static event Action<bool, bool> OnCalibrationStateChange;
2729

2830
[SerializeField]private UnityDispatcher _Dispatcher;
2931

3032
private const string DEFAULT_CFG = "network.cfg";
3133

34+
private IEnumerator _FrameCacheUpdater;
35+
3236
void Awake()
3337
{
3438
if (null == _Dispatcher)
@@ -42,6 +46,7 @@ void OnEnable()
4246
GazeManager.Instance.AddTrackerStateListener(this);
4347
GazeManager.Instance.AddCalibrationResultListener(this);
4448
GazeManager.Instance.AddConnectionStateListener(this);
49+
GazeManager.Instance.AddCalibrationStateListener(this);
4550

4651
//activate EyeTribe C# SDK, default port
4752
if (!GazeManager.Instance.IsActivated)
@@ -62,21 +67,27 @@ void OnEnable()
6267
GazeManager.Instance.ActivateAsync(GazeManager.ApiVersion.VERSION_1_0, ip, 6555);
6368
}
6469
}
70+
71+
StartCoroutine(_FrameCacheUpdater = BalancedUpdater());
6572
}
6673

6774
void OnDisable()
6875
{
76+
if (null != _FrameCacheUpdater)
77+
StopCoroutine(_FrameCacheUpdater);
78+
6979
//deregister listeners
7080
GazeManager.Instance.RemoveGazeListener(this);
7181
GazeManager.Instance.RemoveTrackerStateListener(this);
7282
GazeManager.Instance.RemoveCalibrationResultListener(this);
7383
GazeManager.Instance.RemoveConnectionStateListener(this);
84+
GazeManager.Instance.RemoveCalibrationStateListener(this);
7485
}
7586

7687
public void OnGazeUpdate(GazeData gazeData)
7788
{
7889
//Add frame to GazeData cache handler
79-
GazeFrameCache.Instance.Update(gazeData);
90+
GazeFrameCache.Instance.Enqueue(gazeData);
8091
}
8192

8293
void OnApplicationQuit()
@@ -106,11 +117,31 @@ public void OnCalibrationChanged(bool isCalibrated, CalibrationResult calibResul
106117
{
107118
_Dispatcher.Dispatch(() =>
108119
{
109-
if (OnCalibration != null)
110-
OnCalibration(isCalibrated, calibResult);
120+
if (OnCalibrationResult != null)
121+
OnCalibrationResult(isCalibrated, calibResult);
122+
});
123+
}
124+
125+
126+
public void OnCalibrationStateChanged(bool isCalibrating, bool isCalibrated)
127+
{
128+
_Dispatcher.Dispatch(() =>
129+
{
130+
if (OnCalibrationStateChange != null)
131+
OnCalibrationStateChange(isCalibrating, isCalibrated);
111132
});
112133
}
113134

135+
private IEnumerator BalancedUpdater()
136+
{
137+
while(enabled)
138+
{
139+
GazeFrameCache.Instance.Update();
140+
141+
yield return new WaitForSeconds(Time.smoothDeltaTime / 1f);
142+
}
143+
}
144+
114145
public String GetExternalFilePath(string fileName)
115146
{
116147
String extPath = null;

unity-commons/commons/scripts/EyeTribeUnityScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class EyeTribeUnityScript : MonoBehaviour, IGazeListener
2929
public virtual void Awake()
3030
{
3131
//turn off VR if no VR device present
32-
_UsingVR = VRMode.IsRunningInVRMode();
32+
_UsingVR = VRMode.IsRunningInVRMode;
3333
}
3434

3535
public virtual void OnEnable()

unity-commons/commons/scripts/FrameRateGazeDataQueue.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,22 @@ namespace EyeTribe.Unity
2323
public class FrameRateGazeDataQueue : GazeDataQueue
2424
{
2525
private readonly static long BUFFER_SIZE_MILLIS = 5000;
26-
private readonly static long BUFFER_SIZE_MIN = BUFFER_SIZE_MILLIS / 2;
2726

2827
public FrameRateGazeDataQueue()
2928
: base(BUFFER_SIZE_MILLIS)
3029
{
3130
}
31+
32+
public FrameRateGazeDataQueue(long timeLimit)
33+
: base(timeLimit)
34+
{
35+
}
3236

3337
public float GetAvgFramesPerSecond()
3438
{
3539
float avgMillis;
3640
if ((avgMillis = GetAvgMillisFrame()) > 0)
37-
return 1000 / avgMillis;
41+
return 1000f / avgMillis;
3842

3943
return -1;
4044
}
@@ -51,12 +55,12 @@ public float GetAvgMillisFrame()
5155
float delta = last.TimeStamp - first.TimeStamp;
5256

5357
// only return value when buffer populated
54-
if (delta > BUFFER_SIZE_MIN)
58+
if (delta > (TimeLimit >> 1))
5559
return delta / this.Count();
5660
}
5761
}
5862

59-
return 0f;
63+
return -1;
6064
}
6165
}
6266
}

unity-commons/commons/scripts/GazeFPS.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ public float AvgFPS
4646
return 0f;
4747
}
4848
}
49-
5049
}
5150
}

0 commit comments

Comments
 (0)