diff --git a/UnityExamples/Assets/Plugins/Android/google-unity-wrapper/bin/google-unity-wrapper.jar b/UnityExamples/Assets/Plugins/Android/google-unity-wrapper/bin/google-unity-wrapper.jar
index 608d1902..36fc3146 100644
Binary files a/UnityExamples/Assets/Plugins/Android/google-unity-wrapper/bin/google-unity-wrapper.jar and b/UnityExamples/Assets/Plugins/Android/google-unity-wrapper/bin/google-unity-wrapper.jar differ
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/AndroidManifest.xml b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/AndroidManifest.xml
index 3f07b937..bfa61674 100644
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/AndroidManifest.xml
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/AndroidManifest.xml
@@ -20,7 +20,7 @@
android:versionName="0" >
\ No newline at end of file
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/R.txt b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/R.txt
index a7663cd1..43bd9079 100644
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/R.txt
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/R.txt
@@ -1,14 +1,14 @@
int color gray_dark 0x7f040000
-int color tango_blue 0x7f040001
-int color tango_green 0x7f040002
-int color tango_yellow 0x7f040003
-int color text_exception_action_required 0x7f040004
-int color text_exception_description 0x7f040005
+int color tango_blue 0x7f040004
+int color tango_green 0x7f040003
+int color tango_yellow 0x7f040005
+int color text_exception_action_required 0x7f040002
+int color text_exception_description 0x7f040001
int dimen connection_progress_bar_sub_margin 0x7f050000
int dimen exception_component_height 0x7f050001
int dimen exception_status_component_size 0x7f050002
-int dimen hold_steady_bubble_level_max_y 0x7f050003
-int dimen hold_steady_frame_transform_pivot_y 0x7f050004
+int dimen hold_steady_bubble_level_max_y 0x7f050004
+int dimen hold_steady_frame_transform_pivot_y 0x7f050003
int dimen hold_steady_trace_size 0x7f050005
int drawable exception_container_shadow 0x7f020000
int drawable hold_steady_bubble_level_err 0x7f020001
@@ -28,14 +28,15 @@ int id bubble_level_err 0x7f080006
int id bubble_level_group 0x7f080005
int id bubble_level_ok 0x7f080007
int id component_hold_steady 0x7f08000c
-int id connection_layout 0x7f08000f
-int id exception_container 0x7f08000e
+int id connection_layout 0x7f080010
+int id connection_layout_title 0x7f08000d
+int id exception_container 0x7f08000f
int id exception_description 0x7f08000a
int id exception_icon 0x7f080008
int id exception_status 0x7f08000b
int id exception_title 0x7f080009
int id frame 0x7f080004
-int id splash_logo 0x7f08000d
+int id splash_logo 0x7f08000e
int id trace_left_1 0x7f080002
int id trace_left_2 0x7f080000
int id trace_right_1 0x7f080003
@@ -45,37 +46,43 @@ int layout exception_component 0x7f030001
int layout layout_connection 0x7f030002
int layout layout_splash 0x7f030003
int layout layout_tango_ux 0x7f030004
-int string action_required 0x7f060000
-int string connection_layout_message 0x7f060001
-int string device_not_responding_description 0x7f060002
-int string device_not_responding_title 0x7f060003
-int string lying_on_surface_description 0x7f060004
-int string lying_on_surface_title 0x7f060005
-int string motion_track_description 0x7f060006
-int string motion_track_title 0x7f060007
-int string moving_too_fast_description 0x7f060008
-int string moving_too_fast_title 0x7f060009
-int string not_enough_light_description 0x7f06000a
-int string not_enough_light_title 0x7f06000b
-int string project_tango 0x7f06000c
-int string run_time_mismatch_description 0x7f06000d
-int string run_time_mismatch_title 0x7f06000e
-int string service_updated_description 0x7f06000f
-int string service_updated_title 0x7f060010
-int string space_not_recognized_description 0x7f060011
-int string space_not_recognized_title 0x7f060012
-int string too_much_light_description 0x7f060013
-int string too_much_light_title 0x7f060014
-int string unable_to_detect_surface_description 0x7f060015
-int string unable_to_detect_surface_title 0x7f060016
-int style ConnectionLayoutSubtext 0x7f070000
-int style ConnectionLayoutText 0x7f070001
-int style DownloadProgressText 0x7f070002
-int style ExceptionActionRequired 0x7f070003
-int style ExceptionDescription 0x7f070004
+int string action_required 0x7f060017
+int string connection_layout_message_still 0x7f060018
+int string connection_layout_message_tight 0x7f060019
+int string device_not_responding_description 0x7f06000c
+int string device_not_responding_title 0x7f06000b
+int string hold_posture_description 0x7f060016
+int string hold_posture_down 0x7f06001c
+int string hold_posture_forward 0x7f06001a
+int string hold_posture_title 0x7f060015
+int string hold_posture_up 0x7f06001b
+int string lying_on_surface_description 0x7f060010
+int string lying_on_surface_title 0x7f06000f
+int string motion_track_description 0x7f060012
+int string motion_track_title 0x7f060011
+int string moving_too_fast_description 0x7f060002
+int string moving_too_fast_title 0x7f060001
+int string not_enough_light_description 0x7f060008
+int string not_enough_light_title 0x7f060007
+int string project_tango 0x7f060000
+int string run_time_mismatch_description 0x7f060014
+int string run_time_mismatch_title 0x7f060013
+int string service_updated_description 0x7f06000e
+int string service_updated_title 0x7f06000d
+int string space_not_recognized_description 0x7f060006
+int string space_not_recognized_title 0x7f060005
+int string too_much_light_description 0x7f06000a
+int string too_much_light_title 0x7f060009
+int string unable_to_detect_surface_description 0x7f060004
+int string unable_to_detect_surface_title 0x7f060003
+int style ConnectionLayoutSubtext 0x7f070003
+int style ConnectionLayoutText 0x7f070002
+int style DownloadProgressText 0x7f070004
+int style ExceptionActionRequired 0x7f070007
+int style ExceptionDescription 0x7f070006
int style ExceptionTitle 0x7f070005
-int style Text20GrayDarkLight 0x7f070006
-int style Text40GrayDarkThin 0x7f070007
-int style TextListContentItem 0x7f070008
-int style TextListTitle 0x7f070009
-int style TextListTitleItem 0x7f07000a
+int style Text20GrayDarkLight 0x7f070001
+int style Text40GrayDarkThin 0x7f070000
+int style TextListContentItem 0x7f07000a
+int style TextListTitle 0x7f070008
+int style TextListTitleItem 0x7f070009
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/tango-ux-support-library.jar b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/tango-ux-support-library.jar
index b3e8347d..fb6a6352 100644
Binary files a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/tango-ux-support-library.jar and b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/bin/tango-ux-support-library.jar differ
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/project.properties b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/project.properties
index 19469c2c..f5c58814 100755
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/project.properties
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/project.properties
@@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-21
+target=android-19
android.library=true
-android.library.reference.1=../tango-java-lib
+android.library.reference.1=../tango_java_lib
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/layout/layout_connection.xml b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/layout/layout_connection.xml
index e8c8455a..b1783775 100755
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/layout/layout_connection.xml
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/layout/layout_connection.xml
@@ -32,10 +32,11 @@
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/dimens.xml b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/dimens.xml
index 39c1510f..73b2fbd8 100755
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/dimens.xml
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/dimens.xml
@@ -22,7 +22,7 @@
30dp
110dp
- -30dp
+ 30dp
112dp
diff --git a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/strings.xml b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/strings.xml
index f0e8acd0..306c7805 100755
--- a/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/strings.xml
+++ b/UnityExamples/Assets/Plugins/Android/tango-ux-support-library/res/values/strings.xml
@@ -23,36 +23,45 @@
Too fast.
Slow down and hold device steady.
- Few depth points.
- Keep objects to be scanned in the range of 0.5 – 4 meters.
-
+ Nothing detected.
+ Keep the device at least an arm’s length from objects.
+
Space not recognized.
- Avoid pointing at environments with few features.
-
- Not enough light.
- Make sure nothing is blocking camera or light.
+ Point the device somewhere else.
+
+ Too dark.
+ Use the device in well-lit areas.
- Too much light.
+ Too bright.
Avoid pointing at bright lights.
- Tango Service Crash.
- Exit the application or reboot your device.
+ System unavailable.
+ Restart the app or reboot the device.
- Library Mismatch.
- Update your Tango Service to the latest version.
+ Incompatible version.
+ Update to the latest Project Tango Core.
- Lying on surface.
+ Camera blocked.
Pick up the device to continue.
- Motion Tracking lost.
- Hold steady and wait for system to recover.
+ Tracking lost.
+ Hold steady to let the system recover.
- Runtime Mismatch.
- Go to system setting and use ART as runtime.
+ Incorrect configuration.
+ Go to Settings > Developer options and select “Use ART”.
+ Incorrect tilt.
+ Point the device %s.
+
Action required
- Hold steady
+ Hold still
+ Hold tight
+
+
+ forward
+ up
+ down
-
\ No newline at end of file
+
diff --git a/UnityExamples/Assets/Scenes/ExperimentalAugmentedReality.unity b/UnityExamples/Assets/Scenes/ExperimentalAugmentedReality.unity
index ae01dde1..2ad2daa4 100644
--- a/UnityExamples/Assets/Scenes/ExperimentalAugmentedReality.unity
+++ b/UnityExamples/Assets/Scenes/ExperimentalAugmentedReality.unity
@@ -200,7 +200,7 @@ Camera:
width: 1
height: 1
near clip plane: .0500000007
- far clip plane: 100
+ far clip plane: 4
field of view: 37.7999992
orthographic: 0
orthographic size: 5
@@ -240,6 +240,10 @@ Prefab:
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
+ - target: {fileID: 11493252, guid: 5f59b9945461344cebfcccf17cdc53f9, type: 2}
+ propertyPath: m_enableOcclusion
+ value: 0
+ objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 5f59b9945461344cebfcccf17cdc53f9, type: 2}
m_IsPrefabParent: 0
@@ -297,7 +301,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1065599727}
m_LocalRotation: {x: -.707106829, y: 0, z: 0, w: .707106709}
- m_LocalPosition: {x: 0, y: 0, z: 15.1000004}
+ m_LocalPosition: {x: 0, y: 0, z: 3.99000001}
m_LocalScale: {x: 1.60000002, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 535930854}
diff --git a/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/AreaLearningFPSCounter.cs b/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/AreaLearningFPSCounter.cs
index 303dec77..61d3f9f1 100644
--- a/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/AreaLearningFPSCounter.cs
+++ b/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/AreaLearningFPSCounter.cs
@@ -75,10 +75,10 @@ private void OnGUI()
Color oldColor = GUI.color;
GUI.color = Color.black;
- GUI.Label(new Rect(Common.UI_LABEL_START_X,
- Common.UI_FPS_LABEL_START_Y,
- Common.UI_LABEL_SIZE_X,
- Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + m_FPSText + "");
+ GUI.Label(new Rect(AreaLearningGUIController.UI_LABEL_START_X,
+ AreaLearningGUIController.UI_FPS_LABEL_START_Y,
+ AreaLearningGUIController.UI_LABEL_SIZE_X,
+ AreaLearningGUIController.UI_LABEL_SIZE_Y), AreaLearningGUIController.UI_FONT_SIZE + m_FPSText + "");
GUI.color = oldColor;
}
diff --git a/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/SaveADFController.cs b/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/SaveADFController.cs
index c0ba0a98..b926a971 100644
--- a/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/SaveADFController.cs
+++ b/UnityExamples/Assets/TangoExamples/AreaLearning/Scripts/SaveADFController.cs
@@ -60,10 +60,10 @@ private void OnGUI()
{
if (m_tangoApplication.m_enableAreaLearning)
{
- if (GUI.Button(new Rect(Common.UI_BUTTON_GAP_X,
- Screen.height - (Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y), "Save ADF"))
+ if (GUI.Button(new Rect(AreaLearningGUIController.UI_BUTTON_GAP_X,
+ Screen.height - (AreaLearningGUIController.UI_BUTTON_SIZE_Y + AreaLearningGUIController.UI_LABEL_GAP_Y),
+ AreaLearningGUIController.UI_BUTTON_SIZE_X,
+ AreaLearningGUIController.UI_BUTTON_SIZE_Y), "Save ADF"))
{
m_keyboardState = KeyboardState.OPEN;
}
diff --git a/UnityExamples/Assets/TangoExamples/Common/Scripts/SceneSwitcher.cs b/UnityExamples/Assets/TangoExamples/Common/Scripts/SceneSwitcher.cs
index 0839ae9f..56f0541e 100644
--- a/UnityExamples/Assets/TangoExamples/Common/Scripts/SceneSwitcher.cs
+++ b/UnityExamples/Assets/TangoExamples/Common/Scripts/SceneSwitcher.cs
@@ -28,6 +28,8 @@ public class SceneSwitcher : MonoBehaviour
{
private const int SCENE_BUTTON_SIZE_X = 250;
private const int SCENE_BUTTON_SIZE_Y = 65;
+ private const int SCENE_BUTTON_GAP_X = 5;
+ private const int SCENE_BUTTON_GAP_Y = 3;
///
/// The names of all the scenes this can switch between.
@@ -46,8 +48,8 @@ private void OnGUI()
{
for (int it = 0; it < m_sceneNames.Length; ++it)
{
- Rect buttonRect = new Rect(Screen.width - Common.UI_BUTTON_GAP_X - SCENE_BUTTON_SIZE_X,
- Common.UI_LABEL_GAP_Y + ((Common.UI_LABEL_GAP_Y + SCENE_BUTTON_SIZE_Y) * it),
+ Rect buttonRect = new Rect(Screen.width - SCENE_BUTTON_GAP_X - SCENE_BUTTON_SIZE_X,
+ SCENE_BUTTON_GAP_Y + ((SCENE_BUTTON_GAP_Y + SCENE_BUTTON_SIZE_Y) * it),
SCENE_BUTTON_SIZE_X,
SCENE_BUTTON_SIZE_Y);
if (GUI.Button(buttonRect, "" + m_sceneNames[it] + ""))
diff --git a/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Scripts/ARScreen.cs b/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Scripts/ARScreen.cs
index f633a255..f405748c 100644
--- a/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Scripts/ARScreen.cs
+++ b/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Scripts/ARScreen.cs
@@ -329,8 +329,9 @@ private void _SetCameraIntrinsics()
}
///
- /// Create a projection matrix from window size, camera intrinsics, and clip settings.
+ /// Compute a projection matrix from window size, camera intrinsics, and clip settings.
///
+ /// Projection matrix.
/// The width of the camera image.
/// The height of the camera image.
/// The x-axis focal length of the camera.
@@ -342,42 +343,44 @@ private void _SetCameraIntrinsics()
private Matrix4x4 ProjectionMatrixForCameraIntrinsics(float width, float height,
float fx, float fy,
float cx, float cy,
- float near, float far) {
+ float near, float far)
+ {
float xscale = near / fx;
float yscale = near / fy;
- float xoffset = (cx - (width / 2.0f)) * xscale;
+ float xoffset = (cx - (width / 2.0f)) * xscale;
+
// OpenGL coordinates has y pointing downwards so we negate this term.
float yoffset = -(cy - (height / 2.0f)) * yscale;
- return Frustum(xscale * -width / 2.0f - xoffset,
- xscale * width / 2.0f - xoffset,
- yscale * -height / 2.0f - yoffset,
- yscale * height / 2.0f - yoffset,
- near, far);
+ return Frustum((xscale * -width / 2.0f) - xoffset,
+ (xscale * +width / 2.0f) - xoffset,
+ (yscale * -height / 2.0f) - yoffset,
+ (yscale * +height / 2.0f) - yoffset,
+ near, far);
}
///
- /// This is function compute the projection matrix based on frustum size.
+ /// Compute a projection matrix for a frustum.
+ ///
/// This function's implementation is same as glFrustum.
///
+ /// Projection matrix.
/// Specify the coordinates for the left vertical clipping planes.
/// Specify the coordinates for the right vertical clipping planes.
/// Specify the coordinates for the bottom horizontal clipping planes.
/// Specify the coordinates for the top horizontal clipping planes.
/// Specify the distances to the near depth clipping planes. Both distances must be positive.
- /// Specify the distances to the far depth clipping planes. Both distances must be positive.
- private Matrix4x4 Frustum(float left,
- float right,
- float bottom,
- float top,
- float zNear,
- float zFar) {
+ /// Specify the distances to the far depth clipping planes. Both distances must be positive.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "*",
+ Justification = "Matrix visibility is more important.")]
+ private Matrix4x4 Frustum(float left, float right, float bottom, float top, float zNear, float zFar)
+ {
Matrix4x4 m = new Matrix4x4();
- m.SetRow(0, new Vector4(2.0f * zNear / (right - left), 0.0f, (right + left) / (right - left) , 0.0f));
- m.SetRow(1, new Vector4(0.0f, 2.0f * zNear/ (top - bottom), (top + bottom) / (top - bottom) , 0.0f));
- m.SetRow(2, new Vector4(0.0f, 0.0f, -(zFar + zNear) / (zFar - zNear), -(2 * zFar * zNear) / (zFar - zNear)));
- m.SetRow(3, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
+ m.SetRow(0, new Vector4(2.0f * zNear / (right - left), 0.0f, (right + left) / (right - left) , 0.0f));
+ m.SetRow(1, new Vector4(0.0f, 2.0f * zNear / (top - bottom), (top + bottom) / (top - bottom) , 0.0f));
+ m.SetRow(2, new Vector4(0.0f, 0.0f, -(zFar + zNear) / (zFar - zNear), -(2 * zFar * zNear) / (zFar - zNear)));
+ m.SetRow(3, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
return m;
}
}
diff --git a/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Shaders/YUV2RGB.shader b/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Shaders/YUV2RGB.shader
index 1d7c0271..a76a109d 100644
--- a/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Shaders/YUV2RGB.shader
+++ b/UnityExamples/Assets/TangoExamples/ExperimentalAugmentedReality/Shaders/YUV2RGB.shader
@@ -10,8 +10,8 @@
{
// Setting the z write off to make sure our video overlay is always rendered at back.
ZWrite Off
-
- Tags { "Queue" = "Geometry" }
+ ZTest Off
+ Tags { "Queue" = "Background" }
Pass
{
GLSLPROGRAM
diff --git a/UnityExamples/Assets/TangoExamples/PointCloud/Scripts/PointCloudFPSCounter.cs b/UnityExamples/Assets/TangoExamples/PointCloud/Scripts/PointCloudFPSCounter.cs
index a0b3b52b..c4e9115d 100644
--- a/UnityExamples/Assets/TangoExamples/PointCloud/Scripts/PointCloudFPSCounter.cs
+++ b/UnityExamples/Assets/TangoExamples/PointCloud/Scripts/PointCloudFPSCounter.cs
@@ -74,8 +74,8 @@ public void OnGUI()
Color oldColor = GUI.color;
GUI.color = Color.black;
- GUI.Label(new Rect(Common.UI_LABEL_START_X, Common.UI_FPS_LABEL_START_Y, Common.UI_LABEL_SIZE_X, Common.UI_LABEL_SIZE_Y),
- Common.UI_FONT_SIZE + m_FPSText + "");
+ GUI.Label(new Rect(PointCloudGUIController.UI_LABEL_START_X, PointCloudGUIController.UI_FPS_LABEL_START_Y, PointCloudGUIController.UI_LABEL_SIZE_X, PointCloudGUIController.UI_LABEL_SIZE_Y),
+ PointCloudGUIController.UI_FONT_SIZE + m_FPSText + "");
GUI.color = oldColor;
}
diff --git a/UnityExamples/Assets/TangoPrefabs/Materials/point_cloud.mat b/UnityExamples/Assets/TangoPrefabs/Materials/point_cloud.mat
index 445827ba..c7ee4843 100644
--- a/UnityExamples/Assets/TangoPrefabs/Materials/point_cloud.mat
+++ b/UnityExamples/Assets/TangoPrefabs/Materials/point_cloud.mat
@@ -22,7 +22,11 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- m_Floats: {}
+ m_Floats:
+ data:
+ first:
+ name: point_size
+ second: 5
m_Colors:
data:
first:
diff --git a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoGestureCamera.cs b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoGestureCamera.cs
index 2173f61d..08aeecc0 100644
--- a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoGestureCamera.cs
+++ b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoGestureCamera.cs
@@ -42,7 +42,13 @@ public enum CameraType
// The default camera mode.
public CameraType m_defaultCameraMode = CameraType.FIRST_PERSON;
-
+
+ // UI fields.
+ public const float UI_BUTTON_SIZE_X = 125.0f;
+ public const float UI_BUTTON_SIZE_Y = 65.0f;
+ public const float UI_BUTTON_GAP_X = 5.0f;
+ public const float UI_BUTTON_GAP_Y = 3.0f;
+
private Vector3 m_curOffset;
private Vector3 m_firstPersonCamOffset = Vector3.zero;
@@ -233,24 +239,24 @@ private void OnGUI()
return;
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - ((Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y) * 3),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y), "First"))
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - ((UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y) * 3),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y), "First"))
{
EnableCamera(CameraType.FIRST_PERSON);
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - ((Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y) * 2),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y), "Third"))
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - ((UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y) * 2),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y), "Third"))
{
EnableCamera(CameraType.THIRD_PERSON);
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - (Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y), "Top"))
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - (UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y), "Top"))
{
EnableCamera(CameraType.TOP_DOWN);
}
diff --git a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoMultiCamera.cs b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoMultiCamera.cs
index aa365cda..6d87a620 100644
--- a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoMultiCamera.cs
+++ b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoMultiCamera.cs
@@ -51,7 +51,13 @@ public enum CameraType
/// The default camera type.
///
public CameraType m_defaultCameraType = CameraType.FirstPerson;
-
+
+ // UI fields.
+ public const float UI_BUTTON_SIZE_X = 125.0f;
+ public const float UI_BUTTON_SIZE_Y = 65.0f;
+ public const float UI_BUTTON_GAP_X = 5.0f;
+ public const float UI_BUTTON_GAP_Y = 3.0f;
+
///
/// Scaling factor when doing a pinch to zoom gesture.
///
@@ -292,26 +298,26 @@ public void OnGUI()
return;
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - ((Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y) * 3),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y),
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - ((UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y) * 3),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y),
"First"))
{
EnableCamera(CameraType.FirstPerson);
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - ((Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y) * 2),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y),
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - ((UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y) * 2),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y),
"Third"))
{
EnableCamera(CameraType.ThirdPerson);
}
- if (GUI.Button(new Rect(Screen.width - Common.UI_BUTTON_SIZE_X - Common.UI_BUTTON_GAP_X,
- Screen.height - (Common.UI_BUTTON_SIZE_Y + Common.UI_LABEL_GAP_Y),
- Common.UI_BUTTON_SIZE_X,
- Common.UI_BUTTON_SIZE_Y),
+ if (GUI.Button(new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
+ Screen.height - (UI_BUTTON_SIZE_Y + UI_BUTTON_GAP_Y),
+ UI_BUTTON_SIZE_X,
+ UI_BUTTON_SIZE_Y),
"Top"))
{
EnableCamera(CameraType.TopDown);
diff --git a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoPointCloud.cs b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoPointCloud.cs
index 425b1ac8..73a9c1dc 100644
--- a/UnityExamples/Assets/TangoPrefabs/Scripts/TangoPointCloud.cs
+++ b/UnityExamples/Assets/TangoPrefabs/Scripts/TangoPointCloud.cs
@@ -31,6 +31,14 @@ public class TangoPointCloud : MonoBehaviour, ITangoDepth
/// If set, the point cloud's mesh gets updated (much slower, useful for debugging).
///
public bool m_updatePointsMesh;
+
+ ///
+ /// If set, m_updatePointsMesh also gets set at start. Then PointCloud material's renderqueue is set to background
+ /// (which is same as YUV2RGB Shader) so that PointCloud data gets written to Z buffer for Depth test with virtual
+ /// objects in scene. Note this is a very rudimentary way of doing occlusion and limited by the capabilities of
+ /// depth camera.
+ ///
+ public bool m_enableOcclusion;
///
/// The points of the point cloud, in world space.
@@ -63,6 +71,16 @@ public class TangoPointCloud : MonoBehaviour, ITangoDepth
///
private const int MAX_POINT_COUNT = 61440;
+ ///
+ /// The Background renderqueue's number.
+ ///
+ private const int BACKGROUND_RENDER_QUEUE = 1000;
+
+ ///
+ /// Point size of PointCloud data when projected on to image plane.
+ ///
+ private const int POINTCLOUD_SPLATTER_UPSAMPLE_SIZE = 30;
+
private TangoApplication m_tangoApplication;
// Matrices for transforming pointcloud to world coordinates.
@@ -108,6 +126,13 @@ public void Start()
m_renderer = GetComponent();
m_rand = new System.Random();
+ if (m_enableOcclusion)
+ {
+ m_renderer.enabled = true;
+ m_renderer.material.renderQueue = BACKGROUND_RENDER_QUEUE;
+ m_renderer.material.SetFloat("point_size", POINTCLOUD_SPLATTER_UPSAMPLE_SIZE);
+ m_updatePointsMesh = true;
+ }
}
///
diff --git a/UnityExamples/Assets/TangoPrefabs/Shaders/PointCloud.shader b/UnityExamples/Assets/TangoPrefabs/Shaders/PointCloud.shader
index edc87c6a..db227393 100644
--- a/UnityExamples/Assets/TangoPrefabs/Shaders/PointCloud.shader
+++ b/UnityExamples/Assets/TangoPrefabs/Shaders/PointCloud.shader
@@ -1,14 +1,18 @@
Shader "Tango/PointCloud" {
+Properties{
+ point_size("Point Size", Float) = 5.0
+}
SubShader {
Pass {
GLSLPROGRAM
-
+
#ifdef VERTEX
uniform mat4 depthCameraTUnityWorld;
+ uniform float point_size;
varying vec4 v_color;
void main()
{
- gl_PointSize = 5.0;
+ gl_PointSize = point_size;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Color should be based on pose relative info
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/Common.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/Common.cs
index 79eb1efc..9112a569 100755
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/Common.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/Common.cs
@@ -89,48 +89,6 @@ public enum AndroidResult
DENIED = 1
}
- ///
- /// DEPRECATED: Empty string.
- ///
- public const string TANGO_PERMISSION_STRING = "";
-
- ///
- /// DEPRECATED: Tango permissions error.
- ///
- public const string TANGO_NO_PERMISSIONS_ERROR = "This application requires all Tango permissions to run. Please restart the application and grant Tango permissions.";
-
- //// \cond
- //// Collection of deprecated fields that should be removed
- public const float UI_LABEL_START_X = 15.0f;
- public const float UI_LABEL_START_Y = 15.0f;
- public const float UI_LABEL_SIZE_X = 1920.0f;
- public const float UI_LABEL_SIZE_Y = 35.0f;
- public const float UI_LABEL_GAP_Y = 3.0f;
- public const float UI_BUTTON_SIZE_X = 125.0f;
- public const float UI_BUTTON_SIZE_Y = 65.0f;
- public const float UI_BUTTON_GAP_X = 5.0f;
- public const float UI_CAMERA_BUTTON_OFFSET = UI_BUTTON_SIZE_X + UI_BUTTON_GAP_X;
- public const float UI_LABEL_OFFSET = UI_LABEL_GAP_Y + UI_LABEL_SIZE_Y;
- public const float UI_FPS_LABEL_START_Y = UI_LABEL_START_Y + UI_LABEL_OFFSET;
- public const float UI_EVENT_LABEL_START_Y = UI_FPS_LABEL_START_Y + UI_LABEL_OFFSET;
- public const float UI_POSE_LABEL_START_Y = UI_EVENT_LABEL_START_Y + UI_LABEL_OFFSET;
- public const float UI_DEPTH_LABLE_START_Y = UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET;
- public const string UI_FLOAT_FORMAT = "F3";
- public const string UI_FONT_SIZE = "";
-
- public const float UI_TANGO_VERSION_X = UI_LABEL_START_X;
- public const float UI_TANGO_VERSION_Y = UI_LABEL_START_Y;
- public const float UI_TANGO_APP_SPECIFIC_START_X = UI_TANGO_VERSION_X;
- public const float UI_TANGO_APP_SPECIFIC_START_Y = UI_TANGO_VERSION_Y + (UI_LABEL_OFFSET * 2);
-
- public const string UX_SERVICE_VERSION = "Service version: {0}";
- public const string UX_TANGO_SERVICE_VERSION = "Tango service version: {0}";
- public const string UX_TANGO_SYSTEM_EVENT = "Tango system event: {0}";
- public const string UX_TARGET_TO_BASE_FRAME = "Target->{0}, Base->{1}:";
- public const string UX_STATUS = "\tstatus: {0}, count: {1}, delta time(ms): {2}, position (m): [{3}], orientation: [{4}]";
- public const float SECOND_TO_MILLISECOND = 1000.0f;
- //// \endcond
-
///
/// Name of the Tango C-API library.
///
@@ -165,95 +123,5 @@ public enum AndroidResult
/// The length of an area description ID string.
///
internal const int UUID_LENGTH = 37;
-
- //// Backing for deprecated properties below.
-#if (UNITY_EDITOR)
- private static bool m_mirroring = true;
-#elif (UNITY_ANDROID)
- private static bool m_mirroring = false;
-#else
- private static bool m_mirroring = false;
-#endif
- private static Resolution m_depthFrameResolution;
- private static int m_depthBufferSize;
-
- ///
- /// DEPRECATED: Property for mirroring.
- ///
- /// Bool - sets mirroring.
- public static bool Mirroring
- {
- get { return m_mirroring; }
- set { m_mirroring = value; }
- }
-
- ///
- /// DEPRECATED: Property for the current depth frame resolution.
- ///
- /// Resolution - Sets depth frame resolution reference.
- public static Resolution DepthFrameResolution
- {
- get { return m_depthFrameResolution; }
- set { m_depthFrameResolution = value; }
- }
-
- ///
- /// DEPRECATED: Property for the depth buffer size.
- ///
- /// Bool - Sets the size of the depth buffer.
- public static int DepthBufferSize
- {
- get { return m_depthBufferSize; }
- set { m_depthBufferSize = value; }
- }
-
- ///
- /// DEPRECATED: Get the world rotation.
- ///
- /// Quaternion representing the world rotation.
- public static Quaternion GetWorldRotation()
- {
- return OrientationManager.GetWorldRotation();
- }
-
- ///
- /// DEPRECATED: Get the screen size if the screen was in landscape mode.
- ///
- /// This looks at Screen.width and Screen.height.
- ///
- /// Vector2 containing the screen size.
- public static Vector2 GetWindowResolution()
- {
- Vector2 screenSize;
- if (Screen.width > Screen.height)
- {
- screenSize = new Vector2(Screen.width, Screen.height);
- }
- else
- {
- screenSize = new Vector2(Screen.height, Screen.width);
- }
- return screenSize;
- }
-
- ///
- /// DEPRECATED: Get the aspect ratio of the screen in landscape mode.
- ///
- /// Aspect ratio.
- public static float GetWindowResolutionAspect()
- {
- Vector2 resolution = GetWindowResolution();
- return resolution.x / resolution.y;
- }
-
- ///
- /// DEPRECATED: Misspelled version of GetWindowResolutionAspect.
- ///
- /// Aspect ratio.
- public static float GetWindowResoltionAspect()
- {
- Vector2 resolution = GetWindowResolution();
- return resolution.x / resolution.y;
- }
}
}
\ No newline at end of file
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/TangoEnums.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/TangoEnums.cs
index 11759a30..943331d8 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/TangoEnums.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Common/TangoEnums.cs
@@ -224,6 +224,11 @@ public enum TangoConfigType
///
TANGO_CONFIG_AREA_LEARNING,
+ ///
+ /// Runtime configuration parameters.
+ ///
+ TANGO_CONFIG_RUNTIME,
+
///
/// Maximum number allowable.
///
@@ -265,5 +270,21 @@ public enum TangoImageFormatType
///
TANGO_HAL_PIXEL_FORMAT_YV12 = 0x32315659
}
+
+ ///
+ /// Depth camera rates.
+ ///
+ public enum TangoDepthCameraRate
+ {
+ ///
+ /// Disable the depth camera entirely.
+ ///
+ DISABLED,
+
+ ///
+ /// The maximum depth camera rate supported. This is 5 on the Tango tablet.
+ ///
+ MAXIMUM,
+ }
}
}
\ No newline at end of file
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs
new file mode 100644
index 00000000..b31fef20
--- /dev/null
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs
@@ -0,0 +1,36 @@
+//-----------------------------------------------------------------------
+//
+//
+// Copyright 2015 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+//-----------------------------------------------------------------------
+using System.Collections;
+using UnityEngine;
+
+///
+/// Tango event interface where the handler will be invoked from multiple threads.
+///
+/// Use this if you want to get the events as soon as they happen. The handler will be invoked as soon as the
+/// event happens, even if that is in another thread. You must make sure your handler is threadsafe.
+///
+public interface ITangoEventMultithreaded
+{
+ ///
+ /// This is called each time a Tango event happens.
+ ///
+ /// Tango event.
+ void OnTangoEventMultithreadedAvailableEventHandler(Tango.TangoEvent tangoEvent);
+}
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs.meta b/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs.meta
new file mode 100644
index 00000000..351f4479
--- /dev/null
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Interfaces/ITangoEventMultithreaded.cs.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: ff09c9752b24d434495a54e47fe2646a
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/DepthListener.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/DepthListener.cs
index bedbebd3..e5a8836b 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/DepthListener.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/DepthListener.cs
@@ -38,7 +38,7 @@ internal class DepthListener
private Tango.DepthProvider.TangoService_onDepthAvailable m_onDepthAvailableCallback;
///
- /// Occurs when m_on tango depth available.
+ /// Called when a new Tango depth is available.
///
private event OnTangoDepthAvailableEventHandler OnTangoDepthAvailable;
@@ -100,12 +100,11 @@ internal void UnregisterOnTangoDepthAvailable(OnTangoDepthAvailableEventHandler
}
///
- /// DEPRECATED: Callback that gets called when depth is available
- /// from the Tango Service.
+ /// Callback that gets called when depth is available from the Tango Service.
///
/// Callback context.
/// Xyzij.
- protected void _OnDepthAvailable(IntPtr callbackContext, TangoXYZij xyzij)
+ private void _OnDepthAvailable(IntPtr callbackContext, TangoXYZij xyzij)
{
// Fill in the data to draw the point cloud.
if (xyzij != null)
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/PoseListener.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/PoseListener.cs
index 4f79d849..8893475f 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/PoseListener.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/PoseListener.cs
@@ -34,12 +34,13 @@ namespace Tango
///
public class PoseListener
{
+ private const int SIZE_OF_POSE_DATA_POOL = 3;
+
///
- /// DEPRECATED: The pose available callback.
+ /// Called when a new Tango pose is available.
///
- internal Tango.PoseProvider.TangoService_onPoseAvailable m_poseAvailableCallback;
+ private Tango.PoseProvider.TangoService_onPoseAvailable m_poseAvailableCallback;
- private const int SIZE_OF_POSE_DATA_POOL = 3;
private TangoPoseData m_motionTrackingData = null;
private TangoPoseData m_areaLearningData = null;
private TangoPoseData m_relocalizationData = null;
@@ -49,20 +50,10 @@ public class PoseListener
private object m_lockObject = new object();
///
- /// DEPRECATED: Gets or sets a value indicating whether this is using auto reset.
+ /// Gets or sets a value indicating whether this is using auto reset.
///
/// true if auto reset; otherwise, false.
- public bool AutoReset
- {
- get;
- set;
- }
-
- ///
- /// DEPRECATED: Gets or sets a value indicating whether this use camera intrinsics.
- ///
- /// true if use camera intrinsics; otherwise, false.
- public bool UseCameraIntrinsics
+ internal bool AutoReset
{
get;
set;
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/TangoEventListener.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/TangoEventListener.cs
index 873098ca..94447861 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/TangoEventListener.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/TangoEventListener.cs
@@ -35,7 +35,9 @@ internal class TangoEventListener
{
private TangoEvents.TangoService_onEventAvailable m_onEventAvaialableCallback;
private OnTangoEventAvailableEventHandler m_onTangoEventAvailable;
- private TangoEvent m_previousEvent;
+ private OnTangoEventAvailableEventHandler m_onTangoEventMultithreadedAvailable;
+ private TangoEvent m_tangoEvent;
+ private System.Object m_lockObject = new System.Object();
private bool m_isDirty;
///
@@ -48,7 +50,7 @@ internal virtual void SetCallback()
{
m_onEventAvaialableCallback = new TangoEvents.TangoService_onEventAvailable(_onEventAvailable);
TangoEvents.SetCallback(m_onEventAvaialableCallback);
- m_previousEvent = new TangoEvent();
+ m_tangoEvent = new TangoEvent();
m_isDirty = false;
}
@@ -57,14 +59,13 @@ internal virtual void SetCallback()
///
internal void SendIfTangoEventAvailable()
{
- if (m_isDirty)
+ if (m_isDirty && m_onTangoEventAvailable != null)
{
- if (m_onTangoEventAvailable != null)
+ lock (m_lockObject)
{
- m_onTangoEventAvailable(m_previousEvent);
+ m_onTangoEventAvailable(m_tangoEvent);
}
-
- m_isDirty = true;
+ m_isDirty = false;
}
}
@@ -93,20 +94,51 @@ internal void UnregisterOnTangoEventAvailable(OnTangoEventAvailableEventHandler
}
///
- /// DEPRECATED: Handle the callback sent by the Tango Service
- /// when a new event is issued.
+ /// Register a multithread handler for Tango events.
+ ///
+ /// Event handler to register.
+ internal void RegisterOnTangoEventMultithreadedAvailable(OnTangoEventAvailableEventHandler handler)
+ {
+ if (handler != null)
+ {
+ m_onTangoEventMultithreadedAvailable += handler;
+ }
+ }
+
+ ///
+ /// Unregister a multithread handler for the Tango depth event.
+ ///
+ /// Event handler to unregister.
+ internal void UnregisterOnTangoEventMultithreadedAvailable(OnTangoEventAvailableEventHandler handler)
+ {
+ if (handler != null)
+ {
+ m_onTangoEventMultithreadedAvailable -= handler;
+ }
+ }
+
+ ///
+ /// Handle the callback sent by the Tango Service when a new event is issued.
///
/// Callback context.
/// Tango event.
- protected void _onEventAvailable(IntPtr callbackContext, TangoEvent tangoEvent)
+ private void _onEventAvailable(IntPtr callbackContext, TangoEvent tangoEvent)
{
if (tangoEvent != null)
{
- m_previousEvent.timestamp = tangoEvent.timestamp;
- m_previousEvent.type = tangoEvent.type;
- m_previousEvent.event_key = tangoEvent.event_key;
- m_previousEvent.event_value = tangoEvent.event_value;
- m_isDirty = true;
+ if (m_onTangoEventMultithreadedAvailable != null)
+ {
+ m_onTangoEventMultithreadedAvailable(tangoEvent);
+ }
+
+ lock (m_lockObject)
+ {
+ m_tangoEvent.timestamp = tangoEvent.timestamp;
+ m_tangoEvent.type = tangoEvent.type;
+ m_tangoEvent.event_key = tangoEvent.event_key;
+ m_tangoEvent.event_value = tangoEvent.event_value;
+ m_isDirty = true;
+ }
}
}
}
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/VideoOverlayListener.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/VideoOverlayListener.cs
index 5f07a266..657a190c 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/VideoOverlayListener.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/Listeners/VideoOverlayListener.cs
@@ -170,15 +170,13 @@ internal void UnregisterOnExperimentalTangoImageAvailable(OnExperimentalTangoIma
}
///
- /// DEPRECATED: Handle the callback sent by the Tango Service
- /// when a new image is sampled.
+ /// Handle the callback sent by the Tango Service when a new image is sampled.
///
/// Callback context.
/// Camera identifier.
/// Image buffer.
- protected void _OnImageAvailable(IntPtr callbackContext,
- TangoEnums.TangoCameraId cameraId,
- TangoImageBuffer imageBuffer)
+ private void _OnImageAvailable(IntPtr callbackContext, TangoEnums.TangoCameraId cameraId,
+ TangoImageBuffer imageBuffer)
{
m_previousCameraId = cameraId;
@@ -200,11 +198,11 @@ protected void _OnImageAvailable(IntPtr callbackContext,
}
///
- /// DEPRECATED: Handle the callback set by the Tango Service when a new image is available.
+ /// Handle the callback set by the Tango Service when a new image is available.
///
/// Callback context.
/// Camera identifier.
- protected void _OnExperimentalUnityFrameAvailable(IntPtr callbackContext, Tango.TangoEnums.TangoCameraId cameraId)
+ private void _OnExperimentalUnityFrameAvailable(IntPtr callbackContext, Tango.TangoEnums.TangoCameraId cameraId)
{
m_previousCameraId = cameraId;
m_shouldSendEvent = true;
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/PoseProvider.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/PoseProvider.cs
index 39473e36..948dda8b 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/PoseProvider.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/PoseProvider.cs
@@ -92,21 +92,6 @@ public static void GetPoseAtTime([In, Out] TangoPoseData poseData,
}
}
- ///
- /// DEPRECATED: Sets the listener coordinate frame pairs.
- ///
- /// Count.
- /// Frames.
- public static void SetListenerCoordinateFramePairs(int count,
- ref TangoCoordinateFramePair frames)
- {
- int returnValue = PoseProviderAPI.TangoService_setPoseListenerFrames(count, ref frames);
- if (returnValue != Common.ErrorType.TANGO_SUCCESS)
- {
- Debug.Log(CLASS_NAME + ".SetListenerCoordinateFramePairs() Could not set frame pairs");
- }
- }
-
///
/// Resets the motion tracking system.
///
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoApplication.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoApplication.cs
index 7965d18c..f3077c9d 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoApplication.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoApplication.cs
@@ -75,6 +75,7 @@ private enum PermissionsTypes
public bool m_enableVideoOverlay = false;
public bool m_motionTrackingAutoReset = true;
public bool m_enableAreaLearning = false;
+ public bool m_enableADFLoading = false;
public bool m_useExperimentalVideoOverlay = true;
public bool m_useExperimentalADF = false;
#if UNITY_EDITOR
@@ -120,6 +121,8 @@ private enum PermissionsTypes
private VideoOverlayListener m_videoOverlayListener;
private TangoEventListener m_tangoEventListener;
private YUVTexture m_yuvTexture;
+ private TangoConfig m_tangoConfig;
+ private TangoConfig m_tangoRuntimeConfig;
///
/// Get the Tango service version name.
@@ -160,6 +163,13 @@ public void Register(System.Object tangoObject)
RegisterOnTangoEvent(tangoEvent.OnTangoEventAvailableEventHandler);
}
+ ITangoEventMultithreaded tangoEventMultithreaded = tangoObject as ITangoEventMultithreaded;
+
+ if (tangoEventMultithreaded != null)
+ {
+ RegisterOnTangoEventMultithreaded(tangoEventMultithreaded.OnTangoEventMultithreadedAvailableEventHandler);
+ }
+
if (m_enableMotionTracking)
{
ITangoPose poseHandler = tangoObject as ITangoPose;
@@ -218,6 +228,13 @@ public void Unregister(System.Object tangoObject)
UnregisterOnTangoEvent(tangoEvent.OnTangoEventAvailableEventHandler);
}
+ ITangoEventMultithreaded tangoEventMultithreaded = tangoObject as ITangoEventMultithreaded;
+
+ if (tangoEventMultithreaded != null)
+ {
+ UnregisterOnTangoEventMultithreaded(tangoEventMultithreaded.OnTangoEventMultithreadedAvailableEventHandler);
+ }
+
if (m_enableMotionTracking)
{
ITangoPose poseHandler = tangoObject as ITangoPose;
@@ -299,20 +316,6 @@ public void UnregisterPermissionsCallback(PermissionsEvent permissionsEventHandl
}
}
- ///
- /// DEPRECATED: Unregister from the permission callbacks.
- ///
- /// See TangoApplication.RegisterPermissionsCallback for more details.
- ///
- /// Event to remove.
- public void RemovePermissionsCallback(PermissionsEvent permissionsEventHandler)
- {
- if (permissionsEventHandler != null)
- {
- PermissionEvent -= permissionsEventHandler;
- }
- }
-
///
/// Register to get an event callback when connected to the Tango service.
///
@@ -399,7 +402,14 @@ public void InitApplication()
{
Debug.Log("-----------------------------------Initializing Tango");
_TangoInitialize();
- TangoConfig.InitConfig(TangoEnums.TangoConfigType.TANGO_CONFIG_DEFAULT);
+ if (m_tangoConfig == null)
+ {
+ m_tangoConfig = new TangoConfig(TangoEnums.TangoConfigType.TANGO_CONFIG_DEFAULT);
+ }
+ if (m_tangoRuntimeConfig == null)
+ {
+ m_tangoRuntimeConfig = new TangoConfig(TangoEnums.TangoConfigType.TANGO_CONFIG_RUNTIME);
+ }
if (m_enableVideoOverlay && m_useExperimentalVideoOverlay)
{
@@ -408,10 +418,10 @@ public void InitApplication()
int uvTextureWidth = 0;
int uvTextureHeight = 0;
- TangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_Y_TEXTURE_WIDTH, ref yTextureWidth);
- TangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_Y_TEXTURE_HEIGHT, ref yTextureHeight);
- TangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_UV_TEXTURE_WIDTH, ref uvTextureWidth);
- TangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_UV_TEXTURE_HEIGHT, ref uvTextureHeight);
+ m_tangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_Y_TEXTURE_WIDTH, ref yTextureWidth);
+ m_tangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_Y_TEXTURE_HEIGHT, ref yTextureHeight);
+ m_tangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_UV_TEXTURE_WIDTH, ref uvTextureWidth);
+ m_tangoConfig.GetInt32(TangoConfig.Keys.EXPERIMENTAL_UV_TEXTURE_HEIGHT, ref uvTextureHeight);
if (yTextureWidth == 0 || yTextureHeight == 0 || uvTextureWidth == 0 || uvTextureHeight == 0)
{
@@ -461,10 +471,79 @@ public void ConnectToService()
public void Shutdown()
{
Debug.Log("Tango Shutdown");
- TangoConfig.Free();
+ if (m_tangoConfig != null)
+ {
+ m_tangoConfig.Dispose();
+ m_tangoConfig = null;
+ }
+ if (m_tangoRuntimeConfig != null)
+ {
+ m_tangoRuntimeConfig.Dispose();
+ m_tangoRuntimeConfig = null;
+ }
_TangoDisconnect();
}
+ ///
+ /// Set the framerate of the depth camera.
+ ///
+ /// Disabling or reducing the framerate of the depth camera when it is running can save a significant amount
+ /// of battery.
+ ///
+ /// The rate in frames per second, for the depth camera to run at.
+ public void SetDepthCameraRate(int rate)
+ {
+ if (rate < 0)
+ {
+ Debug.Log("Invalid rate passed to SetDepthCameraRate");
+ return;
+ }
+
+ m_tangoRuntimeConfig.SetInt32(TangoConfig.Keys.RUNTIME_DEPTH_FRAMERATE, rate);
+ m_tangoRuntimeConfig.SetRuntimeConfig();
+ }
+
+ ///
+ /// Set the framerate of the depth camera.
+ ///
+ /// Disabling or reducing the framerate of the depth camera when it is running can save a significant amount
+ /// of battery.
+ ///
+ /// A special rate to set the depth camera to.
+ public void SetDepthCameraRate(TangoEnums.TangoDepthCameraRate rate)
+ {
+ switch (rate)
+ {
+ case TangoEnums.TangoDepthCameraRate.DISABLED:
+ SetDepthCameraRate(0);
+ break;
+
+ case TangoEnums.TangoDepthCameraRate.MAXIMUM:
+ // Set the depth frame rate to a sufficiently high number, it will get rounded down. There is no
+ // way to actually get the maximum value to pass in.
+ SetDepthCameraRate(9000);
+ break;
+ }
+ }
+
+ ///
+ /// Get the Tango config. Useful for debugging.
+ ///
+ /// The config.
+ internal TangoConfig Config
+ {
+ get { return m_tangoConfig; }
+ }
+
+ ///
+ /// Get the current Tango runtime config. Useful for debugging.
+ ///
+ /// The current runtime config.
+ internal TangoConfig RuntimeConfig
+ {
+ get { return m_tangoRuntimeConfig; }
+ }
+
///
/// Register to get Tango pose callbacks.
///
@@ -548,6 +627,34 @@ internal void UnregisterOnTangoEvent(OnTangoEventAvailableEventHandler handler)
m_tangoEventListener.UnregisterOnTangoEventAvailable(handler);
}
}
+
+ ///
+ /// Register to get Tango event callbacks.
+ ///
+ /// See TangoApplication.Register for details.
+ ///
+ /// Object to stop getting Tango callbacks from.
+ internal void RegisterOnTangoEventMultithreaded(OnTangoEventAvailableEventHandler handler)
+ {
+ if (m_tangoEventListener != null)
+ {
+ m_tangoEventListener.RegisterOnTangoEventMultithreadedAvailable(handler);
+ }
+ }
+
+ ///
+ /// Unregister from the Tango event callbacks.
+ ///
+ /// See TangoApplication.Register for more details.
+ ///
+ /// Event to remove.
+ internal void UnregisterOnTangoEventMultithreaded(OnTangoEventAvailableEventHandler handler)
+ {
+ if (m_tangoEventListener != null)
+ {
+ m_tangoEventListener.UnregisterOnTangoEventMultithreadedAvailable(handler);
+ }
+ }
///
/// Register to get Tango video overlay callbacks.
@@ -685,22 +792,33 @@ private void _InitializeMotionTracking(string uuid)
{
System.Collections.Generic.List framePairs = new System.Collections.Generic.List();
- if (TangoConfig.SetBool(TangoConfig.Keys.ENABLE_MOTION_TRACKING_BOOL, m_enableMotionTracking) && m_enableMotionTracking)
+ if (m_tangoConfig.SetBool(TangoConfig.Keys.ENABLE_MOTION_TRACKING_BOOL, m_enableMotionTracking) && m_enableMotionTracking)
{
TangoCoordinateFramePair motionTracking;
motionTracking.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
motionTracking.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
framePairs.Add(motionTracking);
-
- if (TangoConfig.SetBool(TangoConfig.Keys.ENABLE_AREA_LEARNING_BOOL, m_enableAreaLearning) && m_enableAreaLearning)
+
+ bool areaLearningEnabled = false;
+ if (m_tangoConfig.SetBool(TangoConfig.Keys.ENABLE_AREA_LEARNING_BOOL, m_enableAreaLearning) && m_enableAreaLearning)
{
+ areaLearningEnabled = true;
Debug.Log("Area Learning is enabled.");
+ }
+
+ // For backward compatibility, don't require the m_enableADFLoading to be set.
+ if (areaLearningEnabled || m_enableADFLoading)
+ {
+ m_tangoConfig.SetBool("config_experimental_high_accuracy_small_scale_adf", m_useExperimentalADF);
+
if (!string.IsNullOrEmpty(uuid))
{
- TangoConfig.SetBool("config_experimental_high_accuracy_small_scale_adf", m_useExperimentalADF);
- TangoConfig.SetString(TangoConfig.Keys.LOAD_AREA_DESCRIPTION_UUID_STRING, uuid);
+ m_tangoConfig.SetString(TangoConfig.Keys.LOAD_AREA_DESCRIPTION_UUID_STRING, uuid);
}
-
+ }
+
+ if (areaLearningEnabled || m_enableADFLoading)
+ {
TangoCoordinateFramePair areaDescription;
areaDescription.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION;
areaDescription.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
@@ -720,9 +838,9 @@ private void _InitializeMotionTracking(string uuid)
}
// The C API does not default this to on, but it is locked down.
- TangoConfig.SetBool(TangoConfig.Keys.ENABLE_LOW_LATENCY_IMU_INTEGRATION, true);
+ m_tangoConfig.SetBool(TangoConfig.Keys.ENABLE_LOW_LATENCY_IMU_INTEGRATION, true);
- TangoConfig.SetBool(TangoConfig.Keys.ENABLE_MOTION_TRACKING_AUTO_RECOVERY_BOOL, m_motionTrackingAutoReset);
+ m_tangoConfig.SetBool(TangoConfig.Keys.ENABLE_MOTION_TRACKING_AUTO_RECOVERY_BOOL, m_motionTrackingAutoReset);
}
///
@@ -730,7 +848,7 @@ private void _InitializeMotionTracking(string uuid)
///
private void _InitializeDepth()
{
- if (TangoConfig.SetBool(TangoConfig.Keys.ENABLE_DEPTH_PERCEPTION_BOOL, m_enableDepth) && m_enableDepth)
+ if (m_tangoConfig.SetBool(TangoConfig.Keys.ENABLE_DEPTH_PERCEPTION_BOOL, m_enableDepth) && m_enableDepth)
{
_SetDepthCallbacks();
}
@@ -777,7 +895,7 @@ private void _TangoConnect()
{
m_isServiceConnected = true;
AndroidHelper.PerformanceLog("Unity _TangoConnect start");
- if (TangoServiceAPI.TangoService_connect(m_callbackContext, TangoConfig.GetConfig()) != Common.ErrorType.TANGO_SUCCESS)
+ if (TangoServiceAPI.TangoService_connect(m_callbackContext, m_tangoConfig.GetHandle()) != Common.ErrorType.TANGO_SUCCESS)
{
Debug.Log(CLASS_NAME + ".Connect() Could not connect to the Tango Service!");
}
@@ -955,6 +1073,7 @@ private void _ResetPermissionsFlags()
{
m_requiredPermissions |= m_enableMotionTracking ? PermissionsTypes.MOTION_TRACKING : PermissionsTypes.NONE;
m_requiredPermissions |= m_enableAreaLearning ? PermissionsTypes.AREA_LEARNING : PermissionsTypes.NONE;
+ m_requiredPermissions |= m_enableADFLoading ? PermissionsTypes.AREA_LEARNING : PermissionsTypes.NONE;
}
}
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoConfig.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoConfig.cs
index e50ae856..3135cc93 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoConfig.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/TangoConfig.cs
@@ -29,7 +29,7 @@ namespace Tango
///
/// C API wrapper for Tango Configuration Parameters.
///
- internal class TangoConfig
+ internal sealed class TangoConfig : IDisposable
{
#region Attributes
///
@@ -58,76 +58,88 @@ internal struct Keys
// Utility
public static readonly string ENABLE_DATASET_RECORDING = "config_enable_dataset_recording";
public static readonly string GET_TANGO_SERVICE_VERSION_STRING = "tango_service_library_version";
+
+ // Runtime configs
+ public static readonly string RUNTIME_DEPTH_FRAMERATE = "config_runtime_depth_framerate";
}
private const string m_FailedConversionFormat = "Failed to convert object to generic type : {0}. Reverting to default.";
private const string m_ErrorLogFormat = "{0}.{1}() Was unable to set key: {2} with value: {3}";
private const string m_ConfigErrorFormat = "{0}.{1}() Invalid TangoConfig, make sure Tango Config is initialized properly.";
- private static readonly string CLASS_NAME = "TangoConfig.";
+ private static readonly string CLASS_NAME = "TangoConfig";
private static readonly string NO_CONFIG_FOUND = "No config file found.";
- private static IntPtr m_tangoConfig = IntPtr.Zero;
+
+ ///
+ /// Pointer to the TangoConfig.
+ ///
+ private IntPtr m_configHandle;
///
/// Delegate for internal API call that sets a config option.
///
- /// This matches the signature of TangoConfig_setBool, TangoConfig_Double, etc.
+ /// This matches the signature of TangoConfig_setBool, TangoConfig_setDouble, etc.
///
- /// C pointer to a TangoConfig.
- /// Key we want to modify.
- /// Value to set, of the correct type.
+ /// TangoConfig handle.
+ /// Key we want to modify.
+ /// Value to set, of the correct type.
///
/// Returns TANGO_SUCCESS on success or TANGO_INVALID if config or key is NULL, or key is not found or could
/// not be set.
///
- private delegate int ConfigAPIDelegate(IntPtr obj1, string obj2, T obj3);
- #endregion
+ private delegate int ConfigAPISetter(IntPtr configHandle, string key, T val);
///
- /// Gets the cached C pointer to a TangoConfig.
+ /// Delegate for internal API call that gets a config option.
///
- /// This pointer is updated by calling InitConfig.
+ /// This matches the signature of TangoConfig_getBool, TangoConfig_getDouble, etc.
///
- /// C pointer to a Tango config.
- internal static IntPtr GetConfig()
- {
- return m_tangoConfig;
- }
+ /// TangoConfig handle.
+ /// Key we want to get.
+ /// Upon success, the value of for key.
+ ///
+ /// Returns TANGO_SUCCESS on success or TANGO_INVALID if config or key is NULL, or key is not found or could
+ /// not be set.
+ ///
+ private delegate int ConfigAPIGetter(IntPtr configHandle, string key, ref T val);
+ #endregion
///
- /// Update the cached C pointer to a TangoConfig.
+ /// Create a new TangoConfig.
///
- /// This should be used to initialize a Config object for setting the configuration that TangoService should
- /// be run in. The Config handle is passed to TangoService_connect() which starts the service running with
- /// the parameters set at that time in that TangoConfig handle. This function can be used to find the current
+ /// A TangoConfig is passed to TangoService_connect() which starts the service running with
+ /// the parameters set at that time in that TangoConfig. This function can be used to find the current
/// configuration of the service (i.e. what would be run if no config is specified on TangoService_connect()),
- /// or to create one of a few "template" TangoConfigs. The returned TangoConfig can be further modified by
- /// TangoConfig_set function calls. The handle should be freed with Free(). The handle is needed
- /// only at the time of TangoService_connect() where it is used to configure the service, and can safely be
- /// freed after it has been used in TangoService_connect().
+ /// or to create one of a few "template" TangoConfigs.
+ ///
+ /// The class is needed only at the time of TangoService_connect() where it is used to configure the service
+ /// and can safely be disposed after it has been used in TangoService_connect().
///
/// The requested configuration type.
- internal static void InitConfig(TangoEnums.TangoConfigType configType)
+ public TangoConfig(TangoEnums.TangoConfigType configType)
{
- m_tangoConfig = TangoConfigAPI.TangoService_getConfig(configType);
-
- // TODO : error check this!
+ m_configHandle = TangoConfigAPI.TangoService_getConfig(configType);
}
///
- /// Free a TangoConfig object.
- ///
- /// Frees the TangoConfig object for the cached handle.
+ /// Releases all resource used by the object.
///
- internal static void Free()
+ /// Call when you are finished using the . The
+ /// method leaves the in an unusable state. After calling
+ /// , you must release all references to the so the garbage
+ /// collector can reclaim the memory that the was occupying.
+ public void Dispose()
{
- if (m_tangoConfig != IntPtr.Zero)
+ if (m_configHandle != IntPtr.Zero)
{
- TangoConfigAPI.TangoConfig_free(m_tangoConfig);
- }
+ TangoConfigAPI.TangoConfig_free(m_configHandle);
+ m_configHandle = IntPtr.Zero;
+ }
else
{
Debug.Log(CLASS_NAME + ".Free() No allocated Tango Config found!");
}
+
+ GC.SuppressFinalize(this);
}
///
@@ -137,11 +149,11 @@ internal static void Free()
/// Note that many of these config values are read-only, unless otherwise documented.
///
/// String representation of the cached configuration.
- internal static string GetSettings()
+ internal string GetSettings()
{
- if (m_tangoConfig != IntPtr.Zero)
+ if (m_configHandle != IntPtr.Zero)
{
- return TangoConfigAPI.TangoConfig_toString(m_tangoConfig);
+ return TangoConfigAPI.TangoConfig_toString(m_configHandle);
}
else
{
@@ -149,15 +161,24 @@ internal static string GetSettings()
}
}
+ ///
+ /// Get the internal handle for this TangoConfig.
+ ///
+ /// The handle.
+ internal IntPtr GetHandle()
+ {
+ return m_configHandle;
+ }
+
///
/// Set a boolean configuration parameter.
///
/// true on success, false otherwise.
/// The string key value of the configuration parameter to set.
/// The value to set the configuration key to.
- internal static bool SetBool(string key, bool value)
+ internal bool SetBool(string key, bool value)
{
- return _ConfigHelperSet(new ConfigAPIDelegate(TangoConfigAPI.TangoConfig_setBool), m_tangoConfig, key, value, "SetBool");
+ return _ConfigHelperSet(new ConfigAPISetter(TangoConfigAPI.TangoConfig_setBool), key, value, "SetBool");
}
///
@@ -166,9 +187,9 @@ internal static bool SetBool(string key, bool value)
/// true on success, false otherwise.
/// The string key value of the configuration parameter to set.
/// The value to set the configuration key to.
- internal static bool SetInt32(string key, Int32 value)
+ internal bool SetInt32(string key, Int32 value)
{
- return _ConfigHelperSet(new ConfigAPIDelegate(TangoConfigAPI.TangoConfig_setInt32), m_tangoConfig, key, value, "SetInt32");
+ return _ConfigHelperSet(new ConfigAPISetter(TangoConfigAPI.TangoConfig_setInt32), key, value, "SetInt32");
}
///
@@ -177,9 +198,9 @@ internal static bool SetInt32(string key, Int32 value)
/// true on success, false otherwise.
/// The string key value of the configuration parameter to set.
/// The value to set the configuration key to.
- internal static bool SetInt64(string key, Int64 value)
+ internal bool SetInt64(string key, Int64 value)
{
- return _ConfigHelperSet(new ConfigAPIDelegate(TangoConfigAPI.TangoConfig_setInt64), m_tangoConfig, key, value, "SetInt64");
+ return _ConfigHelperSet(new ConfigAPISetter(TangoConfigAPI.TangoConfig_setInt64), key, value, "SetInt64");
}
///
@@ -188,9 +209,9 @@ internal static bool SetInt64(string key, Int64 value)
/// true on success, false otherwise.
/// The string key value of the configuration parameter to set.
/// The value to set the configuration key to.
- internal static bool SetDouble(string key, double value)
+ internal bool SetDouble(string key, double value)
{
- return _ConfigHelperSet(new ConfigAPIDelegate(TangoConfigAPI.TangoConfig_setDouble), m_tangoConfig, key, value, "SetDouble");
+ return _ConfigHelperSet(new ConfigAPISetter(TangoConfigAPI.TangoConfig_setDouble), key, value, "SetDouble");
}
///
@@ -199,9 +220,9 @@ internal static bool SetDouble(string key, double value)
/// true on success, false otherwise.
/// The string key value of the configuration parameter to set.
/// The value to set the configuration key to.
- internal static bool SetString(string key, string value)
+ internal bool SetString(string key, string value)
{
- return _ConfigHelperSet(new ConfigAPIDelegate(TangoConfigAPI.TangoConfig_setString), m_tangoConfig, key, value, "SetString");
+ return _ConfigHelperSet(new ConfigAPISetter(TangoConfigAPI.TangoConfig_setString), key, value, "SetString");
}
///
@@ -210,20 +231,9 @@ internal static bool SetString(string key, string value)
/// true, if the value was retrieved, false otherwise.
/// The string key value of the configuration parameter to get.
/// On successful return, the value of the configuration key.
- internal static bool GetBool(string key, ref bool value)
+ internal bool GetBool(string key, ref bool value)
{
- bool wasSuccess = false;
- if (m_tangoConfig != IntPtr.Zero)
- {
- wasSuccess = TangoConfigAPI.TangoConfig_getBool(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS;
- }
- if (!wasSuccess)
- {
-#if UNITY_ANDROID && !UNITY_EDITOR
- Debug.LogWarning(string.Format(m_ErrorLogFormat, "GetBool", key, false));
-#endif
- }
- return wasSuccess;
+ return _ConfigHelperGet(new ConfigAPIGetter(TangoConfigAPI.TangoConfig_getBool), key, ref value, "GetBool");
}
///
@@ -232,18 +242,9 @@ internal static bool GetBool(string key, ref bool value)
/// true, if the value was retrieved, false otherwise.
/// The string key value of the configuration parameter to get.
/// On successful return, the value of the configuration key.
- internal static bool GetInt32(string key, ref Int32 value)
+ internal bool GetInt32(string key, ref Int32 value)
{
- bool wasSuccess = false;
- if (m_tangoConfig != IntPtr.Zero)
- {
- wasSuccess = TangoConfigAPI.TangoConfig_getInt32(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS;
- }
- if (!wasSuccess)
- {
- Debug.Log(string.Format(m_ErrorLogFormat, "GetInt32", key, value));
- }
- return wasSuccess;
+ return _ConfigHelperGet(new ConfigAPIGetter(TangoConfigAPI.TangoConfig_getInt32), key, ref value, "GetInt32");
}
///
@@ -252,18 +253,9 @@ internal static bool GetInt32(string key, ref Int32 value)
/// true, if the value was retrieved, false otherwise.
/// The string key value of the configuration parameter to get.
/// On successful return, the value of the configuration key.
- internal static bool GetInt64(string key, ref Int64 value)
+ internal bool GetInt64(string key, ref Int64 value)
{
- bool wasSuccess = false;
- if (m_tangoConfig != IntPtr.Zero)
- {
- wasSuccess = TangoConfigAPI.TangoConfig_getInt64(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS;
- }
- if (!wasSuccess)
- {
- Debug.Log(string.Format(m_ErrorLogFormat, "GetInt64", key, value));
- }
- return wasSuccess;
+ return _ConfigHelperGet(new ConfigAPIGetter(TangoConfigAPI.TangoConfig_getInt64), key, ref value, "GetInt64");
}
///
@@ -272,18 +264,9 @@ internal static bool GetInt64(string key, ref Int64 value)
/// true, if the value was retrieved, false otherwise.
/// The string key value of the configuration parameter to get.
/// On successful return, the value of the configuration key.
- internal static bool GetDouble(string key, ref double value)
+ internal bool GetDouble(string key, ref double value)
{
- bool wasSuccess = false;
- if (m_tangoConfig != IntPtr.Zero)
- {
- wasSuccess = TangoConfigAPI.TangoConfig_getDouble(m_tangoConfig, key, ref value) == 0;
- }
- if (!wasSuccess)
- {
- Debug.Log(string.Format(m_ErrorLogFormat, "GetDouble", key, value));
- }
- return wasSuccess;
+ return _ConfigHelperGet(new ConfigAPIGetter(TangoConfigAPI.TangoConfig_getDouble), key, ref value, "GetDouble");
}
///
@@ -292,71 +275,96 @@ internal static bool GetDouble(string key, ref double value)
/// true, if the value was retrieved, false otherwise.
/// The string key value of the configuration parameter to get.
/// On successful return, the value of the configuration key.
- internal static bool GetString(string key, ref string value)
+ internal bool GetString(string key, ref string value)
{
+ // Can't use _ConfigHelperGet because the API takes a size parameter.
+ string tangoMethodName = "GetString";
+
+ if (m_configHandle == IntPtr.Zero)
+ {
+ Debug.Log(string.Format(m_ConfigErrorFormat, CLASS_NAME, tangoMethodName));
+ return false;
+ }
+
bool wasSuccess = false;
- if (m_tangoConfig != IntPtr.Zero)
+ StringBuilder stringBuilder = new StringBuilder(512);
+ wasSuccess = TangoConfigAPI.TangoConfig_getString(m_configHandle, key, stringBuilder, (uint)stringBuilder.Capacity) == Common.ErrorType.TANGO_SUCCESS;
+ value = stringBuilder.ToString();
+ if (!wasSuccess)
{
- UInt32 stringLength = 512;
-
- StringBuilder tempString = new StringBuilder(512);
- wasSuccess = TangoConfigAPI.TangoConfig_getString(m_tangoConfig, key, tempString, stringLength) == Common.ErrorType.TANGO_SUCCESS;
- if (wasSuccess)
- {
- value = tempString.ToString();
- }
- else
- {
- Debug.Log(string.Format(m_ErrorLogFormat, "GetString", key, value));
- }
+ Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, tangoMethodName, key));
}
return wasSuccess;
}
+ ///
+ /// Set this config as the current runtime config.
+ ///
+ internal void SetRuntimeConfig()
+ {
+ bool wasSuccess = TangoConfigAPI.TangoService_setRuntimeConfig(m_configHandle) == Common.ErrorType.TANGO_SUCCESS;
+ if (!wasSuccess)
+ {
+ Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, "SetRuntimeConfig"));
+ }
+ }
+
///
/// Helper method for setting a configuration parameter.
///
/// true if the API call returned success, false otherwise.
- /// The API call we want to perform.
- /// Handle to a Tango Config.
- /// The string key value of the configuration parameter to set.
- /// The value to set the configuration key to.
- /// Name of the method we are calling. Used for logging purposes.
- /// The type of object we are trying to set.
- private static bool _ConfigHelperSet(ConfigAPIDelegate apiCall, IntPtr tangoConfig, string configKey, object configValue,
- string tangoMethodName)
+ /// The API call to perform.
+ /// The key of the configuration parameter to set.
+ /// The value to set the configuration key to.
+ /// Name of the calling method. Used for logging purposes.
+ /// The type of object to set.
+ private bool _ConfigHelperSet(ConfigAPISetter apiCall, string key, T value, string tangoMethodName)
{
- if (tangoConfig == IntPtr.Zero)
+ if (m_configHandle == IntPtr.Zero)
{
Debug.Log(string.Format(m_ConfigErrorFormat, CLASS_NAME, tangoMethodName));
return false;
}
+
bool wasSuccess = false;
- T genericObj;
- try
+ wasSuccess = apiCall(m_configHandle, key, value) == Common.ErrorType.TANGO_SUCCESS;
+ if (!wasSuccess)
{
- genericObj = (T)configValue;
- }
- catch
+ Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, tangoMethodName, key, value));
+ }
+ return wasSuccess;
+ }
+
+ ///
+ /// Helper method for getting a configuration parameter.
+ ///
+ /// true, if the API call returned success, false otherwise.
+ /// The API call to perfom.
+ /// The key of the configuration parameter to get.
+ /// On success, this is filled with the value of the configuration parameter.
+ /// Name of the calling method. Used for logging purposes.
+ /// The 1type of object to get.
+ private bool _ConfigHelperGet(ConfigAPIGetter apiCall, string key, ref T value, string tangoMethodName)
+ {
+ if (m_configHandle == IntPtr.Zero)
{
- Debug.Log(string.Format(m_FailedConversionFormat, typeof(T)));
- genericObj = default(T);
+ Debug.Log(string.Format(m_ConfigErrorFormat, CLASS_NAME, tangoMethodName));
+ return false;
}
- wasSuccess = apiCall(tangoConfig, configKey, genericObj) == Common.ErrorType.TANGO_SUCCESS;
+
+ bool wasSuccess = false;
+ wasSuccess = apiCall(m_configHandle, key, ref value) == Common.ErrorType.TANGO_SUCCESS;
if (!wasSuccess)
{
- Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, tangoMethodName, configKey, configValue));
+ Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, tangoMethodName, key));
}
return wasSuccess;
}
- ///
- /// DEPRECATED: Internal API, should be private.
- ///
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules",
"SA1600:ElementsMustBeDocumented",
Justification = "C API Wrapper.")]
- internal struct TangoConfigAPI
+ private struct TangoConfigAPI
{
#if UNITY_ANDROID && !UNITY_EDITOR
[DllImport(Common.TANGO_UNITY_DLL)]
@@ -417,6 +425,9 @@ public static extern int TangoConfig_getString(IntPtr tangoConfig,
[MarshalAs(UnmanagedType.LPStr)] string key,
[In, Out] StringBuilder value,
UInt32 size);
+
+ [DllImport(Common.TANGO_UNITY_DLL)]
+ public static extern int TangoService_setRuntimeConfig(IntPtr tangoConfig);
#else
public static void TangoConfig_free(IntPtr tangoConfig)
{
@@ -502,6 +513,11 @@ public static int TangoConfig_getString(IntPtr tangoConfig,
{
return Common.ErrorType.TANGO_SUCCESS;
}
+
+ public static int TangoService_setRuntimeConfig(IntPtr tangoConfig)
+ {
+ return Common.ErrorType.TANGO_SUCCESS;
+ }
#endif
}
}
diff --git a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/VideoOverlayProvider.cs b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/VideoOverlayProvider.cs
index 3d3ecfb2..1a879985 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/VideoOverlayProvider.cs
+++ b/UnityExamples/Assets/TangoSDK/Core/Scripts/TangoWrappers/VideoOverlayProvider.cs
@@ -76,42 +76,6 @@ public static void ConnectTexture(TangoEnums.TangoCameraId cameraId, int texture
}
}
- ///
- /// Experimental API only, subject to change. Connect a Texture IDs to a camera.
- ///
- /// The camera is selected via TangoCameraId. Currently only TANGO_CAMERA_COLOR is supported. The texture
- /// handles will be regenerated by the API on startup after which the application can use them, and will be
- /// packed RGBA8888 data containing bytes of the image (so a single RGBA8888 will pack 4 neighbouring pixels).
- /// If the config flag experimental_image_pixel_format is set to HAL_PIXEL_FORMAT_YCrCb_420_SP, texture_y will
- /// pack 1280x720 pixels into a 320x720 RGBA8888 texture. texture_Cb and texture_Cr will contain copies of
- /// the 2x2 downsampled interleaved UV planes packed similarly. If experimental_image_pixel_format is set to
- /// HAL_PIXEL_FORMAT_YV12 then texture_y will have a stride of 1536 containing 1280 columns of data, packed
- /// similarly in a RGBA8888 texture. texture_Cb and texture_Cr will be 2x2 downsampled versions of the same.
- /// See YV12 and NV21 formats for details.
- ///
- /// Note: The first scan-line of the color image is reserved for metadata instead of image pixels.
- ///
- ///
- /// The ID of the camera to connect this texture to. Only TANGO_CAMERA_COLOR and TANGO_CAMERA_FISHEYE are
- /// supported.
- ///
- /// The texture IDs to use for the Y, Cb, and Cr planes.
- /// Callback.
- internal static void ExperimentalConnectTexture(TangoEnums.TangoCameraId cameraId, YUVTexture textures, TangoService_onUnityFrameAvailable onUnityFrameAvailable)
- {
- int returnValue = VideoOverlayAPI.TangoService_Experimental_connectTextureIdUnity(cameraId,
- (uint)textures.m_videoOverlayTextureY.GetNativeTextureID(),
- (uint)textures.m_videoOverlayTextureCb.GetNativeTextureID(),
- (uint)textures.m_videoOverlayTextureCr.GetNativeTextureID(),
- callbackContext,
- onUnityFrameAvailable);
-
- if (returnValue != Common.ErrorType.TANGO_SUCCESS)
- {
- Debug.Log("VideoOverlayProvider.ConnectTexture() Texture was not connected to camera!");
- }
- }
-
///
/// Update the texture that has been connected to camera referenced by TangoCameraId with the latest image
/// from the camera.
@@ -129,10 +93,10 @@ public static double RenderLatestFrame(TangoEnums.TangoCameraId cameraId)
{
Debug.Log("VideoOverlayProvider.UpdateTexture() Texture was not updated by camera!");
}
-
+
return timestamp;
}
-
+
///
/// Get the intrinsic calibration parameters for a given camera.
///
@@ -153,6 +117,42 @@ public static void GetIntrinsics(TangoEnums.TangoCameraId cameraId, [Out] TangoC
}
}
+ ///
+ /// Experimental API only, subject to change. Connect a Texture IDs to a camera.
+ ///
+ /// The camera is selected via TangoCameraId. Currently only TANGO_CAMERA_COLOR is supported. The texture
+ /// handles will be regenerated by the API on startup after which the application can use them, and will be
+ /// packed RGBA8888 data containing bytes of the image (so a single RGBA8888 will pack 4 neighbouring pixels).
+ /// If the config flag experimental_image_pixel_format is set to HAL_PIXEL_FORMAT_YCrCb_420_SP, texture_y will
+ /// pack 1280x720 pixels into a 320x720 RGBA8888 texture. texture_Cb and texture_Cr will contain copies of
+ /// the 2x2 downsampled interleaved UV planes packed similarly. If experimental_image_pixel_format is set to
+ /// HAL_PIXEL_FORMAT_YV12 then texture_y will have a stride of 1536 containing 1280 columns of data, packed
+ /// similarly in a RGBA8888 texture. texture_Cb and texture_Cr will be 2x2 downsampled versions of the same.
+ /// See YV12 and NV21 formats for details.
+ ///
+ /// Note: The first scan-line of the color image is reserved for metadata instead of image pixels.
+ ///
+ ///
+ /// The ID of the camera to connect this texture to. Only TANGO_CAMERA_COLOR and TANGO_CAMERA_FISHEYE are
+ /// supported.
+ ///
+ /// The texture IDs to use for the Y, Cb, and Cr planes.
+ /// Callback.
+ internal static void ExperimentalConnectTexture(TangoEnums.TangoCameraId cameraId, YUVTexture textures, TangoService_onUnityFrameAvailable onUnityFrameAvailable)
+ {
+ int returnValue = VideoOverlayAPI.TangoService_Experimental_connectTextureIdUnity(cameraId,
+ (uint)textures.m_videoOverlayTextureY.GetNativeTextureID(),
+ (uint)textures.m_videoOverlayTextureCb.GetNativeTextureID(),
+ (uint)textures.m_videoOverlayTextureCr.GetNativeTextureID(),
+ callbackContext,
+ onUnityFrameAvailable);
+
+ if (returnValue != Common.ErrorType.TANGO_SUCCESS)
+ {
+ Debug.Log("VideoOverlayProvider.ConnectTexture() Texture was not connected to camera!");
+ }
+ }
+
///
/// Connect a callback to a camera for access to the pixels.
///
diff --git a/UnityExamples/Assets/TangoSDK/Core/Tango.dat b/UnityExamples/Assets/TangoSDK/Core/Tango.dat
index 80235af0..4cf28363 100644
--- a/UnityExamples/Assets/TangoSDK/Core/Tango.dat
+++ b/UnityExamples/Assets/TangoSDK/Core/Tango.dat
@@ -1 +1 @@
- undefined400af05release-weyl
\ No newline at end of file
+ undefinedf2877f0release-xiaotong
\ No newline at end of file
diff --git a/UnityExamples/Assets/TangoSDK/Editor/TangoInspector.cs b/UnityExamples/Assets/TangoSDK/Editor/TangoInspector.cs
index ef88ba1d..d9a26bd7 100644
--- a/UnityExamples/Assets/TangoSDK/Editor/TangoInspector.cs
+++ b/UnityExamples/Assets/TangoSDK/Editor/TangoInspector.cs
@@ -67,6 +67,8 @@ private void _DrawMotionTrackingOptions(TangoApplication tangoApplication)
tangoApplication.m_motionTrackingAutoReset = EditorGUILayout.Toggle("Auto Reset",
tangoApplication.m_motionTrackingAutoReset);
+ tangoApplication.m_enableADFLoading = EditorGUILayout.Toggle("Load ADF",
+ tangoApplication.m_enableADFLoading);
tangoApplication.m_enableAreaLearning = EditorGUILayout.Toggle("Area Learning",
tangoApplication.m_enableAreaLearning);
if (tangoApplication.m_enableAreaLearning)
diff --git a/UnityExamples/Assets/TangoSDK/TangoUX/Scripts/TangoUx.cs b/UnityExamples/Assets/TangoSDK/TangoUX/Scripts/TangoUx.cs
index 16bcd901..48409e79 100644
--- a/UnityExamples/Assets/TangoSDK/TangoUX/Scripts/TangoUx.cs
+++ b/UnityExamples/Assets/TangoSDK/TangoUX/Scripts/TangoUx.cs
@@ -19,7 +19,7 @@
namespace Tango
{
[RequireComponent(typeof(TangoApplication))]
- public class TangoUx : MonoBehaviour, ITangoPose, ITangoEvent, ITangoDepth
+ public class TangoUx : MonoBehaviour, ITangoPose, ITangoEventMultithreaded, ITangoDepth
{
public bool m_enableUXLibrary = true;
public bool m_drawDefaultUXExceptions = true;
@@ -103,7 +103,7 @@ public void OnTangoPoseAvailable(Tango.TangoPoseData poseData)
/// Raises the tango event available event handler event.
///
/// Tango event.
- public void OnTangoEventAvailableEventHandler(Tango.TangoEvent tangoEvent)
+ public void OnTangoEventMultithreadedAvailableEventHandler(Tango.TangoEvent tangoEvent)
{
if(m_enableUXLibrary)
{
diff --git a/UnityExamples/ProjectSettings/ProjectSettings.asset b/UnityExamples/ProjectSettings/ProjectSettings.asset
index 444914a0..19564494 100644
--- a/UnityExamples/ProjectSettings/ProjectSettings.asset
+++ b/UnityExamples/ProjectSettings/ProjectSettings.asset
@@ -72,14 +72,14 @@ PlayerSettings:
16:9: 1
Others: 1
bundleIdentifier: com.projecttango.unityexamples
- bundleVersion: 1.22
+ bundleVersion: 1.23
preloadedAssets: []
metroEnableIndependentInputSource: 0
metroEnableLowLatencyPresentationAPI: 0
xboxOneDisableKinectGpuReservation: 0
virtualRealitySupported: 0
productGUID: c6391136f507d40acbbba7382166aeb8
- AndroidBundleVersionCode: 22
+ AndroidBundleVersionCode: 23
AndroidMinSdkVersion: 17
AndroidPreferredInstallLocation: 1
aotOptions: