diff --git a/T3-Unity/Assets/GoogleARCore.meta b/T3-Unity/Assets/GoogleARCore.meta new file mode 100644 index 0000000000000000000000000000000000000000..ce7c2e411b1b1d824211b9db56f83fb98a9fd46a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74e4fcdb05c15f743842e3280864e8b1 +folderAsset: yes +timeCreated: 1505872011 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Configurations.meta b/T3-Unity/Assets/GoogleARCore/Configurations.meta new file mode 100644 index 0000000000000000000000000000000000000000..7417fbe0881e302c6a5a8dd849e5f382c91e04e6 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Configurations.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6b1cded3497844b35a3bfac966b428f2 +folderAsset: yes +timeCreated: 1496364746 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset b/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset new file mode 100644 index 0000000000000000000000000000000000000000..4afeb5ff73b97e5beea8bb0521f85074b4e826a1 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 53ac32fab2599402fb6d154adf4c1e40, type: 3} + m_Name: DefaultSessionConfig + m_EditorClassIdentifier: + m_matchCameraFramerate: 1 + m_enablePlaneFinding: 1 + m_enableLightEstimation: 1 diff --git a/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset.meta b/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset.meta new file mode 100644 index 0000000000000000000000000000000000000000..62f7d4c16cef3b80fc0a3159c40f0c0bf31f0b36 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Configurations/DefaultSessionConfig.asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9586a84d6c32f46b6ab7aeb6042f160d +timeCreated: 1510878073 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples.meta b/T3-Unity/Assets/GoogleARCore/Examples.meta new file mode 100644 index 0000000000000000000000000000000000000000..deafab15ccf47f489d13a928088ca03e5cd5804a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 165068a6255814b639ac5e322836d8bb +folderAsset: yes +timeCreated: 1512499966 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision.meta new file mode 100644 index 0000000000000000000000000000000000000000..5985f3e33d8fea0e2687a866b53c74b052e97495 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7af44c1128a614f72a62d613e2c5b61d +folderAsset: yes +timeCreated: 1512755870 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials.meta new file mode 100644 index 0000000000000000000000000000000000000000..e824a8c780c584746ddec4b6aef66ece4ea2ad45 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bec192a39069f44f8ae625bd826b4e53 +folderAsset: yes +timeCreated: 1501723767 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader new file mode 100644 index 0000000000000000000000000000000000000000..8597474799d176914120f5afa16207e97b95b374 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader @@ -0,0 +1,74 @@ +Shader "AREdgeDetectionBackground" +{ + Properties + { + _OverlayPercentage ("Overlay Percentage", Range (0.0, 1.0)) = 0.5 + } + + // For GLES3 + SubShader + { + Pass + { + ZWrite Off + + GLSLPROGRAM + + #pragma only_renderers gles3 + + #ifdef SHADER_API_GLES3 + #extension GL_OES_EGL_image_external_essl3 : require + #endif + + uniform vec4 _UvTopLeftRight; + uniform vec4 _UvBottomLeftRight; + + #ifdef VERTEX + + #define kPortrait 1.0 + #define kPortraitUpsideDown 2.0 + #define kLandscapeLeft 3.0 + #define kLandscapeRight 4.0 + + varying vec2 textureCoord; + + void main() + { + #ifdef SHADER_API_GLES3 + vec2 uvTop = mix(_UvTopLeftRight.xy, _UvTopLeftRight.zw, gl_MultiTexCoord0.x); + vec2 uvBottom = mix(_UvBottomLeftRight.xy, _UvBottomLeftRight.zw, gl_MultiTexCoord0.x); + textureCoord = mix(uvTop, uvBottom, gl_MultiTexCoord0.y); + + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + #endif + } + + #endif + + #ifdef FRAGMENT + varying vec2 textureCoord; + uniform samplerExternalOES _MainTex; + uniform sampler2D _ImageTex; + uniform float _OverlayPercentage; + + void main() + { + #ifdef SHADER_API_GLES3 + if (textureCoord.x < _OverlayPercentage) + gl_FragColor = texture(_MainTex, textureCoord); + else + { + vec4 color = texture2D(_ImageTex, textureCoord); + gl_FragColor.xyz = color.xxx; + } + #endif + } + + #endif + + ENDGLSL + } + } + + FallBack Off +} diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader.meta new file mode 100644 index 0000000000000000000000000000000000000000..9a4f035b1dd21b135a4941f46ccbe34846384cba --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackground.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7004efaaedb14dfcba62eea5c70c9d2 +timeCreated: 1512500068 +licenseType: Pro +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat new file mode 100644 index 0000000000000000000000000000000000000000..05303003be8683bc0b3f3ae29bf7e4df9f01bd65 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: AREdgeDetectionBackgroundMaterial + m_Shader: {fileID: 4800000, guid: b7004efaaedb14dfcba62eea5c70c9d2, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat.meta new file mode 100644 index 0000000000000000000000000000000000000000..cc16df134772628a9235a66616db95e3d8ad0658 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Materials/AREdgeDetectionBackgroundMaterial.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 44aa46aeaaf4d46a79e18f3e2da31ccc +timeCreated: 1512581681 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins.meta new file mode 100644 index 0000000000000000000000000000000000000000..f2d4ad93e5cba08293e987d165bf1321c25b1521 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5c8e17f48a997417eac4ae975493b6a1 +folderAsset: yes +timeCreated: 1511980390 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so new file mode 100644 index 0000000000000000000000000000000000000000..139eb4d953cc2308af9a458b2b79440b7e88b7d0 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so differ diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so.meta new file mode 100644 index 0000000000000000000000000000000000000000..484e574e6b5b34c5a3300ee84ee3383e64463147 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/libarcore_camera_utility.so.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: f10dd41e5f6ea4c76829088acdb03eb3 +timeCreated: 1512072454 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 0 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Android: Android + second: + enabled: 1 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src.meta new file mode 100644 index 0000000000000000000000000000000000000000..3f822d23e4f31f9ff20967e8260ab5d6aff0ca6e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 88691640f915f42f6937d8d0122d69bd +folderAsset: yes +timeCreated: 1513277705 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bb0aeeb7bcb47982c099555b79c3e6fa93be4af7 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md @@ -0,0 +1,32 @@ +Google ARCore Camera Utility Plugin Source Code +================================================ +Copyright (c) 2017 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. + +## Overview +The arcore_camera_unity.zip file contains source code of the libarcore_camera_utility.so +C library. This library is used to create the Unity plugin for reading image pixels from +ARCore GPU texture. + +## Files Included +- include/camera_utility.h : header file of the C API interface. +- include/gl_utility.h : header file of GL utility functions. +- include/texture_reader.h : header file of C++ API interface. +- src/camera_utility.cc : implementation of the C API. +- src/gl_utility.cc : implementation of GL utility functions. +- src/texture_reader.cc : implementation of C++ API. + +## How to Build +You can build the library by using Google Android NDK(https://developer.android.com/ndk/index.html). +Google Android NDK can be downloaded from this URL(https://developer.android.com/ndk/downloads/index.html). \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md.meta new file mode 100644 index 0000000000000000000000000000000000000000..5429e512b22a89720230f4dbdf295d38bcd47d64 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/README.md.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fe5fc815b621d4801ac251a35d054ac1 +timeCreated: 1513277715 +licenseType: Pro +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip new file mode 100644 index 0000000000000000000000000000000000000000..a77736e073805ecbd204c112b2ae5641cf39e15b Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip differ diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip.meta new file mode 100644 index 0000000000000000000000000000000000000000..da5e89a56ea915e0c5c04d8cc743fe30df737024 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 218bec0cf31a949a18e480486444ca54 +timeCreated: 1513277705 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes.meta new file mode 100644 index 0000000000000000000000000000000000000000..b9ff2810919f198a9a197580ab035de5be3632db --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ed63ed01b7e4c427d8d897825c5ed5dd +folderAsset: yes +timeCreated: 1501206008 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity new file mode 100644 index 0000000000000000000000000000000000000000..e75eb21193eb8aa566a5c986cef02f5fa2fa3b32 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity @@ -0,0 +1,202 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 8 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.37311947, g: 0.38074005, b: 0.35872722, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 9 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1001 &60865845 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4892153982037908, guid: c10877f7cd5764de18d46d7b777d1faa, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 114923820857209294, guid: c10877f7cd5764de18d46d7b777d1faa, + type: 2} + propertyPath: BackgroundMaterial + value: + objectReference: {fileID: 2100000, guid: 44aa46aeaaf4d46a79e18f3e2da31ccc, type: 2} + - target: {fileID: 114876698896786350, guid: c10877f7cd5764de18d46d7b777d1faa, + type: 2} + propertyPath: BackgroundMaterial + value: + objectReference: {fileID: 2100000, guid: 44aa46aeaaf4d46a79e18f3e2da31ccc, type: 2} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: c10877f7cd5764de18d46d7b777d1faa, type: 2} + m_IsPrefabParent: 0 +--- !u!114 &517579873 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 114876698896786350, guid: c10877f7cd5764de18d46d7b777d1faa, + type: 2} + m_PrefabInternal: {fileID: 60865845} + m_Script: {fileID: 11500000, guid: eb172c260d42e4f62945afda50892c0c, type: 3} +--- !u!1 &1465104021 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1465104022} + - component: {fileID: 1465104023} + - component: {fileID: 1465104024} + m_Layer: 0 + m_Name: ComputerVisionController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1465104022 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1465104021} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1465104023 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1465104021} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0471ee42f4eac4098805c8b4aae4875c, type: 3} + m_Name: + m_EditorClassIdentifier: + TextureReaderComponent: {fileID: 1465104024} + BackgroundRenderer: {fileID: 517579873} +--- !u!114 &1465104024 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1465104021} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b8ba03f2a23f74384ac6625e269b5f50, type: 3} + m_Name: + m_EditorClassIdentifier: + ImageWidth: 1024 + ImageHeight: 512 + ImageSampleMode: 1 + ImageFormat: 1 diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity.meta new file mode 100644 index 0000000000000000000000000000000000000000..37f9d04e748fe0f6fdab175a7ba721633c1423ce --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scenes/ComputerVision.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5ef0f7f7f2c7b4285b707265348bbffd +timeCreated: 1512755571 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts.meta new file mode 100644 index 0000000000000000000000000000000000000000..3f3f725df7bcafddb8b6f822388c766aac8afcc5 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 02f1f705271f6408cb81efb900b3b2bb +folderAsset: yes +timeCreated: 1501723747 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs new file mode 100644 index 0000000000000000000000000000000000000000..0f9b12ab9e1626e06a14910637c6671800a58347 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs @@ -0,0 +1,221 @@ +//----------------------------------------------------------------------- +// <copyright file="ComputerVisionController.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore.TextureReader +{ + using System; + using System.Collections.Generic; + using GoogleARCore; + using UnityEngine; + using UnityEngine.Rendering; + + /// <summary> + /// Controlls the ComputerVision example. + /// </summary> + public class ComputerVisionController : MonoBehaviour + { + /// <summary> + /// The TextureReader component instance. + /// </summary> + public TextureReader TextureReaderComponent; + + /// <summary> + /// Background renderer to inject our texture into. + /// </summary> + public ARCoreBackgroundRenderer BackgroundRenderer; + + /// <summary> + /// True if the app is in the process of quitting due to an ARCore connection error, otherwise false. + /// </summary> + private bool m_IsQuitting = false; + + /// <summary> + /// Texture created from filtered camera image. + /// </summary> + private Texture2D m_TextureToRender = null; + private int m_ImageWidth = 0; + private int m_ImageHeight = 0; + private byte[] m_EdgeImage = null; + private float m_SwipeMomentum = 0.0f; + + /// <summary> + /// Start is called on the frame when a script is enabled just before + /// any of the Update methods is called the first time. + /// </summary> + public void Start() + { + // Registers the TextureReader callback. + TextureReaderComponent.OnImageAvailableCallback += OnImageAvailable; + Screen.sleepTimeout = SleepTimeout.NeverSleep; + } + + /// <summary> + /// The Unity Update() method. + /// </summary> + public void Update() + { + if (Input.GetKey(KeyCode.Escape)) + { + Application.Quit(); + } + + _QuitOnConnectionErrors(); + _HandleTouchInput(); + } + + /// <summary> + /// TextureReader callback handler. + /// </summary> + /// <param name="format">The format of the image.</param> + /// <param name="width">Width of the image, in pixels.</param> + /// <param name="height">Height of the image, in pixels.</param> + /// <param name="pixelBuffer">Pointer to raw image buffer.</param> + /// <param name="bufferSize">The size of the image buffer, in bytes.</param> + public void OnImageAvailable(TextureReaderApi.ImageFormatType format, int width, int height, IntPtr pixelBuffer, int bufferSize) + { + if (format != TextureReaderApi.ImageFormatType.ImageFormatGrayscale) + { + Debug.Log("No edge detected due to incorrect image format."); + return; + } + + if (m_TextureToRender == null || m_EdgeImage == null || m_ImageWidth != width || m_ImageHeight != height) + { + m_TextureToRender = new Texture2D(width, height, TextureFormat.R8, false, false); + m_EdgeImage = new byte[width * height]; + m_ImageWidth = width; + m_ImageHeight = height; + } + + // Detect edges within the image. + if (EdgeDetector.Detect(m_EdgeImage, pixelBuffer, width, height)) + { + // Update the rendering texture with the edge image. + m_TextureToRender.LoadRawTextureData(m_EdgeImage); + m_TextureToRender.Apply(); + BackgroundRenderer.BackgroundMaterial.SetTexture("_ImageTex", m_TextureToRender); + } + } + + /// <summary> + /// Show an Android toast message. + /// </summary> + /// <param name="message">Message string to show in the toast.</param> + private static void _ShowAndroidToastMessage(string message) + { + AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaObject unityActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); + + if (unityActivity != null) + { + AndroidJavaClass toastClass = new AndroidJavaClass("android.widget.Toast"); + unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() => + { + AndroidJavaObject toastObject = toastClass.CallStatic<AndroidJavaObject>("makeText", unityActivity, + message, 0); + toastObject.Call("show"); + })); + } + } + + /// <summary> + /// Handles detecting touch input to control the edge detection effect. + /// </summary> + private void _HandleTouchInput() + { + const float SWIPE_SCALING_FACTOR = 1.15f; + const float INTERTIAL_CANCELING_FACTOR = 2.0f; + const float MINIMUM_MOMENTUM = .01f; + + if (Input.touchCount == 0) + { + m_SwipeMomentum /= INTERTIAL_CANCELING_FACTOR; + } + else + { + m_SwipeMomentum = _GetTouchDelta(); + m_SwipeMomentum *= SWIPE_SCALING_FACTOR; + } + + if (Mathf.Abs(m_SwipeMomentum) < MINIMUM_MOMENTUM) + { + m_SwipeMomentum = 0; + } + + var overlayPercentage = BackgroundRenderer.BackgroundMaterial.GetFloat("_OverlayPercentage"); + overlayPercentage -= m_SwipeMomentum; + BackgroundRenderer.BackgroundMaterial.SetFloat("_OverlayPercentage", Mathf.Clamp(overlayPercentage, 0.0f, 1.0f)); + } + + /// <summary> + /// Gets the delta touch as a percentage of the screen. + /// </summary> + /// <returns>The delta touch as a percentage of the screen.</returns> + private float _GetTouchDelta() + { + switch (Screen.orientation) + { + case ScreenOrientation.LandscapeLeft: + return -Input.GetTouch(0).deltaPosition.x / Screen.width; + case ScreenOrientation.LandscapeRight: + return Input.GetTouch(0).deltaPosition.x / Screen.width; + case ScreenOrientation.Portrait: + return Input.GetTouch(0).deltaPosition.y / Screen.height; + case ScreenOrientation.PortraitUpsideDown: + return -Input.GetTouch(0).deltaPosition.y / Screen.height; + default: + return 0; + } + } + + /// <summary> + /// Actually quit the application. + /// </summary> + private void DoQuit() + { + Application.Quit(); + } + + /// <summary> + /// Quit the application if there was a connection error for the ARCore session. + /// </summary> + private void _QuitOnConnectionErrors() + { + if (m_IsQuitting) + { + return; + } + + // Quit if ARCore was unable to connect and give Unity some time for the toast to appear. + if (Session.Status == SessionStatus.ErrorPermissionNotGranted) + { + _ShowAndroidToastMessage("Camera permission is needed to run this application."); + m_IsQuitting = true; + Invoke("DoQuit", 0.5f); + } + else if (Session.Status == SessionStatus.FatalError) + { + _ShowAndroidToastMessage("ARCore encountered a problem connecting. Please start the app again."); + m_IsQuitting = true; + Invoke("DoQuit", 0.5f); + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..820912a00b091f15838dbafa9c7fe9b6260aa142 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/ComputerVisionController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0471ee42f4eac4098805c8b4aae4875c +timeCreated: 1512755448 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs new file mode 100644 index 0000000000000000000000000000000000000000..13be4ec1bd9bdea1918d5112a1ed4f35c0bf4617 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------- +// <copyright file="EdgeDetector.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- +namespace GoogleARCore.TextureReader +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Text; + using UnityEngine; + + /// <summary> + /// Detects edges from input grayscale image. + /// </summary> + public class EdgeDetector + { + private static byte[] s_ImageBuffer = new byte[0]; + private static int s_ImageBufferSize = 0; + + /// <summary> + /// Detects edges from input grayscale image. + /// </summary> + /// <param name="outputImage">Output image buffer, which has a size of width * height.</param> + /// <param name="pixelBuffer">Pointer to raw image buffer, assuming one byte per pixel.</param> + /// <param name="width">Width of the input image, in pixels.</param> + /// <param name="height">Height of the input image, in pixels.</param> + /// <returns>False if the outputImage buffer is too small, True otherwise.</returns> + public static bool Detect(byte[] outputImage, IntPtr pixelBuffer, int width, int height) + { + if (outputImage.Length < width * height) + { + Debug.Log("Input buffer is too small!"); + return false; + } + + Sobel(outputImage, pixelBuffer, width, height); + + return true; + } + + private static void Sobel(byte[] outputImage, IntPtr inputImage, int width, int height) + { + // Adjust buffer size if necessary. + int bufferSize = width * height; + if (bufferSize != s_ImageBufferSize || s_ImageBuffer.Length == 0) + { + s_ImageBufferSize = bufferSize; + s_ImageBuffer = new byte[bufferSize]; + } + + // Move raw data into managed buffer. + System.Runtime.InteropServices.Marshal.Copy(inputImage, s_ImageBuffer, 0, bufferSize); + + // Detect edges. + int threshold = 128 * 128; + + for (int j = 1; j < height - 1; j++) + { + for (int i = 1; i < width - 1; i++) + { + // Offset of the pixel at [i, j] of the input image. + int offset = (j * width) + i; + + // Neighbour pixels around the pixel at [i, j]. + int a00 = s_ImageBuffer[offset - width - 1]; + int a01 = s_ImageBuffer[offset - width]; + int a02 = s_ImageBuffer[offset - width + 1]; + int a10 = s_ImageBuffer[offset - 1]; + int a12 = s_ImageBuffer[offset + 1]; + int a20 = s_ImageBuffer[offset + width - 1]; + int a21 = s_ImageBuffer[offset + width]; + int a22 = s_ImageBuffer[offset + width + 1]; + + // Sobel X filter: + // -1, 0, 1, + // -2, 0, 2, + // -1, 0, 1 + int xSum = -a00 - (2 * a10) - a20 + a02 + (2 * a12) + a22; + + // Sobel Y filter: + // 1, 2, 1, + // 0, 0, 0, + // -1, -2, -1 + int ySum = a00 + (2 * a01) + a02 - a20 - (2 * a21) - a22; + + if ((xSum * xSum) + (ySum * ySum) > threshold) + { + outputImage[(j * width) + i] = 0xFF; + } + else + { + outputImage[(j * width) + i] = 0x1F; + } + } + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..564dbbec1a5362ae3adb3fab020871384639193a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/EdgeDetector.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4efa5fefaf4064b6f944e9c9d1803813 +timeCreated: 1512175258 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..fa36c610fc55f349c83bb2b1446348431f1ab2bd --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs @@ -0,0 +1,214 @@ +//----------------------------------------------------------------------- +// <copyright file="TextureReader.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- +namespace GoogleARCore.TextureReader +{ + using System; + using System.Collections.Generic; + using GoogleARCore; + using UnityEngine; + using UnityEngine.Rendering; + + /// <summary> + /// Component that provides CPU access to ArCore GPU texture. + /// </summary> + public class TextureReader : MonoBehaviour + { + /// <summary> + /// Output image width, in pixels. + /// </summary> + public int ImageWidth = k_ARCoreTextureWidth; + + /// <summary> + /// Output image height, in pixels. + /// </summary> + public int ImageHeight = k_ARCoreTextureHeight; + + /// <summary> + /// Output image sampling option. + /// </summary> + public SampleMode ImageSampleMode = SampleMode.CoverFullViewport; + + /// <summary> + /// Output image format. + /// </summary> + public TextureReaderApi.ImageFormatType ImageFormat = TextureReaderApi.ImageFormatType.ImageFormatGrayscale; + + private const int k_ARCoreTextureWidth = 1920; + private const int k_ARCoreTextureHeight = 1080; + + private TextureReaderApi m_TextureReaderApi = null; + + private CommandType m_Command = CommandType.None; + + private int m_ImageBufferIndex = -1; + + /// <summary> + /// Callback function type for receiving the output images. + /// </summary> + /// <param name="format">The format of the image.</param> + /// <param name="width">The width of the image, in pixels.</param> + /// <param name="height">The height of the image, in pixels.</param> + /// <param name="pixelBuffer">The pointer to the raw buffer of the image pixels.</param> + /// <param name="bufferSize">The size of the image buffer, in bytes.</param> + public delegate void OnImageAvailableCallbackFunc(TextureReaderApi.ImageFormatType format, int width, int height, IntPtr pixelBuffer, int bufferSize); + + /// <summary> + /// Callback function handle for receiving the output images. + /// </summary> + public event OnImageAvailableCallbackFunc OnImageAvailableCallback = null; + + /// <summary> + /// Options to sample the output image. + /// </summary> + public enum SampleMode + { + /// <summary> + /// Keeps the same aspect ratio as the GPU texture. Crop image if necessary. + /// </summary> + KeepAspectRatio, + + /// <summary> + /// Samples the entire texture and does not crop. The aspect ratio may be different from the texture aspect ratio. + /// </summary> + CoverFullViewport + } + + private enum CommandType + { + None, + ProcessNextFrame, + Create, + Reset, + ReleasePreviousBuffer + } + + /// <summary> + /// Start is called on the frame when a script is enabled just before + /// any of the Update methods is called the first time. + /// </summary> + public void Start() + { + if (m_TextureReaderApi == null) + { + m_TextureReaderApi = new TextureReaderApi(); + m_Command = CommandType.Create; + m_ImageBufferIndex = -1; + } + } + + /// <summary> + /// This function should be called after any public property is changed. + /// </summary> + public void Apply() + { + m_Command = CommandType.Reset; + } + + /// <summary> + /// Update is called every frame, if the MonoBehaviour is enabled. + /// </summary> + public void Update() + { + if (!enabled) + { + return; + } + + // Process command. + switch (m_Command) + { + case CommandType.Create: + { + m_TextureReaderApi.Create(ImageFormat, ImageWidth, ImageHeight, ImageSampleMode == SampleMode.KeepAspectRatio); + break; + } + + case CommandType.Reset: + { + m_TextureReaderApi.ReleaseFrame(m_ImageBufferIndex); + m_TextureReaderApi.Destroy(); + m_TextureReaderApi.Create(ImageFormat, ImageWidth, ImageHeight, ImageSampleMode == SampleMode.KeepAspectRatio); + m_ImageBufferIndex = -1; + break; + } + + case CommandType.ReleasePreviousBuffer: + { + // Clear previously used buffer, and submits a new request. + m_TextureReaderApi.ReleaseFrame(m_ImageBufferIndex); + m_ImageBufferIndex = -1; + break; + } + + case CommandType.ProcessNextFrame: + { + if (m_ImageBufferIndex >= 0) + { + // Get image pixels from previously submitted request. + int bufferSize = 0; + IntPtr pixelBuffer = m_TextureReaderApi.AcquireFrame(m_ImageBufferIndex, ref bufferSize); + + if (pixelBuffer != IntPtr.Zero && OnImageAvailableCallback != null) + { + OnImageAvailableCallback(ImageFormat, ImageWidth, ImageHeight, pixelBuffer, bufferSize); + } + + // Release the texture reader internal buffer. + m_TextureReaderApi.ReleaseFrame(m_ImageBufferIndex); + } + + break; + } + + case CommandType.None: + default: + break; + } + + // Submit reading request for the next frame. + int textureId = Frame.CameraImage.Texture.GetNativeTexturePtr().ToInt32(); + m_ImageBufferIndex = m_TextureReaderApi.SubmitFrame(textureId, k_ARCoreTextureWidth, k_ARCoreTextureHeight); + + // Set next command. + m_Command = CommandType.ProcessNextFrame; + } + + /// <summary> + /// This function is called when the MonoBehaviour will be destroyed. + /// </summary> + private void OnDestroy() + { + if (m_TextureReaderApi != null) + { + m_TextureReaderApi.Destroy(); + m_TextureReaderApi = null; + } + } + + /// <summary> + /// This function is called when the behaviour becomes disabled or inactive. + /// </summary> + private void OnDisable() + { + // Force to release previously used buffer. + m_Command = CommandType.ReleasePreviousBuffer; + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e3a9262cf9376e3da9cd2b62719371c9b18b7773 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReader.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b8ba03f2a23f74384ac6625e269b5f50 +timeCreated: 1512525798 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..8d53ebbc255c5eed039ce2bb7b65435859049b97 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs @@ -0,0 +1,130 @@ +//----------------------------------------------------------------------- +// <copyright file="TextureReaderApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- +namespace GoogleARCore.TextureReader +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + /// <summary> + /// API that provides CPU access to GPU texture. + /// </summary> + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class TextureReaderApi + { + /// <summary> + /// Image format type. + /// </summary> + public enum ImageFormatType + { + /// <summary> + /// Color image pixel format. Four bytes per pixel, in the order of R, G, B, and A. + /// </summary> + ImageFormatColor = 0, + + /// <summary> + /// Grayscale image pixel format. One byte per pixel. + /// </summary> + ImageFormatGrayscale = 1 + } + + /// <summary> + /// Creates the texture reader instance. + /// </summary> + /// <param name="format">Format of the output image pixel. Can be either eImageFormat_RGBA or eImageFormat_I8.</param> + /// <param name="width">Width of the output image, in pixels.</param> + /// <param name="height">Height of the output image, in pixels.</param> + /// <param name="keepAspectRatio">Indicate whether or not to keep aspect ratio. If true, the output image may be cropped + /// if the image aspect ratio is different from the texture aspect ratio. If false, the output image covers the entire + /// texture scope and no cropping is applied.</param> + public void Create(ImageFormatType format, int width, int height, bool keepAspectRatio) + { + ExternApi.TextureReader_create((int)format, width, height, keepAspectRatio); + } + + /// <summary> + /// Destroys the texture reader instance and release internal resources. + /// </summary> + public void Destroy() + { + ExternApi.TextureReader_destroy(); + } + + /// <summary> + /// Submits a texture reading request to GPU driver. The result of this request will be available in the next + /// frame through AcquireFrame(). + /// </summary> + /// <param name="textureId">The GLES texture id of the input camera texture. It has to be created as OES texture.</param> + /// <param name="textureWidth">Width of the texture, in pixels.</param> + /// <param name="textureHeight">Height of the texture, in pixels.</param> + /// <returns>The frame buffer index, which can be used to retrieve the frame later through AcquireFrame(). -1 if the submission fails.</returns> + public int SubmitFrame(int textureId, int textureWidth, int textureHeight) + { + int bufferIndex = ExternApi.TextureReader_submitFrame(textureId, textureWidth, textureHeight); + GL.InvalidateState(); + return bufferIndex; + } + + /// <summary> + /// Acquires the output image pixels from a previous reading request. + /// </summary> + /// <param name="bufferIndex">The buffer index required by previous call to SubmitFrame().</param> + /// <param name="bufferSize">The size of the output image pixel buffer, in bytes.</param> + /// <returns>The pointer to the raw buffer of the output image. null if fails.</returns> + public IntPtr AcquireFrame(int bufferIndex, ref int bufferSize) + { + IntPtr pixelBuffer = ExternApi.TextureReader_acquireFrame(bufferIndex, ref bufferSize); + return pixelBuffer; + } + + /// <summary> + /// Releases a previously used frame buffer. + /// </summary> + /// <param name="bufferIndex">The buffer index required by previous call to SubmitFrame().</param> + public void ReleaseFrame(int bufferIndex) + { + ExternApi.TextureReader_releaseFrame(bufferIndex); + } + + private struct ExternApi + { + public const string ARCoreCameraUtilityAPI = "arcore_camera_utility"; + + [DllImport(ARCoreCameraUtilityAPI)] + public static extern void TextureReader_create(int format, int width, int height, bool keepAspectRatio); + + [DllImport(ARCoreCameraUtilityAPI)] + public static extern void TextureReader_destroy(); + + [DllImport(ARCoreCameraUtilityAPI)] + public static extern int TextureReader_submitFrame(int textureId, int textureWidth, int textureHeight); + + [DllImport(ARCoreCameraUtilityAPI)] + public static extern IntPtr TextureReader_acquireFrame(int bufferIndex, ref int bufferSize); + + [DllImport(ARCoreCameraUtilityAPI)] + public static extern void TextureReader_releaseFrame(int bufferIndex); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs.meta b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6980ec53a493d1c27bae32a1a1fc8ffc078a94cb --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Examples/ComputerVision/Scripts/TextureReaderApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b6c5057504d004df59cb05eeea4454ae +timeCreated: 1511999811 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Prefabs.meta b/T3-Unity/Assets/GoogleARCore/Prefabs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8d31210512e9e18e312efe5dd7892d038c3e430c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Prefabs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a00108229b1e04acd805e57abcdff773 +folderAsset: yes +timeCreated: 1492558533 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab b/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab new file mode 100644 index 0000000000000000000000000000000000000000..b1f1c63bd5f7443a7f801e699d98f11b762ff156 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab @@ -0,0 +1,150 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1772147192650458} + m_IsPrefabParent: 1 +--- !u!1 &1637996540812124 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4497055787654456} + - component: {fileID: 20155940112608238} + - component: {fileID: 114963366853050710} + - component: {fileID: 114876698896786350} + m_Layer: 0 + m_Name: First Person Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1772147192650458 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4442908887562770} + - component: {fileID: 114451889682527732} + m_Layer: 0 + m_Name: ARCore Device + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4442908887562770 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1772147192650458} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4497055787654456} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4497055787654456 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1637996540812124} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4442908887562770} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &20155940112608238 +Camera: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1637996540812124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.05 + far clip plane: 200 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!114 &114451889682527732 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1772147192650458} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d4ca0c6a3af6b4635b7e98c6ea0a0cf9, type: 3} + m_Name: + m_EditorClassIdentifier: + SessionConfig: {fileID: 11400000, guid: 9586a84d6c32f46b6ab7aeb6042f160d, type: 2} +--- !u!114 &114876698896786350 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1637996540812124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eb172c260d42e4f62945afda50892c0c, type: 3} + m_Name: + m_EditorClassIdentifier: + BackgroundMaterial: {fileID: 2100000, guid: 03ad0130a037647aeb60218f61aca114, type: 2} +--- !u!114 &114963366853050710 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1637996540812124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1742909100, guid: 3a84de5cd0624681b6b6dcd8921d912a, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Device: 0 + m_PoseSource: 6 + m_TrackingType: 0 + m_UpdateType: 2 + m_UseRelativeTransform: 1 diff --git a/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab.meta b/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..2b3afe23b64adfe7e042fdd7ac954fc4a369ba13 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Prefabs/ARCore Device.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c10877f7cd5764de18d46d7b777d1faa +timeCreated: 1501460862 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab b/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab new file mode 100644 index 0000000000000000000000000000000000000000..f61b71f31b6ee90360bed8e2d523c0cd4b967717 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1248447649449928} + m_IsPrefabParent: 1 +--- !u!1 &1248447649449928 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4461716624848968} + - component: {fileID: 114136752755502098} + m_Layer: 0 + m_Name: Environmental Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4461716624848968 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1248447649449928} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114136752755502098 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1248447649449928} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 92a4cf446a0c7334aaceb5457be27894, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab.meta b/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..9b0bf7867ab5149472598273ab8d9459ff5dad39 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/Prefabs/Environmental Light.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: cf498fc35b538884db557f7a9a2c0ef9 +timeCreated: 1512062703 +licenseType: Pro +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK.meta b/T3-Unity/Assets/GoogleARCore/SDK.meta new file mode 100644 index 0000000000000000000000000000000000000000..f9de22ba7c17df563fa837ccc27a59510d12f44c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 84e45386d8da3497591c38deb2bccd02 +folderAsset: yes +timeCreated: 1502400656 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview.meta new file mode 100644 index 0000000000000000000000000000000000000000..4a8208577fff48bdff9cbf3dc3a66ba635d2ffc5 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1e9a08d000a446c9ad506ecb3a4d083 +folderAsset: yes +timeCreated: 1513969093 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins.meta new file mode 100644 index 0000000000000000000000000000000000000000..6d4a6474e8e704a4e8a0c09a12bbc45a90eb2f95 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ede998a9371e74aa6a759743f41b3eb6 +folderAsset: yes +timeCreated: 1513969093 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64.meta new file mode 100644 index 0000000000000000000000000000000000000000..ed36e881095a1e4524b8cc9fdc6e03f1ca054401 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 42098948be8564f678777d26e6906df3 +folderAsset: yes +timeCreated: 1513969093 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll new file mode 100644 index 0000000000000000000000000000000000000000..2e6e5f7e4c68945a8dbe63b0596c5ed7b100c33b Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll.meta new file mode 100644 index 0000000000000000000000000000000000000000..aa02256a0f517de25339b576d71f367bee2e4de4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_shared.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: 3a5f7d59b4b729446a1d2a9999f62bdb +timeCreated: 1513200317 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle.meta new file mode 100644 index 0000000000000000000000000000000000000000..0683b5e74ce15d5bee0f0d34ee1880066a2290f1 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle.meta @@ -0,0 +1,101 @@ +fileFormatVersion: 2 +guid: 1785ef67a37b1402f8f80e1f0658e486 +folderAsset: yes +timeCreated: 1515110710 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + '': OSXIntel + second: + enabled: 0 + settings: + CPU: None + - first: + '': OSXIntel64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: OSX + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents.meta new file mode 100644 index 0000000000000000000000000000000000000000..cdd5fcc29ed7f733d9387e8b7179542feabc148f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c22c793c4b5f447bbb532e92cb93d5ac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS.meta new file mode 100644 index 0000000000000000000000000000000000000000..ff6f0ebec2b289a2352955bbfb6f079ad7ef2ec8 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 33d076be2f74340b98cb58cefe9122f7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin new file mode 100644 index 0000000000000000000000000000000000000000..5e21d15e50ba619b8ba89955497d7c98a969f3a2 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin.meta new file mode 100644 index 0000000000000000000000000000000000000000..9eab1b00435c383d3b5c8d2c2128bd07312c72fa --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/instant_preview_unity_plugin.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 27a7f7613c41541ef8517d1b5390962b +timeCreated: 1516418595 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib new file mode 100644 index 0000000000000000000000000000000000000000..a2c5a41e00e785613d6cdc1307ab65cffeea2394 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib.meta new file mode 100644 index 0000000000000000000000000000000000000000..481ccf42dc4e2fddef4208fd8e54531fecb7af28 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.bundle/Contents/MacOS/libinstant_preview_shared.dylib.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9a49dee3272c24e7794351bb17e92bd3 +timeCreated: 1516418595 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll new file mode 100644 index 0000000000000000000000000000000000000000..06e20566657f848e1d7595a49e2ca2e10740bb41 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll.meta new file mode 100644 index 0000000000000000000000000000000000000000..54fbaede5711aea33c754f9cd774037a409e8cc9 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Plugins/x86_64/instant_preview_unity_plugin.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: d80cb1919279b7348924bc747e2ada70 +timeCreated: 1513200317 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts.meta new file mode 100644 index 0000000000000000000000000000000000000000..c1960e6410fb7f0bbd1dec91a6b028370b9aa128 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a10b012db03ac404a87dcb0519846527 +folderAsset: yes +timeCreated: 1513969093 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs new file mode 100644 index 0000000000000000000000000000000000000000..f628d10a7cb7eec02a2193e789253303c72dba95 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs @@ -0,0 +1,186 @@ +//----------------------------------------------------------------------- +// <copyright file="InstantPreviewInput.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Helper class that provides touch input in lieu of Input.GetTouch when + /// running the Unity Editor. + /// </summary> + public static class InstantPreviewInput + { + private static Touch[] s_Touches = new Touch[0]; + + /// <summary> + /// Gets the available touch inputs from Instant Preview since the last + /// update. + /// </summary> + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overridden field.")] + public static Touch[] touches + { + get + { + return s_Touches; + } + } + + /// <summary> + /// Gets the number of touches available from Instant preview since the + /// last update. + /// </summary> + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overridden field.")] + public static int touchCount + { + get + { + return touches.Length; + } + } + + /// <summary> + /// Gets return value of Input.mousePosition. + /// </summary> + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overridden field.")] + public static Vector3 mousePosition + { + get + { + return Input.mousePosition; + } + } + + /// <summary> + /// Gets a value indicating whether a mouse device is detected. + /// </summary> + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overridden field.")] + public static bool mousePresent + { + get + { + return Input.mousePresent; + } + } + + /// <summary> + /// Gets a specific touch input from Instant Preview by index. + /// </summary> + /// <param name="index">Index of touch input to get.</param> + /// <returns>Touch data.</returns> + public static Touch GetTouch(int index) + { + return touches[index]; + } + + /// <summary> + /// Passthrough function to Input.GetKey. + /// </summary> + /// <param name="keyCode">Key parameter to pass to Input.GetKey.</param> + /// <returns>Key state returned from Input.GetKey.</returns> + public static bool GetKey(KeyCode keyCode) + { + return Input.GetKey(keyCode); + } + + /// <summary> + /// Passthrough function to Input.GetMouseButton. + /// </summary> + /// <param name="button">Button index.</param> + /// <returns>Return value of Input.GetMouseButton.</returns> + public static bool GetMouseButton(int button) + { + return Input.GetMouseButton(button); + } + + /// <summary> + /// Passthrough function to Input.GetMouseButtonDown. + /// </summary> + /// <param name="button">Button index.</param> + /// <returns>Return value of Input.GetMouseButtonDown.</returns> + public static bool GetMouseButtonDown(int button) + { + return Input.GetMouseButtonDown(button); + } + + /// <summary> + /// Passthrough function to Input.GetMouseButtonUp. + /// </summary> + /// <param name="button">Button index.</param> + /// <returns>Return value of Input.GetMouseButtonUp.</returns> + public static bool GetMouseButtonUp(int button) + { + return Input.GetMouseButtonUp(button); + } + + /// <summary> + /// Refreshes touch inputs from Instant Preview to reflect the state + /// since the last time Update was called. + /// </summary> + public static void Update() + { + if (!Application.isEditor) + { + return; + } + + IntPtr nativeTouchesPtr; + int nativeTouchCount; + NativeApi.GetTouches(out nativeTouchesPtr, out nativeTouchCount); + + var structSize = Marshal.SizeOf(typeof(NativeTouch)); + s_Touches = new Touch[nativeTouchCount]; + for (var i = 0; i < nativeTouchCount; ++i) + { + var source = new IntPtr(nativeTouchesPtr.ToInt64() + (i * structSize)); + var nativeTouch = (NativeTouch)Marshal.PtrToStructure(source, typeof(NativeTouch)); + + s_Touches[i] = new Touch() + { + phase = nativeTouch.Phase, + + // Note that the Unity's screen coordinate (0, 0) starts from bottom left. + position = new Vector2(nativeTouch.X, Screen.height - nativeTouch.Y), + }; + } + } + + private struct NativeTouch + { + public TouchPhase Phase; + public float X; + public float Y; + } + + private struct NativeApi + { + [DllImport(InstantPreviewManager.InstantPreviewNativeApi)] + public static extern void GetTouches(out IntPtr touches, out int count); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..040ca2529211aa7652a600c27f9e39c9fcf91203 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ed2d2995c742a6c4490fa51080dbf4cf +timeCreated: 1512422473 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..a3d84f8b71b650d1867b55683b1ee4b6d658c843 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs @@ -0,0 +1,470 @@ +//----------------------------------------------------------------------- +// <copyright file="InstantPreviewManager.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections; + using System.IO; + using System.Runtime.InteropServices; + using System.Text; + using System.Threading; + using GoogleARCore; + using UnityEngine; + using UnityEngine.Rendering; + using UnityEngine.SpatialTracking; + + /// <summary> + /// Contains methods for managing communication to the Instant Preview + /// plugin. + /// </summary> + public static class InstantPreviewManager + { + /// <summary> + /// Name of the Instant Preview plugin library. + /// </summary> + public const string InstantPreviewNativeApi = "instant_preview_unity_plugin"; + + // Guid is taken from meta file and should never change. + private const string k_ApkGuid = "cf7b10762fe921e40a18151a6c92a8a6"; + private const string k_NoDevicesFoundAdbResult = "error: no devices/emulators found"; + private const float k_MaxTolerableAspectRatioDifference = 0.1f; + private const string k_MismatchedAspectRatioWarningFormatString = + "The aspect ratio of your game window is different from the aspect ratio of your Instant Preview camera " + + "texture. Please resize your game window's aspect ratio to match, or your preview will be distorted. The " + + "camera texture resolution is {0}, {1}."; + + private static readonly WaitForEndOfFrame k_WaitForEndOfFrame = new WaitForEndOfFrame(); + + /// <summary> + /// Coroutine method that communicates to the Instant Preview plugin + /// every frame. + /// + /// If not running in the editor, this does nothing. + /// </summary> + /// <returns>Enumerator for a coroutine that updates Instant Preview + /// every frame.</returns> + public static IEnumerator InitializeIfNeeded() + { + // Terminates if not running in editor. + if (!Application.isEditor) + { + yield break; + } + + // User may have explicitly disabled Instant Preview. + if (ARCoreProjectSettings.Instance != null && + !ARCoreProjectSettings.Instance.IsInstantPreviewEnabled) + { + yield break; + } + + var adbPath = InstantPreviewManager.GetAdbPath(); + if (adbPath == null) + { + Debug.LogError("Instant Preview requires your Unity Android SDK path to be set. Please set it under " + + "Preferences/External Tools/Android. You may need to install the Android SDK first."); + yield break; + } + else if (!File.Exists(adbPath)) + { + Debug.LogErrorFormat("adb not found at \"{0}\". Please add adb to your SDK path and restart the Unity editor.", adbPath); + yield break; + } + + string localVersion; + if (!StartServer(adbPath, out localVersion)) + { + yield break; + } + + yield return InstallApkAndRunIfConnected(adbPath, localVersion); + + yield return UpdateLoop(); + } + + /// <summary> + /// Uploads the latest camera video frame received from Instant Preview + /// to the specified texture. The texture might be recreated if it is + /// not the right size or null. + /// </summary> + /// <param name="backgroundTexture">Texture variable to store the latest + /// Instant Preview video frame.</param> + /// <returns>True if InstantPreview updated the background texture, + /// false if it did not and the texture still needs updating.</returns> + public static bool UpdateBackgroundTextureIfNeeded(ref Texture2D backgroundTexture) + { + if (!Application.isEditor) + { + return false; + } + + IntPtr pixelBytes; + int width; + int height; + if (NativeApi.LockCameraTexture(out pixelBytes, out width, out height)) + { + if (backgroundTexture == null || width != backgroundTexture.width || + height != backgroundTexture.height) + { + backgroundTexture = new Texture2D(width, height, TextureFormat.BGRA32, false); + } + + backgroundTexture.LoadRawTextureData(pixelBytes, width * height * 4); + backgroundTexture.Apply(); + + NativeApi.UnlockCameraTexture(); + } + + return true; + } + + private static IEnumerator UpdateLoop() + { + // Creates a target texture to capture the preview window onto. + // Some video encoders prefer the dimensions to be a multiple of 16. + var targetWidth = RoundUpToNearestMultipleOf16(Screen.width); + var targetHeight = RoundUpToNearestMultipleOf16(Screen.height); + var screenTexture = new RenderTexture(targetWidth, targetHeight, 0); + + var renderEventFunc = NativeApi.GetRenderEventFunc(); + var shouldConvertToBrgra = SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11; + var targetTexture = screenTexture; + RenderTexture bgrTexture = null; + if (shouldConvertToBrgra) + { + bgrTexture = new RenderTexture(screenTexture.width, screenTexture.height, 0, RenderTextureFormat.BGRA32); + targetTexture = bgrTexture; + } + + var loggedAspectRatioWarning = false; + + // Begins update loop. The coroutine will cease when the + // ARCoreSession component it's called from is destroyed. + for (;;) + { + yield return k_WaitForEndOfFrame; + NativeApi.Update(); + InstantPreviewInput.Update(); + AddInstantPreviewTrackedPoseDriverWhenNeeded(); + + Graphics.Blit(null, screenTexture); + + if (shouldConvertToBrgra) + { + Graphics.Blit(screenTexture, bgrTexture); + } + + var cameraTexture = Frame.CameraImage.Texture; + if (!loggedAspectRatioWarning && cameraTexture != null) + { + var sourceWidth = cameraTexture.width; + var sourceHeight = cameraTexture.height; + var sourceAspectRatio = (float)sourceWidth / sourceHeight; + var destinationWidth = Screen.width; + var destinationHeight = Screen.height; + var destinationAspectRatio = (float)destinationWidth / destinationHeight; + + if (Mathf.Abs(sourceAspectRatio - destinationAspectRatio) > + k_MaxTolerableAspectRatioDifference) + { + Debug.LogWarning(string.Format(k_MismatchedAspectRatioWarningFormatString, sourceWidth, + sourceHeight)); + loggedAspectRatioWarning = true; + } + } + + NativeApi.SendFrame(targetTexture.GetNativeTexturePtr()); + GL.IssuePluginEvent(renderEventFunc, 69); + } + } + + private static void AddInstantPreviewTrackedPoseDriverWhenNeeded() + { + foreach (var poseDriver in Component.FindObjectsOfType<TrackedPoseDriver>()) + { + poseDriver.enabled = false; + var gameObject = poseDriver.gameObject; + var hasInstantPreviewTrackedPoseDriver = + gameObject.GetComponent<InstantPreviewTrackedPoseDriver>() != null; + if (!hasInstantPreviewTrackedPoseDriver) + { + gameObject.AddComponent<InstantPreviewTrackedPoseDriver>(); + } + } + } + + private static string GetAdbPath() + { + string sdkRoot = null; +#if UNITY_EDITOR + // Gets adb path and starts instant preview server. + sdkRoot = UnityEditor.EditorPrefs.GetString("AndroidSdkRoot"); +#endif // UNITY_EDITOR + + if (string.IsNullOrEmpty(sdkRoot)) + { + return null; + } + + // Gets adb path from known directory. + var adbPath = Path.Combine(Path.GetFullPath(sdkRoot), "platform-tools" + Path.DirectorySeparatorChar + "adb"); + + if (Application.platform == RuntimePlatform.WindowsEditor) + { + adbPath = Path.ChangeExtension(adbPath, "exe"); + } + + return adbPath; + } + + /// <summary> + /// Tries to install and run the Instant Preview android app. + /// </summary> + /// <param name="adbPath">Path to adb to use for installing.</param> + /// <param name="localVersion">Local version of Instant Preview plugin to compare installed APK against.</param> + /// <returns>Enumerator for coroutine that handles installation if necessary.</returns> + private static IEnumerator InstallApkAndRunIfConnected(string adbPath, string localVersion) + { + string apkPath = null; + +#if UNITY_EDITOR + apkPath = UnityEditor.AssetDatabase.GUIDToAssetPath(k_ApkGuid); +#endif // !UNITY_EDITOR + + // Early outs if set to install but the apk can't be found. + if (!File.Exists(apkPath)) + { + Debug.LogError( + string.Format("Trying to install Instant Preview apk but reference to InstantPreview.apk is " + + "broken. Couldn't find an asset with .meta file guid={0}", k_ApkGuid)); + yield break; + } + + Result result = new Result(); + + Thread checkAdbThread = new Thread((object obj) => + { + Result res = (Result)obj; + string output; + string errors; + + // Gets version of installed apk. + RunAdbCommand(adbPath, "shell dumpsys package com.google.ar.core.instantpreview | grep versionName", + out output, out errors); + string installedVersion = null; + if (!string.IsNullOrEmpty(output) && string.IsNullOrEmpty(errors)) + { + installedVersion = output.Substring(output.IndexOf('=') + 1); + } + + // Early outs if no device is connected. + if (string.Compare(errors, k_NoDevicesFoundAdbResult) == 0) + { + return; + } + + // Prints errors and exits on failure. + if (!string.IsNullOrEmpty(errors)) + { + Debug.LogError(errors); + return; + } + + if (installedVersion == null) + { + Debug.Log(string.Format( + "Instant Preview: app not found on device, attempting to install it from {0}.", + apkPath)); + } + else if (installedVersion != localVersion) + { + Debug.Log(string.Format( + "Instant Preview: installed version \"{0}\" does not match local version \"{1}\", attempting upgrade.", + installedVersion, localVersion)); + } + + res.ShouldPromptForInstall = installedVersion != localVersion; + }); + checkAdbThread.Start(result); + + while (!checkAdbThread.Join(0)) + { + yield return 0; + } + + if (result.ShouldPromptForInstall) + { + if (PromptToInstall()) + { + Thread installThread = new Thread(() => + { + string output; + string errors; + + RunAdbCommand(adbPath, + string.Format("uninstall com.google.ar.core.instantpreview", apkPath), + out output, out errors); + + RunAdbCommand(adbPath, + string.Format("install \"{0}\"", apkPath), + out output, out errors); + + // Prints any output from trying to install. + if (!string.IsNullOrEmpty(output)) + { + Debug.Log(output); + } + + if (!string.IsNullOrEmpty(errors)) + { + if (string.Equals(errors, "Success")) + { + Debug.Log("Successfully installed Instant Preview app."); + } + else + { + Debug.LogError(errors); + } + } + }); + installThread.Start(); + + while (!installThread.Join(0)) + { + yield return 0; + } + } + else + { + yield break; + } + } + + if (!NativeApi.IsConnected()) + { + new Thread(() => + { + string output; + string errors; + RunAdbCommand(adbPath, + "shell am start -n com.google.ar.core.instantpreview/.InstantPreviewActivity", + out output, out errors); + }).Start(); + } + } + + private static bool PromptToInstall() + { +#if UNITY_EDITOR + return UnityEditor.EditorUtility.DisplayDialog("Instant Preview", + "To instantly reflect your changes on device, the " + + "Instant Preview app will be installed on your " + + "connected phone.\n\nTo permanently disable Instant Preview, " + + "uncheck the InstantPreviewEnabled checkbox in Edit/Project Settings/ARCore Instant Preview Enabled.", "Okay", "Don't Install This Time"); +#else + return false; +#endif + } + + private static void RunAdbCommand(string fileName, string arguments, out string output, out string errors) + { + using (var process = new System.Diagnostics.Process()) + { + var startInfo = new System.Diagnostics.ProcessStartInfo(fileName, arguments); + startInfo.UseShellExecute = false; + startInfo.RedirectStandardError = true; + startInfo.RedirectStandardOutput = true; + startInfo.CreateNoWindow = true; + process.StartInfo = startInfo; + + var outputBuilder = new StringBuilder(); + var errorBuilder = new StringBuilder(); + process.OutputDataReceived += (sender, ef) => outputBuilder.Append(ef.Data); + process.ErrorDataReceived += (sender, ef) => errorBuilder.Append(ef.Data); + + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + process.WaitForExit(); + process.Close(); + + // Trims the output strings to make comparison easier. + output = outputBuilder.ToString().Trim(); + errors = errorBuilder.ToString().Trim(); + } + } + + private static bool StartServer(string adbPath, out string version) + { + // Tries to start server. + const int k_InstantPreviewVersionStringMaxLength = 64; + var versionStringBuilder = new StringBuilder(k_InstantPreviewVersionStringMaxLength); + var started = NativeApi.InitializeInstantPreview(adbPath, versionStringBuilder, + versionStringBuilder.Capacity); + if (!started) + { + Debug.LogErrorFormat("Couldn't start Instant Preview server with adb path: {0}.", adbPath); + version = null; + return false; + } + + version = versionStringBuilder.ToString(); + Debug.Log("Instant Preview Version: " + version); + return true; + } + + private static int RoundUpToNearestMultipleOf16(int value) + { + return (value + 15) & ~15; + } + + private struct NativeApi + { + [DllImport(InstantPreviewNativeApi)] + public static extern bool InitializeInstantPreview( + string adbPath, StringBuilder version, int versionStringLength); + + [DllImport(InstantPreviewNativeApi)] + public static extern void Update(); + + [DllImport(InstantPreviewNativeApi)] + public static extern IntPtr GetRenderEventFunc(); + + [DllImport(InstantPreviewNativeApi)] + public static extern void SendFrame(IntPtr renderTexture); + + [DllImport(InstantPreviewNativeApi)] + public static extern bool LockCameraTexture(out IntPtr pixelBytes, out int width, + out int height); + + [DllImport(InstantPreviewNativeApi)] + public static extern void UnlockCameraTexture(); + + [DllImport(InstantPreviewNativeApi)] + public static extern bool IsConnected(); + } + + private class Result + { + public bool ShouldPromptForInstall = false; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..101cb5a448b950a8508aab51361386011013014e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8d78f35e6ec68ed4ba199eddf266e308 +timeCreated: 1513720134 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs new file mode 100644 index 0000000000000000000000000000000000000000..4515e12695f12f44c93cccca4a40bdf29a72b3aa --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------- +// <copyright file="InstantPreviewTrackedPoseDriver.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + + /// <summary> + /// Drives cameras when using Instant Preview, since there is no easy way to + /// provide data to Unity's TrackedPoseDriver. + /// </summary> + public class InstantPreviewTrackedPoseDriver : MonoBehaviour + { + /// <summary> + /// Updates the game object's transform to that of the latest pose + /// received by Instant Preview. + /// </summary> + public void Update() + { + if (!Application.isEditor) + { + return; + } + + transform.position = Frame.Pose.position; + transform.rotation = Frame.Pose.rotation; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..f56757ea90f1d98d6f24124206acd12261517287 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreviewTrackedPoseDriver.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 307167e96a9af144789862588807c91b +timeCreated: 1512450063 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Materials.meta b/T3-Unity/Assets/GoogleARCore/SDK/Materials.meta new file mode 100644 index 0000000000000000000000000000000000000000..e6a762de2576eea820ec89987b60d6c0e2fe410d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b2c4e904b5e6b425f8ab111db67d7908 +folderAsset: yes +timeCreated: 1497981256 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat new file mode 100644 index 0000000000000000000000000000000000000000..3b70f19f219eaa253ba5a57233a156118d405788 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: ARBackground + m_Shader: {fileID: 4800000, guid: 025775b2b3616154f9eec0261bb8a581, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat.meta b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat.meta new file mode 100644 index 0000000000000000000000000000000000000000..3e2e2dc476a759e5249b8fb2c5cd6a624450c0ff --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.mat.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 03ad0130a037647aeb60218f61aca114 +timeCreated: 1498003566 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader new file mode 100644 index 0000000000000000000000000000000000000000..a05825d8de6f97311d4a1e4db8bbfb16a512b2d1 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader @@ -0,0 +1,117 @@ +Shader "ARCore/ARBackground" +{ + Properties { + _MainTex ("Texture", 2D) = "white" {} + _UvTopLeftRight ("UV of top corners", Vector) = (0, 1, 1, 1) + _UvBottomLeftRight ("UV of bottom corners", Vector) = (0 , 0, 1, 0) + } + + // For GLES3 + SubShader + { + Pass + { + ZWrite Off + + GLSLPROGRAM + + #pragma only_renderers gles3 + + #ifdef SHADER_API_GLES3 + #extension GL_OES_EGL_image_external_essl3 : require + #endif + + uniform vec4 _UvTopLeftRight; + uniform vec4 _UvBottomLeftRight; + + #ifdef VERTEX + + varying vec2 textureCoord; + + void main() + { + #ifdef SHADER_API_GLES3 + vec2 uvTop = mix(_UvTopLeftRight.xy, _UvTopLeftRight.zw, gl_MultiTexCoord0.x); + vec2 uvBottom = mix(_UvBottomLeftRight.xy, _UvBottomLeftRight.zw, gl_MultiTexCoord0.x); + textureCoord = mix(uvTop, uvBottom, gl_MultiTexCoord0.y); + + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + #endif + } + + #endif + + #ifdef FRAGMENT + varying vec2 textureCoord; + uniform samplerExternalOES _MainTex; + + void main() + { + #ifdef SHADER_API_GLES3 + gl_FragColor = texture(_MainTex, textureCoord); + #endif + } + + #endif + + ENDGLSL + } + } + + Subshader + { + Pass + { + ZWrite Off + + CGPROGRAM + + #pragma exclude_renderers gles3 + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + uniform float4 _UvTopLeftRight; + uniform float4 _UvBottomLeftRight; + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + v2f vert(appdata v) + { + float2 uvTop = lerp(_UvTopLeftRight.xy, _UvTopLeftRight.zw, v.uv.x); + float2 uvBottom = lerp(_UvBottomLeftRight.xy, _UvBottomLeftRight.zw, v.uv.x); + + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = lerp(uvTop, uvBottom, v.uv.y); + + // Instant preview's texture is transformed differently. + o.uv = o.uv.yx; + o.uv.x = 1.0 - o.uv.x; + + return o; + } + + sampler2D _MainTex; + + fixed4 frag(v2f i) : SV_Target + { + return tex2D(_MainTex, i.uv); + } + ENDCG + } + } + + FallBack Off +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader.meta b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader.meta new file mode 100644 index 0000000000000000000000000000000000000000..32b75c80962c010805051d329d02ecfbed0c49c6 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Materials/ARBackground.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 025775b2b3616154f9eec0261bb8a581 +timeCreated: 1510285086 +licenseType: Pro +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins.meta new file mode 100644 index 0000000000000000000000000000000000000000..a9072c24df230339dede8e4f5cbf4985a8e9d6eb --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 93be2b9777c348648a2d9151b7e233fc +folderAsset: yes +timeCreated: 1501825151 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar new file mode 100644 index 0000000000000000000000000000000000000000..9d9732ffe5c19d4ecfb592b0872946d191b65c0e Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar.meta new file mode 100644 index 0000000000000000000000000000000000000000..a5cc8b2e5f343ef8fe4e7cc66b56ea0724c8afd4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar.meta @@ -0,0 +1,31 @@ +fileFormatVersion: 2 +guid: 19eddef6ceb6961489b26fb8bf19f1e5 +timeCreated: 1517361316 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar new file mode 100644 index 0000000000000000000000000000000000000000..8a18178918f6febfd09e37ad5e4611bbb431f71b Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar.meta new file mode 100644 index 0000000000000000000000000000000000000000..b610eba46238f2c5a9a8bf8a232a19ebd682483f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar.meta @@ -0,0 +1,31 @@ +fileFormatVersion: 2 +guid: e2fd4640a9f7349438a5920ea2fb35f2 +timeCreated: 1518222616 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar new file mode 100644 index 0000000000000000000000000000000000000000..be40e73d92e93be21f3c69091b32eacd7a9e98bd Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar.meta new file mode 100644 index 0000000000000000000000000000000000000000..3c485d19fcd9b60dba716933265724f04f669dbb --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar.meta @@ -0,0 +1,31 @@ +fileFormatVersion: 2 +guid: cb4b89ba21eac484797cfca938a1a5ea +timeCreated: 1518222591 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so new file mode 100644 index 0000000000000000000000000000000000000000..11694aa5ff8294580a9bb2d53f8f1dd472c8d9ab Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so.meta new file mode 100644 index 0000000000000000000000000000000000000000..9272c6dc65f2fb3b6ffc90a4ee740db770988622 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so.meta @@ -0,0 +1,103 @@ +fileFormatVersion: 2 +guid: d9b715dad41754ff39bd62a2954dadf9 +timeCreated: 1510001161 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 0 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + - first: + Android: Android + second: + enabled: 1 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so new file mode 100644 index 0000000000000000000000000000000000000000..2b010c931fb5b84404bb3fc0b0c22419abedc1b2 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so.meta new file mode 100644 index 0000000000000000000000000000000000000000..e803faa08b834271dd17ba8c0e9eda4f80978dc3 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/libarpresto_api.so.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ccde220b10a8b441a9b728f80d014cfe +timeCreated: 1513372698 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 0 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Android: Android + second: + enabled: 1 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar new file mode 100644 index 0000000000000000000000000000000000000000..acb6aa5a57ba0e8301ce8cc35a79fdd2769f0785 Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar.meta new file mode 100644 index 0000000000000000000000000000000000000000..d8a07c7db1c62a7fccf4dd78dabceacdfda4f19d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar.meta @@ -0,0 +1,31 @@ +fileFormatVersion: 2 +guid: bd091fc8013c942f586c1672b8ee2b27 +timeCreated: 1500400815 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar new file mode 100644 index 0000000000000000000000000000000000000000..e180693f9934fd4ab658edf71494bd286d7af7ba Binary files /dev/null and b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar differ diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar.meta b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar.meta new file mode 100644 index 0000000000000000000000000000000000000000..ee356f6975c8b0fd6ce0534995c4b0c3de832b00 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Plugins/unitygar.aar.meta @@ -0,0 +1,31 @@ +fileFormatVersion: 2 +guid: f62612db4b24deb43ada3a769754a2f7 +timeCreated: 1503511556 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts.meta new file mode 100644 index 0000000000000000000000000000000000000000..337aa52a5e46957263f313cf4aeac48ffb310f0e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8f3875959d8dd4bdeb9620e0eb96fb3b +folderAsset: yes +timeCreated: 1501446012 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs new file mode 100644 index 0000000000000000000000000000000000000000..cb49abfe8becf285a888a7f9d730218eb28515b4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------- +// <copyright file="ARCoreBackgroundRenderer.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System.Collections; + using System.Collections.Generic; + using GoogleARCoreInternal; + using UnityEngine; + using UnityEngine.XR; + + /// <summary> + /// Renders the device's camera as a background to the attached Unity camera component. + /// </summary> + [RequireComponent(typeof(Camera))] + public class ARCoreBackgroundRenderer : MonoBehaviour + { + /// <summary> + /// A material used to render the AR background image. + /// </summary> + [Tooltip("A material used to render the AR background image.")] + public Material BackgroundMaterial; + + private Camera m_Camera; + + private ARBackgroundRenderer m_BackgroundRenderer; + + private void OnEnable() + { + if (BackgroundMaterial == null) + { + Debug.LogError("ArCameraBackground:: No material assigned."); + return; + } + + m_Camera = GetComponent<Camera>(); + } + + private void OnDisable() + { + Disable(); + } + + private void Update() + { + if (BackgroundMaterial == null) + { + Disable(); + return; + } + + Texture backgroundTexture = Frame.CameraImage.Texture; + if (backgroundTexture == null) + { + Disable(); + return; + } + + const string mainTexVar = "_MainTex"; + const string topLeftRightVar = "_UvTopLeftRight"; + const string bottomLeftRightVar = "_UvBottomLeftRight"; + + BackgroundMaterial.SetTexture(mainTexVar, backgroundTexture); + + var uvQuad = Frame.CameraImage.DisplayUvCoords; + BackgroundMaterial.SetVector(topLeftRightVar, + new Vector4(uvQuad.TopLeft.x, uvQuad.TopLeft.y, uvQuad.TopRight.x, uvQuad.TopRight.y)); + BackgroundMaterial.SetVector(bottomLeftRightVar, + new Vector4(uvQuad.BottomLeft.x, uvQuad.BottomLeft.y, uvQuad.BottomRight.x, uvQuad.BottomRight.y)); + + m_Camera.projectionMatrix = Frame.CameraImage.GetCameraProjectionMatrix( + m_Camera.nearClipPlane, m_Camera.farClipPlane); + + if (m_BackgroundRenderer == null) + { + m_BackgroundRenderer = new ARBackgroundRenderer(); + m_BackgroundRenderer.backgroundMaterial = BackgroundMaterial; + m_BackgroundRenderer.camera = m_Camera; + m_BackgroundRenderer.mode = ARRenderMode.MaterialAsBackground; + } + } + + private void Disable() + { + if (m_BackgroundRenderer != null) + { + m_BackgroundRenderer.camera = null; + m_BackgroundRenderer = null; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..675748ab8b6dc1c30db5599e2ab55dab83777890 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreBackgroundRenderer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: eb172c260d42e4f62945afda50892c0c +timeCreated: 1510461368 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs new file mode 100644 index 0000000000000000000000000000000000000000..29c000e1db02df1adadbc1a4a5c110d0a8bb822e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs @@ -0,0 +1,69 @@ +//----------------------------------------------------------------------- +// <copyright file="ARCoreSession.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// A component that manages the ARCore Session in a Unity scene. + /// </summary> + public class ARCoreSession : MonoBehaviour + { + /// <summary> + /// A scriptable object specifying the ARCore session configuration. + /// </summary> + [Tooltip("A scriptable object specifying the ARCore session configuration.")] + public ARCoreSessionConfig SessionConfig; + + /// <summary> + /// Unity Awake. + /// </summary> + public void Awake() + { + LifecycleManager.Instance.CreateSession(this); + } + + /// <summary> + /// Unity OnDestroy. + /// </summary> + public void OnDestroy() + { + LifecycleManager.Instance.DestroySession(); + } + + /// <summary> + /// Unity OnEnable. + /// </summary> + public void OnEnable() + { + LifecycleManager.Instance.EnableSession(); + } + + /// <summary> + /// Unity OnDisable. + /// </summary> + public void OnDisable() + { + LifecycleManager.Instance.DisableSession(); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..583f69aea142be19d046af74dc2412159156808f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSession.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d4ca0c6a3af6b4635b7e98c6ea0a0cf9 +timeCreated: 1510461671 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7b04818849e510e5bb7f63c4d5a840a97ab1aca --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------- +// <copyright file="ARCoreSessionConfig.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + + /// <summary> + /// Holds settings that are used to configure the session. + /// </summary> + [CreateAssetMenu(fileName = "ARCoreSessionConfig", menuName = "GoogleARCore/SessionConfig", order = 1)] + public class ARCoreSessionConfig : ScriptableObject + { + /// <summary> + /// Toggles whether the rendering frame rate matches the background camera frame rate. + /// Setting this to true will also set QualitySetting.vSyncCount to 0, which will make your entire app to run at the background camera frame rate (including animations, UI interaction, etc.). + /// Setting this to false could incur extra power overhead due to rendering the same background more than once. + /// </summary> + [Tooltip("Toggles whether the rendering frame rate matches the background camera frame rate")] + public bool MatchCameraFramerate = true; + + /// <summary> + /// Toggles whether plane finding is enabled. + /// </summary> + [Tooltip("Toggles whether plane finding is enabled.")] + public bool EnablePlaneFinding = true; + + /// <summary> + /// Toggles whether light estimation is enabled. + /// </summary> + [Tooltip("Toggles whether light estimation is enabled.")] + public bool EnableLightEstimation = true; + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..378059c940d456aa2360ca24ff0ead10aaf6061a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ARCoreSessionConfig.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 53ac32fab2599402fb6d154adf4c1e40 +timeCreated: 1510876906 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7e6dd43c0fcf114a95e505edd7f00f83224b396 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs @@ -0,0 +1,141 @@ +//----------------------------------------------------------------------- +// <copyright file="Anchor.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Attaches a GameObject to an ARCore {@link Trackable}. The transform of the GameObject will be updated to + /// maintain the semantics of the attachment relationship, which varies between sub-types of Trackable. + /// </summary> + public class Anchor : MonoBehaviour + { + private static Dictionary<IntPtr, Anchor> s_AnchorDict = new Dictionary<IntPtr, Anchor>(); + + private IntPtr m_AnchorNativeHandle = IntPtr.Zero; + + private NativeSession m_NativeSession; + + private TrackingState m_LastFrameTrackingState = TrackingState.Stopped; + + /// <summary> + /// Gets the tracking state of the anchor. + /// </summary> + public TrackingState TrackingState + { + get + { + // TODO (b/73256094): Remove isTracking when fixed. + var nativeSession = LifecycleManager.Instance.NativeSession; + var isTracking = LifecycleManager.Instance.SessionStatus == SessionStatus.Tracking; + if (nativeSession != m_NativeSession) + { + // Anchors from another session are considered stopped. + return TrackingState.Stopped; + } + else if (!isTracking) + { + // If there are no new frames coming in we must manually return paused. + return TrackingState.Paused; + } + + return m_NativeSession.AnchorApi.GetTrackingState(m_AnchorNativeHandle); + } + } + + //// @cond EXCLUDE_FROM_DOXYGEN + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static Anchor AnchorFactory(IntPtr anchorNativeHandle, NativeSession nativeApi, bool isCreate = true) + { + if (anchorNativeHandle == IntPtr.Zero) + { + return null; + } + + Anchor result; + if (s_AnchorDict.TryGetValue(anchorNativeHandle, out result)) + { + // Release acquired handle and return cached result + result.m_NativeSession.AnchorApi.Release(anchorNativeHandle); + return result; + } + + if (isCreate) + { + Anchor anchor = (new GameObject()).AddComponent<Anchor>(); + anchor.gameObject.name = "Anchor"; + anchor.m_AnchorNativeHandle = anchorNativeHandle; + anchor.m_NativeSession = nativeApi; + anchor.Update(); + + s_AnchorDict.Add(anchorNativeHandle, anchor); + return anchor; + } + + return null; + } + + //// @endcond + + private void Update() + { + if (m_AnchorNativeHandle == IntPtr.Zero) + { + Debug.LogError("Anchor components instantiated outside of ARCore are not supported. " + + "Please use a 'Create' method within ARCore to instantiate anchors."); + return; + } + + var pose = m_NativeSession.AnchorApi.GetPose(m_AnchorNativeHandle); + transform.position = pose.position; + transform.rotation = pose.rotation; + + TrackingState currentFrameTrackingState = TrackingState; + if (m_LastFrameTrackingState != currentFrameTrackingState) + { + bool isAnchorTracking = currentFrameTrackingState == TrackingState.Tracking; + foreach (Transform child in transform) + { + child.gameObject.SetActive(isAnchorTracking); + } + + m_LastFrameTrackingState = currentFrameTrackingState; + } + } + + private void OnDestroy() + { + if (m_AnchorNativeHandle == IntPtr.Zero) + { + return; + } + + s_AnchorDict.Remove(m_AnchorNativeHandle); + m_NativeSession.AnchorApi.Release(m_AnchorNativeHandle); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..06b6167eebd1a4cefb40a43db7dec30741af5b25 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Anchor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: bd5c45a099b834b8d847a3ba64b2c8ec +timeCreated: 1502157890 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: -16000 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..36ed83f69f7854c9e09ec1bef76d4eb90ca4279f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs @@ -0,0 +1,181 @@ +//----------------------------------------------------------------------- +// <copyright file="AndroidPermissionsManager.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Manages Android permissions for the Unity application. + /// </summary> + public class AndroidPermissionsManager : AndroidJavaProxy + { + private static AndroidPermissionsManager s_Instance; + private static AndroidJavaObject s_Activity; + private static AndroidJavaObject s_PermissionService; + private static AsyncTask<AndroidPermissionsRequestResult> s_CurrentRequest = null; + private static Action<AndroidPermissionsRequestResult> s_OnPermissionsRequestFinished; + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Constructs a new AndroidPermissionsManager. + /// </summary> + public AndroidPermissionsManager() : base("com.unity3d.plugin.UnityAndroidPermissions$IPermissionRequestResult") + { + } + + /// @endcond + + /// <summary> + /// Checks if an Android permission is granted to the application. + /// </summary> + /// <param name="permissionName">The full name of the Android permission to check (e.g. + /// android.permission.CAMERA).</param> + /// <returns><c>true</c> if <c>permissionName</c> is granted to the application, otherwise + /// <c>false</c>.</returns> + public static bool IsPermissionGranted(string permissionName) + { + if (Application.isEditor) + { + return true; + } + + return GetPermissionsService().Call<bool>("IsPermissionGranted", GetUnityActivity(), permissionName); + } + + /// <summary> + /// Requests an Android permission from the user. + /// </summary> + /// <param name="permissionName">The permission to be requested (e.g. android.permission.CAMERA).</param> + /// <returns>An asynchronous task the completes when the user has accepted/rejected the requested permission + /// and yields a {@link AndroidPermissionsRequestResult} that summarizes the result. If this method is called + /// when another permissions request is pending <c>null</c> will be returned instead.</returns> + public static AsyncTask<AndroidPermissionsRequestResult> RequestPermission(string permissionName) + { + if (AndroidPermissionsManager.IsPermissionGranted(permissionName)) + { + return new AsyncTask<AndroidPermissionsRequestResult>(new AndroidPermissionsRequestResult( + new string[] { permissionName }, new bool[] { true })); + } + + if (s_CurrentRequest != null) + { + ARDebug.LogError("Attempted to make simultaneous Android permissions requests."); + return null; + } + + GetPermissionsService().Call("RequestPermissionAsync", GetUnityActivity(), + new[] { permissionName }, GetInstance()); + s_CurrentRequest = new AsyncTask<AndroidPermissionsRequestResult>(out s_OnPermissionsRequestFinished); + + return s_CurrentRequest; + } + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Callback fired when a permission is granted. + /// </summary> + /// <param name="permissionName">The name of the permission that was granted.</param> + public virtual void OnPermissionGranted(string permissionName) + { + _OnPermissionResult(permissionName, true); + } + + /// @endcond + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Callback fired when a permission is denied. + /// </summary> + /// <param name="permissionName">The name of the permission that was denied.</param> + public virtual void OnPermissionDenied(string permissionName) + { + _OnPermissionResult(permissionName, false); + } + + /// @endcond + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Callback fired on an Android activity result (unused part of UnityAndroidPermissions interface). + /// </summary> + public virtual void OnActivityResult() + { + } + + private static AndroidPermissionsManager GetInstance() + { + if (s_Instance == null) + { + s_Instance = new AndroidPermissionsManager(); + } + + return s_Instance; + } + + private static AndroidJavaObject GetUnityActivity() + { + if (s_Activity == null) + { + AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + s_Activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); + } + + return s_Activity; + } + + private static AndroidJavaObject GetPermissionsService() + { + if (s_PermissionService == null) + { + s_PermissionService = new AndroidJavaObject("com.unity3d.plugin.UnityAndroidPermissions"); + } + + return s_PermissionService; + } + + /// @endcond + + /// <summary> + /// Callback fired on an Android permission result. + /// </summary> + /// <param name="permissionName">The name of the permission.</param> + /// <param name="granted">If permission is granted or not.</param> + private void _OnPermissionResult(string permissionName, bool granted) + { + if (s_OnPermissionsRequestFinished == null) + { + Debug.LogErrorFormat("AndroidPermissionsManager received an unexpected permissions result {0}", + permissionName); + return; + } + + // Cache completion method and reset request state. + var onRequestFinished = s_OnPermissionsRequestFinished; + s_CurrentRequest = null; + s_OnPermissionsRequestFinished = null; + + onRequestFinished(new AndroidPermissionsRequestResult(new string[] { permissionName }, + new bool[] { granted })); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6fb2f47bf40f16ba1d6473769bb48ef05ff4a705 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c0726c8b601b041069fad86754497703 +timeCreated: 1502330118 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs new file mode 100644 index 0000000000000000000000000000000000000000..55f2ce56b4f6d757c67310f21d163f06ac61594b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------- +// <copyright file="AndroidPermissionsRequestResult.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Structure holding data summarizing the result of an Android permissions request. + /// </summary> + public struct AndroidPermissionsRequestResult + { + /// <summary> + /// Constructs a new AndroidPermissionsRequestResult. + /// </summary> + /// <param name="permissionNames">The value for PermissionNames.</param> + /// <param name="grantResults">The value for GrantResults.</param> + public AndroidPermissionsRequestResult(string[] permissionNames, bool[] grantResults) + { + PermissionNames = permissionNames; + GrantResults = grantResults; + } + + /// <summary> + /// Gets a collection of permissions requested. + /// </summary> + public string[] PermissionNames { get; private set; } + + /// <summary> + /// Gets a collection of results corresponding to {@link PermissionNames}. + /// </summary> + public bool[] GrantResults { get; private set; } + + /// <summary> + /// Gets a value indicating whether all permissions are granted. + /// </summary> + public bool IsAllGranted + { + get + { + if (PermissionNames == null || GrantResults == null) + { + return false; + } + + for (int i = 0; i < GrantResults.Length; i++) + { + if (!GrantResults[i]) + { + return false; + } + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6d1418b13cebe62a191e43329e1bb82a368d7e9b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AndroidPermissionsRequestResult.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d7676570d2869469a8e061cbd3d90c9f +timeCreated: 1502330118 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api.meta new file mode 100644 index 0000000000000000000000000000000000000000..9f54629080ebf1c516f640815a2d6b722b57960f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 11813694e8abb437eb9ef46ed1cc67c5 +folderAsset: yes +timeCreated: 1502400396 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..266e9c5c8acf38590262fe0983a22f3fa7ae9883 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------- +// <copyright file="AnchorApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class AnchorApi + { + private NativeSession m_NativeSession; + + public AnchorApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public Pose GetPose(IntPtr anchorHandle) + { + var poseHandle = m_NativeSession.PoseApi.Create(); + ExternApi.ArAnchor_getPose(m_NativeSession.SessionHandle, anchorHandle, poseHandle); + Pose resultPose = m_NativeSession.PoseApi.ExtractPoseValue(poseHandle); + m_NativeSession.PoseApi.Destroy(poseHandle); + return resultPose; + } + + public TrackingState GetTrackingState(IntPtr anchorHandle) + { + ApiTrackingState trackingState = ApiTrackingState.Stopped; + ExternApi.ArAnchor_getTrackingState(m_NativeSession.SessionHandle, anchorHandle, + ref trackingState); + return trackingState.ToTrackingState(); + } + + public void Detach(IntPtr anchorHandle) + { + ExternApi.ArAnchor_detach(m_NativeSession.SessionHandle, anchorHandle); + } + + public void Release(IntPtr anchorHandle) + { + ExternApi.ArAnchor_release(anchorHandle); + } + + public IntPtr CreateList() + { + IntPtr listHandle = IntPtr.Zero; + ExternApi.ArAnchorList_create(m_NativeSession.SessionHandle, ref listHandle); + return listHandle; + } + + public int GetListSize(IntPtr anchorListHandle) + { + int size = 0; + ExternApi.ArAnchorList_getSize(m_NativeSession.SessionHandle, anchorListHandle, ref size); + return size; + } + + public IntPtr AcquireListItem(IntPtr anchorListHandle, int index) + { + IntPtr anchorHandle = IntPtr.Zero; + ExternApi.ArAnchorList_acquireItem(m_NativeSession.SessionHandle, anchorListHandle, index, + ref anchorHandle); + return anchorHandle; + } + + public void DestroyList(IntPtr anchorListHandle) + { + ExternApi.ArAnchorList_destroy(anchorListHandle); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchor_getPose(IntPtr sessionHandle, IntPtr anchorHandle, IntPtr poseHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchor_getTrackingState(IntPtr sessionHandle, IntPtr anchorHandle, + ref ApiTrackingState trackingState); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchor_detach(IntPtr sessionHandle, IntPtr anchorHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchor_release(IntPtr anchorHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchorList_create(IntPtr sessionHandle, ref IntPtr outputAnchorListHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchorList_destroy(IntPtr anchorListHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchorList_getSize(IntPtr sessionHandle, IntPtr anchorListHandle, ref int outputSize); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArAnchorList_acquireItem(IntPtr sessionHandle, IntPtr anchorListHandle, int index, + ref IntPtr outputAnchorHandle); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..59b7291146023fce29f63ddf4abb0ccee17162d8 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/AnchorApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0301646575b004ceca83800c3b3c9f06 +timeCreated: 1509305507 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..a719f17237ae90a67c4a886e7537dccce3d39f70 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs @@ -0,0 +1,55 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiApkInstallStatusExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiApkInstallStatusExtensions + { + public static ApkInstallationStatus ToApkInstallationStatus(this ApiApkInstallationStatus apiStatus) + { + switch (apiStatus) + { + case ApiApkInstallationStatus.Uninitialized: + return ApkInstallationStatus.Uninitialized; + case ApiApkInstallationStatus.Requested: + return ApkInstallationStatus.Requested; + case ApiApkInstallationStatus.Success: + return ApkInstallationStatus.Success; + case ApiApkInstallationStatus.Error: + return ApkInstallationStatus.Error; + case ApiApkInstallationStatus.ErrorDeviceNotCompatible: + return ApkInstallationStatus.ErrorDeviceNotCompatible; + case ApiApkInstallationStatus.ErrorAndroidVersionNotSupported: + return ApkInstallationStatus.ErrorAndroidVersionNotSupported; + case ApiApkInstallationStatus.ErrorUserDeclined: + return ApkInstallationStatus.ErrorUserDeclined; + default: + UnityEngine.Debug.LogErrorFormat("Unexpected ApiApkInstallStatus status {0}", apiStatus); + return ApkInstallationStatus.Error; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..2cac95948964c02e82f5226e563c8a1a68f8d364 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallStatusExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3345208dea93f4ca6a361f8852a87704 +timeCreated: 1517873495 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..5cb2484681a928ad1af32c74414136b66cbdf25c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiApkInstallationStatus.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiApkInstallationStatus + { + Uninitialized = 0, + Requested = 1, + Success = 100, + Error = 200, + ErrorDeviceNotCompatible = 201, + ErrorAndroidVersionNotSupported = 202, + ErrorUserDeclined = 203, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ec82243b893e946f47e02f1c53156e7b4baeb030 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiApkInstallationStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7aa753c5e597b4841b03ea5f7f21326f +timeCreated: 1517874709 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..352de267efeb6e1f81712c6ca65efcb7cc77620f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiArStatus.cs" company="Google"> +// +// Copyright 2016 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Collections; + using System.Diagnostics.CodeAnalysis; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiArStatus + { + Success = 0, + + // Invalid argument handling: null pointers and invalid enums for void + // functions are handled by logging and returning best-effort value. + // Non-void functions additionally return AR_ERROR_INVALID_ARGUMENT. + ErrorInvalidArgument = -1, + ErrorFatal = -2, + ErrorSessionPaused = -3, + ErrorSessionNotPaused = -4, + ErrorNotTracking = -5, + ErrorTextureNotSet = -6, + ErrorMissingGlContext = -7, + ErrorUnsupportedConfiguration = -8, + ErrorCameraPermissionNotGranted = -9, + + // Acquire failed because the object being acquired is already released. + // This happens e.g. if the developer holds an old frame for too long, and + // then tries to acquire a point cloud from it. + ErrorDeadlineExceeded = -10, + + // Acquire failed because there are too many objects already acquired. For + // example, the developer may acquire up to N point clouds. + // N is determined by available resources, and is usually small, e.g. 8. + // If the developer tries to acquire N+1 point clouds without releasing the + // previously acquired ones, they will get this error. + ErrorResourceExhausted = -11, + + // Acquire failed because the data isn't available yet for the current + // frame. For example, acquire the image metadata may fail with this error + // because the camera hasn't fully started. + ErrorNotYetAvailable = -12, + + UnavailableArCoreNotInstalled = -100, + UnavailableDeviceNotCompatible = -101, + UnavailableAndroidVersionNotSupported = -102, + + // The ARCore APK currently installed on device is too old and needs to be + // updated. For example, SDK v2.0.0 when APK is v1.0.0. + UnavailableApkTooOld = -103, + + // The ARCore APK currently installed no longer supports the sdk that the + // app was built with. For example, SDK v1.0.0 when APK includes support for + // v2.0.0+. + UnavailableSdkTooOld = -104, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e8c2b8eb8a38ef72791f0173d72c4b430c9b1dd2 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiArStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2632806855cc1405ca80cf82ad68f50a +timeCreated: 1511201582 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs new file mode 100644 index 0000000000000000000000000000000000000000..e4d652cdb69d9f15c960fc15f6e48462474f3ee4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiAvailability.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiAvailability + { + UnknownError = 0, + UnknownChecking = 1, + UnknownTimedOut = 2, + UnsupportedDeviceNotCapable = 100, + SupportedNotInstalled = 201, + SupportedApkTooOld = 202, + SupportedInstalled = 203 + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..3d4bcc357132925579a2d05f2d6260c1e10f6c22 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailability.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a2ff5d80474fa4dcf979bc5ec9b89ca4 +timeCreated: 1517858100 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..70abf8e0badefdfdab664de5db52ff845cbbc8a2 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs @@ -0,0 +1,55 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiAvailabilityExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiAvailabilityExtensions + { + public static ApkAvailabilityStatus ToApkAvailabilityStatus(this ApiAvailability apiStatus) + { + switch (apiStatus) + { + case ApiAvailability.UnknownError: + return ApkAvailabilityStatus.UnknownError; + case ApiAvailability.UnknownChecking: + return ApkAvailabilityStatus.UnknownChecking; + case ApiAvailability.UnknownTimedOut: + return ApkAvailabilityStatus.UnknownTimedOut; + case ApiAvailability.UnsupportedDeviceNotCapable: + return ApkAvailabilityStatus.UnsupportedDeviceNotCapable; + case ApiAvailability.SupportedNotInstalled: + return ApkAvailabilityStatus.SupportedNotInstalled; + case ApiAvailability.SupportedApkTooOld: + return ApkAvailabilityStatus.SupportedApkTooOld; + case ApiAvailability.SupportedInstalled: + return ApkAvailabilityStatus.SupportedInstalled; + default: + UnityEngine.Debug.LogErrorFormat("Unexpected ApiAvailability status {0}", apiStatus); + return ApkAvailabilityStatus.UnknownError; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8d50e66d71a5f0de4cb2d913a5dd34bd1bf33fc3 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiAvailabilityExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: da78fe0b9a17c46dea099872f469ccd7 +timeCreated: 1517871435 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs new file mode 100644 index 0000000000000000000000000000000000000000..9397faffc8e5202e9977c2f443d18216b1ed7342 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiCameraMetadata.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", + "SA1649:FileHeaderFileNameDocumentationMustMatchTypeName", Justification = "Internal.")] + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum NdkCameraMetadataType + { + Byte = 0, + Int32 = 1, + Float = 2, + Int64 = 3, + Double = 4, + Rational = 5, + NumTypes, + } + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum NdkCameraStatus + { + Ok = 0, + ErrorBase = -10000, + ErrorUnknown = ErrorBase, + ErrorInvalidParameter = ErrorBase - 1, + ErrorMetadataNotFound = ErrorBase - 4, + } + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + [StructLayout(LayoutKind.Explicit)] + public struct NdkCameraMetadata + { + [FieldOffset(0)] + [MarshalAs(UnmanagedType.I4)] + public int Tag; + + [FieldOffset(4)] + [MarshalAs(UnmanagedType.I1)] + public NdkCameraMetadataType Type; + + [FieldOffset(8)] + [MarshalAs(UnmanagedType.I4)] + public int Count; + + [FieldOffset(12)] + public IntPtr Value; + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..220e31a8bdfd8a7b0eb2cf30e2cad48ab396309f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiCameraMetadata.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: bfdd6a8d3f3624cc68c5c22390d84305 +timeCreated: 1511898550 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs new file mode 100644 index 0000000000000000000000000000000000000000..6bfa7a5b656c4fcbf421ea38b574722c25515452 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiConstants.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiConstants + { +#if !UNITY_EDITOR + public const string ARCoreNativeApi = "arcore_sdk"; + public const string ARCoreShimApi = "arcore_unity_api"; +#else + public const string ARCoreNativeApi = InstantPreviewManager.InstantPreviewNativeApi; + public const string ARCoreShimApi = InstantPreviewManager.InstantPreviewNativeApi; +#endif + + // NDK camera API is a system API after Android 24. + public const string NdkCameraApi = "camera2ndk"; + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..83d208b2fb90330f6205a994d47f832bcca8b2a7 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiConstants.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 020d4ce00b42e47d2b46e7aa6244bedb +timeCreated: 1509553365 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs new file mode 100644 index 0000000000000000000000000000000000000000..49b4b0b514cd5097e1e3bbcfa4b5f88018356cea --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiDisplayUvCoords.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using UnityEngine; + + /// <summary> + /// UV coordinates for the four corners of the display. + /// </summary> + [StructLayout(LayoutKind.Sequential)] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public struct ApiDisplayUvCoords + { + /// <summary> + /// Number of floats contained in this struct. + /// </summary> + public const int NumFloats = 8; + + public Vector2 TopLeft; + public Vector2 TopRight; + public Vector2 BottomLeft; + public Vector2 BottomRight; + + public ApiDisplayUvCoords(Vector2 topLeft, Vector2 topRight, + Vector2 bottomLeft, Vector2 bottomRight) + { + TopLeft = topLeft; + TopRight = topRight; + BottomLeft = bottomLeft; + BottomRight = bottomRight; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1329ca215d2ee21c315419b2f761a770d8a98d01 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiDisplayUvCoords.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ed17abe8b8d17dc44ae53ea9840cd4dc +timeCreated: 1510289770 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs new file mode 100644 index 0000000000000000000000000000000000000000..5b49a9437c80ae37cf8aa3f7700c8e11f3f389ed --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiLightEstimateState.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiLightEstimateState + { + NotValid = 0, + Valid = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..93173fb1b8408a0da900b1fb220e373554aead28 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateState.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: edc967aa80d4104418f83a5d540219ca +timeCreated: 1510799673 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..7a714d4d6c07ec451bbeead51fcf7132bfafb913 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiLightEstimateStateExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiLightEstimateStateExtensions + { + public static LightEstimateState ToLightEstimateState(this ApiLightEstimateState apiState) + { + switch (apiState) + { + case ApiLightEstimateState.NotValid: + return LightEstimateState.NotValid; + case ApiLightEstimateState.Valid: + return LightEstimateState.Valid; + default: + return LightEstimateState.NotValid; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..2028905fee774c0f9e9fe6a00f876cad41d093a1 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimateStateExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7b62de06fc1d1854d8e46bfb414db000 +timeCreated: 1510799673 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..39b0fcd7f171f29df79be135f5899df5a6b49f3f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiLightEstimationMode.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiLightEstimationMode + { + Disabled = 0, + AmbientIntensity = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e698b61473cf946ba74e4a3964ac21de26837799 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiLightEstimationMode.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 31136b31f422e49a5b4307c1b3bff384 +timeCreated: 1512782847 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..2326ff3cd9b5039b4fbbb39e1441bdb93d0cff22 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiPlaneFindingMode.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiPlaneFindingMode + { + Disabled = 0, + Horizontal = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..36b8a3dbf8dab3136b2e23016c5057ec0269d89d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPlaneFindingMode.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f21ec92bd25d0434ca6f063262f0ede5 +timeCreated: 1512178510 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs new file mode 100644 index 0000000000000000000000000000000000000000..70ea6162ac31fbe61026ee6c37f8d65497a365dc --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs @@ -0,0 +1,74 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiPoseData.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using UnityEngine; + + /// <summary> + /// Pose data container stored in ARCore frame. + /// </summary> + [StructLayout(LayoutKind.Sequential)] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public struct ApiPoseData + { + [MarshalAs(UnmanagedType.R4)] + public float Qx; + + [MarshalAs(UnmanagedType.R4)] + public float Qy; + + [MarshalAs(UnmanagedType.R4)] + public float Qz; + + [MarshalAs(UnmanagedType.R4)] + public float Qw; + + [MarshalAs(UnmanagedType.R4)] + public float X; + + [MarshalAs(UnmanagedType.R4)] + public float Y; + + [MarshalAs(UnmanagedType.R4)] + public float Z; + + public ApiPoseData(UnityEngine.Pose unityPose) + { + ConversionHelper.UnityPoseToApiPose(unityPose, out this); + } + + public UnityEngine.Pose ToUnityPose() + { + Pose unityPose; + ConversionHelper.ApiPoseToUnityPose(this, out unityPose); + return unityPose; + } + + public override string ToString() + { + return string.Format("qx: {0}, qy: {1}, qz: {2}, qw: {3}, x: {4}, y: {5}, z: {6}", + Qx, Qy, Qz, Qw, X, Y, Z); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..c87ff52c8b0db187a58fc1ab2eefe677b19bc919 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPoseData.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2d4a3892884f34b018a13b62fd1615f1 +timeCreated: 1510174272 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..76e67235bb03cfc79b529f620d31f624f0f92e54 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiPrestoConfig.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + [StructLayout(LayoutKind.Sequential)] + public struct ApiPrestoConfig + { + public ApiUpdateMode UpdateMode; + public ApiPlaneFindingMode PlaneFindingMode; + public ApiLightEstimationMode LightEstimationMode; + + public ApiPrestoConfig(ARCoreSessionConfig config) + { + UpdateMode = config.MatchCameraFramerate ? + ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage; + PlaneFindingMode = config.EnablePlaneFinding ? + ApiPlaneFindingMode.Horizontal : ApiPlaneFindingMode.Disabled; + LightEstimationMode = config.EnableLightEstimation ? + ApiLightEstimationMode.AmbientIntensity : ApiLightEstimationMode.Disabled; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..66775228ec8bea7791e05e18a99b63eb5a5479cc --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoConfig.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d8a0d471a5e1c486fb61de90a976a6d3 +timeCreated: 1518035095 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..85bdacc6a3bd78f4f2a49e9e9b7708d7e2d48a23 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs @@ -0,0 +1,42 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiPrestoStatus.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiPrestoStatus + { + Uninitialized = 0, + RequestingApkInstall = 1, + RequestingPermission = 2, + + Resumed = 100, + ResumedNotTracking = 101, + Paused = 102, + + ErrorFatal = 200, + ErrorApkNotAvailable = 201, + ErrorPermissionNotGranted = 202, + ErrorSessionConfigurationNotSupported = 203, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..6125bc00854978dd97095a44d5087f3efbddd239 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f77bf9ab0d39f4875b26d70fce838285 +timeCreated: 1513291504 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..d223292f4d07524fa2ef8658d93be53dfd8b3546 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiPrestoStatusExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiPrestoStatusExtensions + { + public static SessionStatus ToSessionStatus(this ApiPrestoStatus prestoStatus) + { + switch (prestoStatus) + { + case ApiPrestoStatus.Uninitialized: + return SessionStatus.None; + case ApiPrestoStatus.RequestingApkInstall: + case ApiPrestoStatus.RequestingPermission: + return SessionStatus.Initializing; + case ApiPrestoStatus.Resumed: + return SessionStatus.Tracking; + case ApiPrestoStatus.ResumedNotTracking: + return SessionStatus.LostTracking; + case ApiPrestoStatus.Paused: + return SessionStatus.NotTracking; + case ApiPrestoStatus.ErrorFatal: + return SessionStatus.FatalError; + case ApiPrestoStatus.ErrorApkNotAvailable: + return SessionStatus.ErrorApkNotAvailable; + case ApiPrestoStatus.ErrorPermissionNotGranted: + return SessionStatus.ErrorPermissionNotGranted; + case ApiPrestoStatus.ErrorSessionConfigurationNotSupported: + return SessionStatus.ErrorSessionConfigurationNotSupported; + default: + UnityEngine.Debug.LogErrorFormat("Unexpected presto status {0}", prestoStatus); + return SessionStatus.FatalError; + } + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1a53f6ab221d15161c69c6ee1b1cb74bb1d60fae --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiPrestoStatusExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 20257a5d02b574ec8a372bb9e319d8b3 +timeCreated: 1513294266 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs new file mode 100644 index 0000000000000000000000000000000000000000..58f6d662ff52cc50284b02142c7786a9fbe8f64f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackableType.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiTrackableType + { + Invalid = 0, + BaseTrackable = 0x41520100, + Plane = 0x41520101, + Point = 0x41520102, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d4fc32d87f76cdaa3f50c9f6b7b266f5a8a2ff13 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableType.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b8348fa5338bd4e8abfa9ebc30d296fb +timeCreated: 1509300062 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..0ab20884dae6b2192a7a5708ea19fc7a417a7728 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackableTypeExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiTrackableTypeExtensions + { + public static ApiTrackableType GetApiTrackableType(this Type type) + { + if (type == typeof(TrackedPlane)) + { + return ApiTrackableType.Plane; + } + else if (type == typeof(Trackable)) + { + return ApiTrackableType.BaseTrackable; + } + else + { + return ApiTrackableType.Invalid; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..87c91779bec782397f9c3e851b783d72ca415d93 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackableTypeExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9bc367d3f7ffd434dae127473b338fd4 +timeCreated: 1510614135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..fdc72ad8b9b83c6ca631f42a9d35bd437ab667d1 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackedPointOrientationMode.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiTrackedPointOrientationMode + { + Identity = 0, + SurfaceNormal = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ac3c10cfbacdbe537cd009581a45bc1c2cb078b6 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationMode.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1e55289de34ec44b191ed1bdc5b17c9d +timeCreated: 1517185900 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..ef3a7668bc274ead8cc321946b7f7c81ca7318fb --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackedPointOrientationModeExtensions.cs" +// company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiTrackedPointOrientationModeExtensions + { + public static TrackedPointOrientationMode ToTrackedPointOrientationMode( + this ApiTrackedPointOrientationMode apiMode) + { + switch (apiMode) + { + case ApiTrackedPointOrientationMode.Identity: + return TrackedPointOrientationMode.Identity; + case ApiTrackedPointOrientationMode.SurfaceNormal: + return TrackedPointOrientationMode.SurfaceNormal; + default: + ARDebug.LogError("Invalid value for ApiTrackedPointOrientationMode."); + return TrackedPointOrientationMode.Identity; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..c73b189fc664498fa4d8efeb4c34e7fa98b30d06 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackedPointOrientationModeExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f7f21e3757d39475aae8f4a13d02253a +timeCreated: 1517185900 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs new file mode 100644 index 0000000000000000000000000000000000000000..9d3f0db71bd8931c7d2b222f13b8daa9e6d5f59a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs @@ -0,0 +1,33 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackingState.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiTrackingState + { + Tracking = 0, + Paused = 1, + Stopped = 2, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5ce34625838eacba5bf569c3e04df2e82e26f3d0 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingState.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 226925a61d2444e8d9a12435697ce770 +timeCreated: 1510543828 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..f7121de9c284955bbb42208b356f3d2dbe124447 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiTrackingStateExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ApiTrackingStateExtensions + { + public static TrackingState ToTrackingState(this ApiTrackingState apiTrackingState) + { + switch (apiTrackingState) + { + case ApiTrackingState.Tracking: + return TrackingState.Tracking; + case ApiTrackingState.Paused: + return TrackingState.Paused; + case ApiTrackingState.Stopped: + return TrackingState.Stopped; + default: + return TrackingState.Stopped; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..86175fda42bc30143853d6955af92efe0bba33e4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiTrackingStateExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e227d0e11c8e0498a88231ab7e5f9da8 +timeCreated: 1510610474 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..c4f9a6a2b74045b27f414e2a0825161945839d5b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------- +// <copyright file="ApiUpdateMode.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public enum ApiUpdateMode + { + Blocking = 0, + LatestCameraImage = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e4a3a0cb241157df4f95703f20789edb4731e9fd --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/ApiUpdateMode.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9d36ec8d5b9b14aefb9f136006e51d6a +timeCreated: 1510876906 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..aadf63a4e2525d96f56044a292a0ae857089587d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------- +// <copyright file="CameraApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class CameraApi + { + private NativeSession m_NativeSession; + + public CameraApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public TrackingState GetTrackingState(IntPtr cameraHandle) + { + ApiTrackingState apiTrackingState = ApiTrackingState.Stopped; + ExternApi.ArCamera_getTrackingState(m_NativeSession.SessionHandle, + cameraHandle, ref apiTrackingState); + return apiTrackingState.ToTrackingState(); + } + + public Pose GetPose(IntPtr cameraHandle) + { + if (cameraHandle == IntPtr.Zero) + { + return Pose.identity; + } + + IntPtr poseHandle = m_NativeSession.PoseApi.Create(); + ExternApi.ArCamera_getDisplayOrientedPose(m_NativeSession.SessionHandle, cameraHandle, + poseHandle); + Pose resultPose = m_NativeSession.PoseApi.ExtractPoseValue(poseHandle); + m_NativeSession.PoseApi.Destroy(poseHandle); + return resultPose; + } + + public Matrix4x4 GetProjectionMatrix(IntPtr cameraHandle, float near, float far) + { + Matrix4x4 matrix = Matrix4x4.identity; + ExternApi.ArCamera_getProjectionMatrix(m_NativeSession.SessionHandle, cameraHandle, + near, far, ref matrix); + return matrix; + } + + public void Release(IntPtr cameraHandle) + { + ExternApi.ArCamera_release(cameraHandle); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArCamera_getTrackingState(IntPtr sessionHandle, IntPtr cameraHandle, + ref ApiTrackingState outTrackingState); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArCamera_getDisplayOrientedPose(IntPtr sessionHandle, IntPtr cameraHandle, IntPtr outPose); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArCamera_getProjectionMatrix(IntPtr sessionHandle, IntPtr cameraHandle, + float near, float far, ref Matrix4x4 outMatrix); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArCamera_release(IntPtr cameraHandle); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..299bfef05c6d1e77205cf4cf819ac1f5c2824966 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 3fdb35ceae7cf491a978d2f4a1c45f2c +timeCreated: 1510257333 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..bf92df7d5f0fe97f169d0eeb1b5bc19ef72d40ea --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------- +// <copyright file="CameraMetadataApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class CameraMetadataApi + { + private NativeSession m_NativeSession; + + public CameraMetadataApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public void Release(IntPtr arCameraMetadataHandle) + { + ExternApi.ArImageMetadata_release(arCameraMetadataHandle); + } + + public bool TryGetValues(IntPtr cameraMetadataHandle, + CameraMetadataTag tag, List<CameraMetadataValue> resultList) + { + IntPtr ndkMetadataHandle = IntPtr.Zero; + ExternApi.ArImageMetadata_getNdkCameraMetadata(m_NativeSession.SessionHandle, + cameraMetadataHandle, ref ndkMetadataHandle); + + resultList.Clear(); + NdkCameraMetadata entry = new NdkCameraMetadata(); + NdkCameraStatus status = ExternApi.ACameraMetadata_getConstEntry(ndkMetadataHandle, tag, ref entry); + if (status != NdkCameraStatus.Ok) + { + ARDebug.LogErrorFormat("ACameraMetadata_getConstEntry error with native camera error code: {0}", + status); + return false; + } + + for (int i = 0; i < entry.Count; i++) + { + switch (entry.Type) + { + case NdkCameraMetadataType.Byte: + sbyte byteValue = (sbyte)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<sbyte>(entry.Value, i), + typeof(sbyte)); + resultList.Add(new CameraMetadataValue(byteValue)); + break; + case NdkCameraMetadataType.Int32: + int intValue = (int)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<int>(entry.Value, i), + typeof(int)); + resultList.Add(new CameraMetadataValue(intValue)); + break; + case NdkCameraMetadataType.Float: + float floatValue = (float)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<float>(entry.Value, i), + typeof(float)); + resultList.Add(new CameraMetadataValue(floatValue)); + break; + case NdkCameraMetadataType.Int64: + long longValue = (long)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<long>(entry.Value, i), + typeof(long)); + resultList.Add(new CameraMetadataValue(longValue)); + break; + case NdkCameraMetadataType.Double: + double doubleValue = (double)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<double>(entry.Value, i), + typeof(double)); + resultList.Add(new CameraMetadataValue(doubleValue)); + break; + case NdkCameraMetadataType.Rational: + CameraMetadataRational rationalValue = (CameraMetadataRational)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<CameraMetadataRational>(entry.Value, i), + typeof(CameraMetadataRational)); + resultList.Add(new CameraMetadataValue(rationalValue)); + break; + default: + return false; + } + } + + return true; + } + + public bool GetAllCameraMetadataTags(IntPtr cameraMetadataHandle, List<CameraMetadataTag> resultList) + { + IntPtr ndkMetadataHandle = IntPtr.Zero; + ExternApi.ArImageMetadata_getNdkCameraMetadata(m_NativeSession.SessionHandle, + cameraMetadataHandle, ref ndkMetadataHandle); + + IntPtr tagsHandle = IntPtr.Zero; + int tagsCount = 0; + NdkCameraStatus status = ExternApi.ACameraMetadata_getAllTags(ndkMetadataHandle, ref tagsCount, ref tagsHandle); + if (status != NdkCameraStatus.Ok) + { + ARDebug.LogErrorFormat("ACameraMetadata_getAllTags error with native camera error code: {0}", + status); + return false; + } + + for (int i = 0; i < tagsCount; i++) + { + resultList.Add((CameraMetadataTag)Marshal.PtrToStructure( + MarshalingHelper.GetPtrToUnmanagedArrayElement<int>(tagsHandle, i), + typeof(int))); + } + + return true; + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArImageMetadata_getNdkCameraMetadata(IntPtr session, IntPtr image_metadata, + ref IntPtr out_ndk_metadata); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArImageMetadata_release(IntPtr metadata); + + [DllImport(ApiConstants.NdkCameraApi)] + public static extern NdkCameraStatus ACameraMetadata_getConstEntry(IntPtr ndkCameraMetadata, + CameraMetadataTag tag, ref NdkCameraMetadata entry); + + [DllImport(ApiConstants.NdkCameraApi)] + public static extern NdkCameraStatus ACameraMetadata_getAllTags(IntPtr ndkCameraMetadata, + ref int numEntries, ref IntPtr tags); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e73dd53ccd4a3fcdbd975d01a572d20a68e1e15e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/CameraMetadataApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d972b11e53fb14a5cb38b3b81e420a7a +timeCreated: 1511395337 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..a92eee9d0bdd40431337294a2f6a52fcc915ac5c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs @@ -0,0 +1,144 @@ +//----------------------------------------------------------------------- +// <copyright file="FrameApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class FrameApi + { + private NativeSession m_NativeSession; + + public FrameApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public long GetTimestamp() + { + long timestamp = 0; + ExternApi.ArFrame_getTimestamp(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ref timestamp); + return timestamp; + } + + public IntPtr AcquireCamera() + { + IntPtr cameraHandle = IntPtr.Zero; + ExternApi.ArFrame_acquireCamera(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ref cameraHandle); + return cameraHandle; + } + + public IntPtr AcquirePointCloud() + { + IntPtr pointCloudHandle = IntPtr.Zero; + ExternApi.ArFrame_acquirePointCloud(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ref pointCloudHandle); + return pointCloudHandle; + } + + public IntPtr AcquireImageMetadata() + { + IntPtr imageMetadataHandle = IntPtr.Zero; + ExternApi.ArFrame_acquireImageMetadata(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ref imageMetadataHandle); + return imageMetadataHandle; + } + + public LightEstimate GetLightEstimate() + { + IntPtr lightEstimateHandle = m_NativeSession.LightEstimateApi.Create(); + ExternApi.ArFrame_getLightEstimate(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + lightEstimateHandle); + + LightEstimateState state = m_NativeSession.LightEstimateApi.GetState(lightEstimateHandle); + float pixelIntensity = m_NativeSession.LightEstimateApi.GetPixelIntensity(lightEstimateHandle); + + m_NativeSession.LightEstimateApi.Destroy(lightEstimateHandle); + + return new LightEstimate(state, pixelIntensity); + } + + public void TransformDisplayUvCoords(ref ApiDisplayUvCoords uv) + { + ApiDisplayUvCoords uvOut = new ApiDisplayUvCoords(); + ExternApi.ArFrame_transformDisplayUvCoords(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ApiDisplayUvCoords.NumFloats, ref uv, ref uvOut); + + uv = uvOut; + } + + public void GetUpdatedTrackables(List<Trackable> trackables) + { + IntPtr listHandle = m_NativeSession.TrackableListApi.Create(); + ExternApi.ArFrame_getUpdatedTrackables(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, + ApiTrackableType.BaseTrackable, listHandle); + + trackables.Clear(); + int count = m_NativeSession.TrackableListApi.GetCount(listHandle); + for (int i = 0; i < count; i++) + { + IntPtr trackableHandle = m_NativeSession.TrackableListApi.AcquireItem(listHandle, i); + trackables.Add(m_NativeSession.TrackableFactory(trackableHandle)); + } + + m_NativeSession.TrackableListApi.Destroy(listHandle); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_getTimestamp(IntPtr sessionHandle, + IntPtr frame, ref long timestamp); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern int ArFrame_acquireCamera(IntPtr sessionHandle, IntPtr frameHandle, + ref IntPtr cameraHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern int ArFrame_acquirePointCloud(IntPtr sessionHandle, IntPtr frameHandle, + ref IntPtr pointCloudHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_transformDisplayUvCoords(IntPtr session, IntPtr frame, + int numElements, ref ApiDisplayUvCoords uvsIn, ref ApiDisplayUvCoords uvsOut); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_getUpdatedTrackables(IntPtr sessionHandle, IntPtr frameHandle, + ApiTrackableType filterType, IntPtr outTrackableList); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_getLightEstimate(IntPtr sessionHandle, IntPtr frameHandle, + IntPtr lightEstimateHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_acquireImageMetadata(IntPtr sessionHandle, IntPtr frameHandle, + ref IntPtr outMetadata); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..c000f6349b4892056882df19f0428532e6b07117 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/FrameApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8343d1d4c171649e18d1c562131e1a22 +timeCreated: 1509578063 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..0f68995039af00748cc4b95b1c49fa558c06b40f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs @@ -0,0 +1,180 @@ +//----------------------------------------------------------------------- +// <copyright file="HitTestApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class HitTestApi + { + private NativeSession m_NativeSession; + + public HitTestApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public bool Raycast(IntPtr frameHandle, float x, float y, TrackableHitFlags filter, + List<TrackableHit> outHitList, bool isOnlyQueryingNearestHit) + { + outHitList.Clear(); + + IntPtr hitResultListHandle = IntPtr.Zero; + ExternApi.ArHitResultList_create(m_NativeSession.SessionHandle, ref hitResultListHandle); + ExternApi.ArFrame_hitTest(m_NativeSession.SessionHandle, frameHandle, x, y, hitResultListHandle); + + int hitListSize = 0; + ExternApi.ArHitResultList_getSize(m_NativeSession.SessionHandle, hitResultListHandle, ref hitListSize); + + for (int i = 0; i < hitListSize; i++) + { + TrackableHit trackableHit; + if (HitResultListGetItemAt(hitResultListHandle, i, out trackableHit)) + { + if ((filter & trackableHit.Flags) != TrackableHitFlags.None) + { + outHitList.Add(trackableHit); + } + } + } + + ExternApi.ArHitResultList_destroy(hitResultListHandle); + return outHitList.Count != 0; + } + + private bool HitResultListGetItemAt(IntPtr hitResultListHandle, int index, out TrackableHit outTrackableHit) + { + outTrackableHit = new TrackableHit(); + + // Query the hit result. + IntPtr hitResultHandle = IntPtr.Zero; + ExternApi.ArHitResult_create(m_NativeSession.SessionHandle, ref hitResultHandle); + ExternApi.ArHitResultList_getItem(m_NativeSession.SessionHandle, hitResultListHandle, index, hitResultHandle); + if (hitResultHandle == IntPtr.Zero) + { + ExternApi.ArHitResult_destroy(hitResultHandle); + return false; + } + + // Query the pose from hit result. + IntPtr poseHandle = m_NativeSession.PoseApi.Create(); + ExternApi.ArHitResult_getHitPose(m_NativeSession.SessionHandle, hitResultHandle, poseHandle); + Pose hitPose = m_NativeSession.PoseApi.ExtractPoseValue(poseHandle); + + // Query the distance from hit result. + float hitDistance = 0.0f; + ExternApi.ArHitResult_getDistance(m_NativeSession.SessionHandle, hitResultHandle, ref hitDistance); + + // Query the trackable from hit result. + IntPtr trackableHandle = IntPtr.Zero; + ExternApi.ArHitResult_acquireTrackable(m_NativeSession.SessionHandle, hitResultHandle, ref trackableHandle); + Trackable trackable = m_NativeSession.TrackableFactory(trackableHandle); + m_NativeSession.TrackableApi.Release(trackableHandle); + + // Calculate trackable hit flags. + TrackableHitFlags flag = TrackableHitFlags.None; + if (trackable == null) + { + Debug.Log("Could not create trackable from hit result."); + m_NativeSession.PoseApi.Destroy(poseHandle); + return false; + } + else if (trackable is TrackedPlane) + { + if (m_NativeSession.PlaneApi.IsPoseInPolygon(trackableHandle, poseHandle)) + { + flag |= TrackableHitFlags.PlaneWithinPolygon; + } + + if (m_NativeSession.PlaneApi.IsPoseInExtents(trackableHandle, poseHandle)) + { + flag |= TrackableHitFlags.PlaneWithinBounds; + } + + flag |= TrackableHitFlags.PlaneWithinInfinity; + } + else if (trackable is TrackedPoint) + { + var point = trackable as TrackedPoint; + flag |= TrackableHitFlags.FeaturePoint; + if (point.OrientationMode == TrackedPointOrientationMode.SurfaceNormal) + { + flag |= TrackableHitFlags.FeaturePointWithSurfaceNormal; + } + } + else + { + m_NativeSession.PoseApi.Destroy(poseHandle); + return false; + } + + outTrackableHit = new TrackableHit(hitPose, hitDistance, flag, trackable); + m_NativeSession.PoseApi.Destroy(poseHandle); + return true; + } + + private struct ExternApi + { + // Hit test function. + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArFrame_hitTest(IntPtr session, + IntPtr frame, float pixel_x, float pixel_y, IntPtr hit_result_list); + + // Hit list functions. + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResultList_create(IntPtr session, ref IntPtr out_hit_result_list); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResultList_destroy(IntPtr hit_result_list); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResultList_getSize(IntPtr session, IntPtr hit_result_list, ref int out_size); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResultList_getItem(IntPtr session, IntPtr hit_result_list, + int index, IntPtr out_hit_result); + + // Hit Result funcitons. + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResult_create(IntPtr session, ref IntPtr out_hit_result); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResult_destroy(IntPtr hit_result); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResult_getDistance(IntPtr session, IntPtr hit_result, + ref float out_distance); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResult_getHitPose(IntPtr session, IntPtr hit_result, IntPtr out_pose); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArHitResult_acquireTrackable(IntPtr session, IntPtr hit_result, + ref IntPtr out_trackable); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e3bb151d877eadcaa75604f9f87a74ee3e6301af --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/HitTestApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9732fd9cd933b45b9b101341baf74b73 +timeCreated: 1510610167 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..ddf7da698e8764efcb9f45c22ccc2066fbbd636b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs @@ -0,0 +1,84 @@ +//----------------------------------------------------------------------- +// <copyright file="LightEstimateApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class LightEstimateApi + { + private NativeSession m_NativeSession; + + public LightEstimateApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public IntPtr Create() + { + IntPtr lightEstimateHandle = IntPtr.Zero; + ExternApi.ArLightEstimate_create(m_NativeSession.SessionHandle, ref lightEstimateHandle); + return lightEstimateHandle; + } + + public void Destroy(IntPtr lightEstimateHandle) + { + ExternApi.ArLightEstimate_destroy(lightEstimateHandle); + } + + public LightEstimateState GetState(IntPtr lightEstimateHandle) + { + ApiLightEstimateState state = ApiLightEstimateState.NotValid; + ExternApi.ArLightEstimate_getState(m_NativeSession.SessionHandle, lightEstimateHandle, ref state); + return state.ToLightEstimateState(); + } + + public float GetPixelIntensity(IntPtr lightEstimateHandle) + { + float pixelIntensity = 0; + ExternApi.ArLightEstimate_getPixelIntensity(m_NativeSession.SessionHandle, + lightEstimateHandle, ref pixelIntensity); + return pixelIntensity; + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArLightEstimate_create(IntPtr sessionHandle, + ref IntPtr lightEstimateHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArLightEstimate_destroy(IntPtr lightEstimateHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArLightEstimate_getState(IntPtr sessionHandle, + IntPtr lightEstimateHandle, ref ApiLightEstimateState state); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArLightEstimate_getPixelIntensity(IntPtr sessionHandle, + IntPtr lightEstimateHandle, ref float pixelIntensity); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..9444edb776edfc7b41d956d9cf341c7612e2e46e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/LightEstimateApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1208855bfb606b34092b04a38c785ff9 +timeCreated: 1510799673 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs new file mode 100644 index 0000000000000000000000000000000000000000..0c83d5545076b8ffff0870f554362bdda3e20a01 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs @@ -0,0 +1,161 @@ +//----------------------------------------------------------------------- +// <copyright file="NativeSession.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class NativeSession + { + private IntPtr m_SessionHandle = IntPtr.Zero; + + private IntPtr m_FrameHandle = IntPtr.Zero; + + private IntPtr m_PointCloudHandle = IntPtr.Zero; + + private float m_LastReleasedPointcloudTimestamp = 0.0f; + + private TrackableManager m_TrackableManager = null; + + public NativeSession(IntPtr sessionHandle, IntPtr frameHandle) + { + m_SessionHandle = sessionHandle; + m_FrameHandle = frameHandle; + m_TrackableManager = new TrackableManager(this); + + AnchorApi = new AnchorApi(this); + CameraApi = new CameraApi(this); + CameraMetadataApi = new CameraMetadataApi(this); + FrameApi = new FrameApi(this); + HitTestApi = new HitTestApi(this); + LightEstimateApi = new LightEstimateApi(this); + PlaneApi = new PlaneApi(this); + PointApi = new PointApi(this); + PointCloudApi = new PointCloudApi(this); + PoseApi = new PoseApi(this); + SessionApi = new SessionApi(this); + SessionConfigApi = new SessionConfigApi(this); + TrackableApi = new TrackableApi(this); + TrackableListApi = new TrackableListApi(this); + } + + public IntPtr SessionHandle + { + get + { + return m_SessionHandle; + } + } + + public IntPtr FrameHandle + { + get + { + return m_FrameHandle; + } + } + + public IntPtr PointCloudHandle + { + get + { + return m_PointCloudHandle; + } + } + + public bool IsPointCloudNew + { + get + { + // TODO (b/73256094): Remove when fixed. + if (LifecycleManager.Instance.SessionStatus != SessionStatus.Tracking) + { + var previousLastTimestamp = m_LastReleasedPointcloudTimestamp; + m_LastReleasedPointcloudTimestamp = 0.0f; + return previousLastTimestamp != 0; + } + + return PointCloudApi.GetTimestamp(PointCloudHandle) != m_LastReleasedPointcloudTimestamp; + } + } + + public AnchorApi AnchorApi { get; private set; } + + public CameraApi CameraApi { get; private set; } + + public CameraMetadataApi CameraMetadataApi { get; private set; } + + public FrameApi FrameApi { get; private set; } + + public HitTestApi HitTestApi { get; private set; } + + public LightEstimateApi LightEstimateApi { get; private set; } + + public PlaneApi PlaneApi { get; private set; } + + public PointApi PointApi { get; private set; } + + public PointCloudApi PointCloudApi { get; private set; } + + public PoseApi PoseApi { get; private set; } + + public SessionApi SessionApi { get; private set; } + + public SessionConfigApi SessionConfigApi { get; private set; } + + public TrackableApi TrackableApi { get; private set; } + + public TrackableListApi TrackableListApi { get; private set; } + + public Trackable TrackableFactory(IntPtr nativeHandle) + { + return m_TrackableManager.TrackableFactory(nativeHandle); + } + + public void GetTrackables<T>(List<T> trackables, TrackableQueryFilter filter) where T : Trackable + { + m_TrackableManager.GetTrackables<T>(trackables, filter); + } + + public void OnUpdate() + { + // After first frame, release previous frame's point cloud. + if (m_PointCloudHandle != IntPtr.Zero) + { + m_LastReleasedPointcloudTimestamp = PointCloudApi.GetTimestamp(m_PointCloudHandle); + PointCloudApi.Release(m_PointCloudHandle); + m_PointCloudHandle = IntPtr.Zero; + } + + // TODO (b/73256094): Remove when fixed. + if (LifecycleManager.Instance.SessionStatus == SessionStatus.Tracking) + { + m_PointCloudHandle = FrameApi.AcquirePointCloud(); + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..23addb5f750e6933f7ccdfda4b449ca6ea6bc238 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/NativeSession.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d592900cfcf4d46c69256dbe400dec56 +timeCreated: 1516388608 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..a8e752c9f4826822fadab59728e4ac79cd2886de --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs @@ -0,0 +1,178 @@ +//----------------------------------------------------------------------- +// <copyright file="PlaneApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class PlaneApi + { + private const int k_MaxPolygonSize = 1024; + private NativeSession m_NativeSession; + private float[] m_TmpPoints; + private GCHandle m_TmpPointsHandle; + + public PlaneApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + m_TmpPoints = new float[k_MaxPolygonSize * 2]; + m_TmpPointsHandle = GCHandle.Alloc(m_TmpPoints, GCHandleType.Pinned); + } + + ~PlaneApi() + { + m_TmpPointsHandle.Free(); + } + + public Pose GetCenterPose(IntPtr planeHandle) + { + var poseHandle = m_NativeSession.PoseApi.Create(); + ExternApi.ArPlane_getCenterPose(m_NativeSession.SessionHandle, planeHandle, poseHandle); + Pose resultPose = m_NativeSession.PoseApi.ExtractPoseValue(poseHandle); + m_NativeSession.PoseApi.Destroy(poseHandle); + return resultPose; + } + + public float GetExtentX(IntPtr planeHandle) + { + float extentX = 0.0f; + ExternApi.ArPlane_getExtentX(m_NativeSession.SessionHandle, planeHandle, ref extentX); + return extentX; + } + + public float GetExtentZ(IntPtr planeHandle) + { + float extentZ = 0.0f; + ExternApi.ArPlane_getExtentZ(m_NativeSession.SessionHandle, planeHandle, ref extentZ); + return extentZ; + } + + public void GetPolygon(IntPtr planeHandle, List<Vector3> points) + { + points.Clear(); + int pointCount = 0; + ExternApi.ArPlane_getPolygonSize(m_NativeSession.SessionHandle, planeHandle, ref pointCount); + if (pointCount < 1) + { + return; + } + else if (pointCount > k_MaxPolygonSize) + { + Debug.LogError("GetPolygon::Plane polygon size exceeds buffer capacity."); + pointCount = k_MaxPolygonSize; + } + + ExternApi.ArPlane_getPolygon(m_NativeSession.SessionHandle, planeHandle, m_TmpPointsHandle.AddrOfPinnedObject()); + + var planeCenter = GetCenterPose(planeHandle); + var unityWorldTPlane = Matrix4x4.TRS(planeCenter.position, planeCenter.rotation, Vector3.one); + for (int i = pointCount - 2; i >= 0; i -= 2) + { + var point = unityWorldTPlane.MultiplyPoint3x4(new Vector3(m_TmpPoints[i], 0, -m_TmpPoints[i + 1])); + points.Add(point); + } + } + + public TrackedPlane GetSubsumedBy(IntPtr planeHandle) + { + IntPtr subsumerHandle = IntPtr.Zero; + ExternApi.ArPlane_acquireSubsumedBy(m_NativeSession.SessionHandle, planeHandle, ref subsumerHandle); + return m_NativeSession.TrackableFactory(subsumerHandle) as TrackedPlane; + } + + public bool IsPoseInExtents(IntPtr planeHandle, Pose pose) + { + // The int is used as a boolean value as the C API expects a int32_t value to represent a boolean. + int isPoseInExtents = 0; + var poseHandle = m_NativeSession.PoseApi.Create(pose); + ExternApi.ArPlane_isPoseInExtents(m_NativeSession.SessionHandle, planeHandle, poseHandle, ref isPoseInExtents); + m_NativeSession.PoseApi.Destroy(poseHandle); + return isPoseInExtents != 0; + } + + public bool IsPoseInExtents(IntPtr planeHandle, IntPtr poseHandle) + { + // The int is used as a boolean value as the C API expects a int32_t value to represent a boolean. + int isPoseInExtents = 0; + ExternApi.ArPlane_isPoseInExtents(m_NativeSession.SessionHandle, planeHandle, poseHandle, ref isPoseInExtents); + return isPoseInExtents != 0; + } + + public bool IsPoseInPolygon(IntPtr planeHandle, Pose pose) + { + // The int is used as a boolean value as the C API expects a int32_t value to represent a boolean. + int isPoseInPolygon = 0; + var poseHandle = m_NativeSession.PoseApi.Create(pose); + ExternApi.ArPlane_isPoseInPolygon(m_NativeSession.SessionHandle, planeHandle, poseHandle, ref isPoseInPolygon); + m_NativeSession.PoseApi.Destroy(poseHandle); + return isPoseInPolygon != 0; + } + + public bool IsPoseInPolygon(IntPtr planeHandle, IntPtr poseHandle) + { + // The int is used as a boolean value as the C API expects a int32_t value to represent a boolean. + int isPoseInPolygon = 0; + ExternApi.ArPlane_isPoseInPolygon(m_NativeSession.SessionHandle, planeHandle, poseHandle, ref isPoseInPolygon); + return isPoseInPolygon != 0; + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_getCenterPose(IntPtr sessionHandle, IntPtr planeHandle, + IntPtr poseHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_acquireSubsumedBy(IntPtr sessionHandle, IntPtr planeHandle, + ref IntPtr subsumerHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_getExtentX(IntPtr sessionHandle, IntPtr planeHandle, + ref float extentX); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_getExtentZ(IntPtr sessionHandle, IntPtr planeHandle, + ref float extentZ); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_getPolygonSize(IntPtr sessionHandle, IntPtr planeHandle, + ref int polygonSize); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_getPolygon(IntPtr sessionHandle, IntPtr planeHandle, + IntPtr polygonXZ); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_isPoseInExtents(IntPtr sessionHandle, IntPtr planeHandle, + IntPtr poseHandle, ref int isPoseInExtents); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPlane_isPoseInPolygon(IntPtr sessionHandle, IntPtr planeHandle, + IntPtr poseHandle, ref int isPoseInPolygon); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..4bd2f36b5a2b26af8017ab7e72ced5eb37f48e7c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PlaneApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: bc57253c2a28846679a773e6c2ee8c32 +timeCreated: 1509300062 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..05a81f759f296d0f9a7e354cf63590007099df60 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs @@ -0,0 +1,69 @@ +//----------------------------------------------------------------------- +// <copyright file="PointApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class PointApi + { + private NativeSession m_NativeSession; + + public PointApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public Pose GetPose(IntPtr pointHandle) + { + var poseHandle = m_NativeSession.PoseApi.Create(); + ExternApi.ArPoint_getPose(m_NativeSession.SessionHandle, pointHandle, poseHandle); + Pose resultPose = m_NativeSession.PoseApi.ExtractPoseValue(poseHandle); + m_NativeSession.PoseApi.Destroy(poseHandle); + return resultPose; + } + + public TrackedPointOrientationMode GetOrientationMode(IntPtr pointHandle) + { + ApiTrackedPointOrientationMode orientationMode = + ApiTrackedPointOrientationMode.Identity; + ExternApi.ArPoint_getOrientationMode(m_NativeSession.SessionHandle, pointHandle, + ref orientationMode); + return orientationMode.ToTrackedPointOrientationMode(); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPoint_getPose(IntPtr session, IntPtr point, IntPtr out_pose); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPoint_getOrientationMode(IntPtr session, IntPtr point, + ref ApiTrackedPointOrientationMode orientationMode); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..379a59124d764b7e650b0d3b7689808bc2e05c3d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 71ae835ce954d488a85396c79162f733 +timeCreated: 1510617062 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..c120520c4a77d25898798c937c6d1f57be0c55a2 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------- +// <copyright file="PointCloudApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class PointCloudApi + { + private NativeSession m_NativeSession; + + private float[] m_CachedVector = new float[4]; + + public PointCloudApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public long GetTimestamp(IntPtr pointCloudHandle) + { + long timestamp = 0; + ExternApi.ArPointCloud_getTimestamp(m_NativeSession.SessionHandle, pointCloudHandle, ref timestamp); + return timestamp; + } + + public int GetNumberOfPoints(IntPtr pointCloudHandle) + { + int pointCount = 0; + ExternApi.ArPointCloud_getNumberOfPoints(m_NativeSession.SessionHandle, pointCloudHandle, ref pointCount); + + return pointCount; + } + + public Vector4 GetPoint(IntPtr pointCloudHandle, int index) + { + IntPtr pointCloudNativeHandle = IntPtr.Zero; + ExternApi.ArPointCloud_getData(m_NativeSession.SessionHandle, pointCloudHandle, ref pointCloudNativeHandle); + IntPtr pointHandle = new IntPtr(pointCloudNativeHandle.ToInt64() + + (Marshal.SizeOf(typeof(Vector4)) * index)); + Marshal.Copy(pointHandle, m_CachedVector, 0, 4); + + // Negate z axis because points are returned in OpenGl space. + return new Vector4(m_CachedVector[0], m_CachedVector[1], -m_CachedVector[2], m_CachedVector[3]); + } + + public void CopyPoints(IntPtr pointCloudHandle, List<Vector4> points) + { + points.Clear(); + + IntPtr pointCloudNativeHandle = IntPtr.Zero; + int pointCloudSize = GetNumberOfPoints(pointCloudHandle); + + ExternApi.ArPointCloud_getData(m_NativeSession.SessionHandle, pointCloudHandle, ref pointCloudNativeHandle); + + MarshalingHelper.AddUnmanagedStructArrayToList<Vector4>(pointCloudNativeHandle, + pointCloudSize, points); + + for (int i = 0; i < pointCloudSize; ++i) + { + // Negate z axis because points are returned in OpenGl space. + points[i] = new Vector4(points[i].x, points[i].y, + -points[i].z, points[i].w); + } + } + + public void Release(IntPtr pointCloudHandle) + { + ExternApi.ArPointCloud_release(pointCloudHandle); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPointCloud_getTimestamp(IntPtr session, IntPtr pointCloudHandle, + ref long timestamp); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPointCloud_getNumberOfPoints(IntPtr session, IntPtr pointCloudHandle, + ref int pointCount); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPointCloud_getData(IntPtr session, IntPtr pointCloudHandle, + ref IntPtr pointCloudData); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPointCloud_release(IntPtr pointCloudHandle); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..41593bd57f574629aa8c7b064af54b8b1dc6aab2 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PointCloudApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d6fca0e25bb6e4612acb66cacc00f8ff +timeCreated: 1509468914 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7b9ba2033ee74a64c3b06486288c94ce6c25b62 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------- +// <copyright file="PoseApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class PoseApi + { + private NativeSession m_NativeSession; + + public PoseApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public IntPtr Create() + { + return Create(Pose.identity); + } + + public IntPtr Create(Pose pose) + { + ApiPoseData rawPose = new ApiPoseData(pose); + + IntPtr poseHandle = IntPtr.Zero; + ExternApi.ArPose_create(m_NativeSession.SessionHandle, ref rawPose, ref poseHandle); + return poseHandle; + } + + public void Destroy(IntPtr nativePose) + { + ExternApi.ArPose_destroy(nativePose); + } + + public Pose ExtractPoseValue(IntPtr poseHandle) + { + ApiPoseData poseValue = new ApiPoseData(Pose.identity); + ExternApi.ArPose_getPoseRaw(m_NativeSession.SessionHandle, poseHandle, ref poseValue); + return poseValue.ToUnityPose(); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPose_create(IntPtr session, ref ApiPoseData rawPose, ref IntPtr poseHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPose_destroy(IntPtr poseHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArPose_getPoseRaw(IntPtr sessionHandle, IntPtr poseHandle, + ref ApiPoseData rawPose); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..2b102fb17cc3add366c024e6b9a307add67cebec --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/PoseApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8bb1ac230a9054569b08d1ca210d8b01 +timeCreated: 1509300062 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..b57e0f2f9fabcbbe634b62c06ccfe1e930520bd4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------- +// <copyright file="SessionApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class SessionApi + { + private NativeSession m_NativeSession; + + public SessionApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public void ReportEngineType() + { + ExternApi.ArSession_reportEngineType(m_NativeSession.SessionHandle, "Unity", + Application.unityVersion); + } + + public ApiArStatus CheckSupported(ARCoreSessionConfig config) + { + IntPtr configHandle; + if (config == null) + { + configHandle = IntPtr.Zero; + return ApiArStatus.ErrorUnsupportedConfiguration; + } + else + { + configHandle = m_NativeSession.SessionConfigApi.Create(); + m_NativeSession.SessionConfigApi.UpdateApiConfigWithArCoreSessionConfig(configHandle, config); + } + + ApiArStatus ret = ExternApi.ArSession_checkSupported(m_NativeSession.SessionHandle, configHandle); + m_NativeSession.SessionConfigApi.Destroy(configHandle); + return ret; + } + + public bool SetConfiguration(ARCoreSessionConfig sessionConfig) + { + IntPtr configHandle = m_NativeSession.SessionConfigApi.Create(); + m_NativeSession.SessionConfigApi.UpdateApiConfigWithArCoreSessionConfig(configHandle, sessionConfig); + + bool ret = ExternApi.ArSession_configure(m_NativeSession.SessionHandle, configHandle) == 0; + m_NativeSession.SessionConfigApi.Destroy(configHandle); + + return ret; + } + + public void GetAllTrackables(List<Trackable> trackables) + { + IntPtr listHandle = m_NativeSession.TrackableListApi.Create(); + ExternApi.ArSession_getAllTrackables(m_NativeSession.SessionHandle, ApiTrackableType.BaseTrackable, listHandle); + + trackables.Clear(); + int count = m_NativeSession.TrackableListApi.GetCount(listHandle); + for (int i = 0; i < count; i++) + { + IntPtr trackableHandle = m_NativeSession.TrackableListApi.AcquireItem(listHandle, i); + trackables.Add(m_NativeSession.TrackableFactory(trackableHandle)); + } + + m_NativeSession.TrackableListApi.Destroy(listHandle); + } + + public Anchor CreateAnchor(Pose pose) + { + IntPtr poseHandle = m_NativeSession.PoseApi.Create(pose); + IntPtr anchorHandle = IntPtr.Zero; + ExternApi.ArSession_acquireNewAnchor(m_NativeSession.SessionHandle, poseHandle, ref anchorHandle); + var anchorResult = Anchor.AnchorFactory(anchorHandle, m_NativeSession); + m_NativeSession.PoseApi.Destroy(poseHandle); + + return anchorResult; + } + + public void SetDisplayGeometry(ScreenOrientation orientation, int width, int height) + { + const int androidRotation0 = 0; + const int androidRotation90 = 1; + const int androidRotation180 = 2; + const int androidRotation270 = 3; + + int androidOrientation = 0; + switch (orientation) + { + case ScreenOrientation.LandscapeLeft: + androidOrientation = androidRotation90; + break; + case ScreenOrientation.LandscapeRight: + androidOrientation = androidRotation270; + break; + case ScreenOrientation.Portrait: + androidOrientation = androidRotation0; + break; + case ScreenOrientation.PortraitUpsideDown: + androidOrientation = androidRotation180; + break; + } + + ExternApi.ArSession_setDisplayGeometry(m_NativeSession.SessionHandle, androidOrientation, width, height); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArSession_destroy(IntPtr sessionHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern ApiArStatus ArSession_checkSupported(IntPtr sessionHandle, IntPtr config); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern int ArSession_configure(IntPtr sessionHandle, IntPtr config); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArSession_setDisplayGeometry(IntPtr sessionHandle, int rotation, int width, + int height); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArSession_getAllTrackables(IntPtr sessionHandle, ApiTrackableType filterType, + IntPtr trackableList); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArSession_reportEngineType(IntPtr sessionHandle, + string engineType, + string engineVersion); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern int ArSession_acquireNewAnchor(IntPtr sessionHandle, IntPtr poseHandle, + ref IntPtr anchorHandle); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..24087e25cf1a98d47bdf753744f6f5dc08695063 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e62f0c78c398d4404a32f71b57e153e4 +timeCreated: 1509504247 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..8f9e91ad7b0661f7ca1150e5627904d262abd8e8 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------- +// <copyright file="SessionConfigApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class SessionConfigApi + { + private NativeSession m_NativeSession; + + public SessionConfigApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public IntPtr Create() + { + IntPtr configHandle = IntPtr.Zero; + ExternApi.ArConfig_create(m_NativeSession.SessionHandle, ref configHandle); + return configHandle; + } + + public void Destroy(IntPtr configHandle) + { + ExternApi.ArConfig_destroy(configHandle); + } + + public void UpdateApiConfigWithArCoreSessionConfig(IntPtr configHandle, ARCoreSessionConfig arCoreSessionConfig) + { + var lightingMode = ApiLightEstimationMode.Disabled; + if (arCoreSessionConfig.EnableLightEstimation) + { + lightingMode = ApiLightEstimationMode.AmbientIntensity; + } + + ExternApi.ArConfig_setLightEstimationMode(m_NativeSession.SessionHandle, configHandle, lightingMode); + + var planeFindingMode = ApiPlaneFindingMode.Disabled; + if (arCoreSessionConfig.EnablePlaneFinding) + { + planeFindingMode = ApiPlaneFindingMode.Horizontal; + } + + ExternApi.ArConfig_setPlaneFindingMode(m_NativeSession.SessionHandle, configHandle, planeFindingMode); + + var updateMode = ApiUpdateMode.LatestCameraImage; + if (arCoreSessionConfig.MatchCameraFramerate) + { + updateMode = ApiUpdateMode.Blocking; + + // Set vSyncCount to 0 so frame in rendered only when we have a new background texture. + QualitySettings.vSyncCount = 0; + } + + ExternApi.ArConfig_setUpdateMode(m_NativeSession.SessionHandle, configHandle, updateMode); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArConfig_create(IntPtr session, ref IntPtr out_config); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArConfig_destroy(IntPtr config); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArConfig_setLightEstimationMode(IntPtr session, IntPtr config, + ApiLightEstimationMode light_estimation_mode); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArConfig_setPlaneFindingMode(IntPtr session, IntPtr config, + ApiPlaneFindingMode plane_finding_mode); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArConfig_setUpdateMode(IntPtr session, IntPtr config, + ApiUpdateMode update_mode); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..07728a103b60b11c508e797e066276432b03b29e --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/SessionConfigApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5bad7cdbe53c84daa86747adecf2feb1 +timeCreated: 1510876906 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..52290b99e58f94ea0071752c1489f9ca228d55ff --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs @@ -0,0 +1,117 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class TrackableApi + { + private NativeSession m_NativeSession; + + public TrackableApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public ApiTrackableType GetType(IntPtr trackableHandle) + { + ApiTrackableType type = ApiTrackableType.Plane; + ExternApi.ArTrackable_getType(m_NativeSession.SessionHandle, trackableHandle, ref type); + return type; + } + + public TrackingState GetTrackingState(IntPtr trackableHandle) + { + ApiTrackingState apiTrackingState = ApiTrackingState.Stopped; + ExternApi.ArTrackable_getTrackingState(m_NativeSession.SessionHandle, trackableHandle, + ref apiTrackingState); + return apiTrackingState.ToTrackingState(); + } + + public bool AcquireNewAnchor(IntPtr trackableHandle, Pose pose, out IntPtr anchorHandle) + { + IntPtr poseHandle = m_NativeSession.PoseApi.Create(pose); + anchorHandle = IntPtr.Zero; + int status = ExternApi.ArTrackable_acquireNewAnchor(m_NativeSession.SessionHandle, trackableHandle, poseHandle, + ref anchorHandle); + m_NativeSession.PoseApi.Destroy(poseHandle); + return status == 0; + } + + public void Release(IntPtr trackableHandle) + { + ExternApi.ArTrackable_release(trackableHandle); + } + + public void GetAnchors(IntPtr trackableHandle, List<Anchor> anchors) + { + IntPtr anchorListHandle = m_NativeSession.AnchorApi.CreateList(); + ExternApi.ArTrackable_getAnchors(m_NativeSession.SessionHandle, trackableHandle, anchorListHandle); + + anchors.Clear(); + int anchorCount = m_NativeSession.AnchorApi.GetListSize(anchorListHandle); + for (int i = 0; i < anchorCount; i++) + { + IntPtr anchorHandle = m_NativeSession.AnchorApi.AcquireListItem(anchorListHandle, i); + Anchor anchor = Anchor.AnchorFactory(anchorHandle, m_NativeSession, false); + if (anchor == null) + { + Debug.LogFormat("Unable to find Anchor component for handle {0}", anchorHandle); + } + else + { + anchors.Add(anchor); + } + } + + m_NativeSession.AnchorApi.DestroyList(anchorListHandle); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackable_getType(IntPtr sessionHandle, IntPtr trackableHandle, + ref ApiTrackableType trackableType); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackable_getTrackingState(IntPtr sessionHandle, + IntPtr trackableHandle, ref ApiTrackingState trackingState); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern int ArTrackable_acquireNewAnchor(IntPtr sessionHandle, IntPtr trackableHandle, + IntPtr poseHandle, ref IntPtr anchorHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackable_release(IntPtr trackableHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackable_getAnchors(IntPtr sessionHandle, IntPtr trackableHandle, + IntPtr outputListHandle); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..45a485f52bd888246f81312cac84563bb61bad16 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 87745264d13d44f2a8295d25c2d6666e +timeCreated: 1509300062 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs new file mode 100644 index 0000000000000000000000000000000000000000..44c4bd7454d86a30408a8d6ba51049b7249c73cf --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs @@ -0,0 +1,85 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableListApi.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class TrackableListApi + { + private NativeSession m_NativeSession; + + public TrackableListApi(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + public IntPtr Create() + { + IntPtr handle = IntPtr.Zero; + ExternApi.ArTrackableList_create(m_NativeSession.SessionHandle, ref handle); + return handle; + } + + public void Destroy(IntPtr listHandle) + { + ExternApi.ArTrackableList_destroy(listHandle); + } + + public int GetCount(IntPtr listHandle) + { + int count = 0; + ExternApi.ArTrackableList_getSize(m_NativeSession.SessionHandle, listHandle, ref count); + return count; + } + + public IntPtr AcquireItem(IntPtr listHandle, int index) + { + IntPtr trackableHandle = IntPtr.Zero; + ExternApi.ArTrackableList_acquireItem(m_NativeSession.SessionHandle, listHandle, index, + ref trackableHandle); + return trackableHandle; + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackableList_create(IntPtr sessionHandle, ref IntPtr trackableListHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackableList_destroy(IntPtr trackableListHandle); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackableList_getSize(IntPtr sessionHandle, IntPtr trackableListHandle, + ref int outSize); + + [DllImport(ApiConstants.ARCoreNativeApi)] + public static extern void ArTrackableList_acquireItem(IntPtr sessionHandle, IntPtr trackableListHandle, + int index, ref IntPtr outTrackable); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..7135e3bbb7e3debdb71fa01bbf64f3a5c3fae3ef --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Api/TrackableListApi.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1d2c4263ac8ea480e98fbaf3e7c08815 +timeCreated: 1510542389 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..67183481f2b645b394eaf97c2fdd17170fec6c24 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="ApkAvailabilityStatus.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// Possible statuses for the ARCore APK availability on a device. + /// </summary> + public enum ApkAvailabilityStatus + { + UnknownError = 0, + UnknownChecking = 1, + UnknownTimedOut = 2, + UnsupportedDeviceNotCapable = 100, + SupportedNotInstalled = 201, + SupportedApkTooOld = 202, + SupportedInstalled = 203 + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..dfb8a7e0bec848d235d328e27bd112f627e9b7c6 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkAvailabilityStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 56892237bd519491d9a60f5ebd3e0f72 +timeCreated: 1517868046 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..c0d96a7b96175a62a8e36a0161c3adccff9d9a4d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="ApkInstallationStatus.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// Possible statuses for an ARCore APK installation request on a device. + /// </summary> + public enum ApkInstallationStatus + { + Uninitialized = 0, + Requested = 1, + Success = 100, + Error = 200, + ErrorDeviceNotCompatible = 201, + ErrorAndroidVersionNotSupported = 202, + ErrorUserDeclined = 203, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a5e7994a517ad748b71fcf8b602d1c553f72bc45 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/ApkInstallationStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a1de1e6e76a30499e970bb552522dec7 +timeCreated: 1517858804 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async.meta new file mode 100644 index 0000000000000000000000000000000000000000..7f08641615b1978e29a0e435cafc70bdfc4a1988 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b3aabcae5f79543dea8251d640bde6ad +folderAsset: yes +timeCreated: 1502330118 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs new file mode 100644 index 0000000000000000000000000000000000000000..f755b86a13725bf7b6a9d8e0f949e3752ccf6cee --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs @@ -0,0 +1,61 @@ +//----------------------------------------------------------------------- +// <copyright file="WaitForTaskCompletionYieldInstruction.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + using UnityEngine; + + /// <summary> + /// A yield instruction that blocks a coroutine until an AsyncTask has completed. + /// </summary> + /// <typeparam name="T">The type of the AsyncTask result.</typeparam> + public class WaitForTaskCompletionYieldInstruction<T> : CustomYieldInstruction + { + /// <summary> + /// The AsyncTask the yield instruction waits on. + /// </summary> + private AsyncTask<T> m_Task; + + /// <summary> + /// Constructor for WaitForTaskCompletionYieldInstruction. + /// </summary> + /// <param name="task">The task to wait for completion.</param> + public WaitForTaskCompletionYieldInstruction(AsyncTask<T> task) + { + m_Task = task; + } + + /// <summary> + /// Gets a value indicating whether the coroutine instruction should keep waiting. + /// </summary> + /// <value><c>true</c> if the task is incomplete, otherwise <c>false</c>.</value> + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overridden method.")] + public override bool keepWaiting + { + get + { + return !m_Task.IsComplete; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..4d911ede0296edbd4ed8380bb2d5fd7e35224821 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Async/WaitForTaskCompletionYieldInstruction.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2ba38d18d01304b4ab5105846c55aff1 +timeCreated: 1502330118 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs new file mode 100644 index 0000000000000000000000000000000000000000..428ce1ef5d4dee191b1eba15b7971af8a8978efa --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs @@ -0,0 +1,166 @@ +//----------------------------------------------------------------------- +// <copyright file="AsyncTask.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using System.Threading; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// A class used for monitoring the status of an asynchronous task. + /// </summary> + /// <typeparam name="T">The resultant type of the task.</typeparam> + public class AsyncTask<T> + { + /// <summary> + /// A collection of actons to perform on the main Unity thread after the task is complete. + /// </summary> + private List<Action<T>> m_ActionsUponTaskCompletion; + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Constructor for AsyncTask. + /// </summary> + /// <param name="asyncOperationComplete">A callback that, when invoked, changes the status of the task to + /// complete and sets the result based on the argument supplied.</param> + public AsyncTask(out Action<T> asyncOperationComplete) + { + IsComplete = false; + asyncOperationComplete = delegate(T result) + { + this.Result = result; + IsComplete = true; + if (m_ActionsUponTaskCompletion != null) + { + AsyncTask.PerformActionInUpdate(() => + { + for (int i = 0; i < m_ActionsUponTaskCompletion.Count; i++) + { + m_ActionsUponTaskCompletion[i](result); + } + }); + } + }; + } + + /// @endcond + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Constructor for AsyncTask that creates a completed task. + /// </summary> + /// <param name="result">The result of the completed task.</param> + public AsyncTask(T result) + { + Result = result; + IsComplete = true; + } + + /// @endcond + + /// <summary> + /// Gets a value indicating whether the task is complete. + /// </summary> + /// <value><c>true</c> if the task is complete, otherwise <c>false</c>.</value> + public bool IsComplete { get; private set; } + + /// <summary> + /// Gets the result of a completed task. + /// </summary> + /// <value>The result of the completed task.</value> + public T Result { get; private set; } + + /// <summary> + /// Returns a yield instruction that monitors this task for completion within a coroutine. + /// </summary> + /// <returns>A yield instruction that monitors this task for completion.</returns> + public CustomYieldInstruction WaitForCompletion() + { + return new WaitForTaskCompletionYieldInstruction<T>(this); + } + + /// <summary> + /// Performs an action (callback) in the first Unity Update() call after task completion. + /// </summary> + /// <param name="doAfterTaskComplete">The action to invoke when task is complete. The result of the task will + /// be passed as an argument to the action.</param> + /// <returns>The invoking asynchronous task.</returns> + public AsyncTask<T> ThenAction(Action<T> doAfterTaskComplete) + { + // Perform action now if task is already complete. + if (IsComplete) + { + doAfterTaskComplete(Result); + return this; + } + + // Allocate list if needed (avoids allocation if then is not used). + if (m_ActionsUponTaskCompletion == null) + { + m_ActionsUponTaskCompletion = new List<Action<T>>(); + } + + m_ActionsUponTaskCompletion.Add(doAfterTaskComplete); + return this; + } + } + + /// @cond EXCLUDE_FROM_DOXYGEN + /// <summary> + /// Helper methods for dealing with asynchronous tasks. + /// </summary> + public class AsyncTask + { + private static Queue<Action> s_UpdateActionQueue = new Queue<Action>(); + private static object s_LockObject = new object(); + + /// <summary> + /// Queues an action to be performed on Unity thread in Update(). This method can be called by any thread. + /// </summary> + /// <param name="action">The action to perform.</param> + public static void PerformActionInUpdate(Action action) + { + lock (s_LockObject) + { + s_UpdateActionQueue.Enqueue(action); + } + } + + /// <summary> + /// An Update handler called each frame. + /// </summary> + public static void OnUpdate() + { + lock (s_LockObject) + { + while (s_UpdateActionQueue.Count > 0) + { + Action action = s_UpdateActionQueue.Dequeue(); + action(); + } + } + } + } + + /// @endcond +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..62982e1947246318c54857549b3c6d1ae89de6f3 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/AsyncTask.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d48675563f8a14e85bb73c0a6d45d9f0 +timeCreated: 1503943281 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs new file mode 100644 index 0000000000000000000000000000000000000000..f54dc35ca3cf3491fd3c1cb129e356b57c1ac17b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs @@ -0,0 +1,327 @@ +//----------------------------------------------------------------------- +// <copyright file="CameraMetadataTag.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// This enum follows the layout of NdkCameraMetadataTags. + /// The values in the file are used for requesting / marshaling camera image's metadata. + /// The comments have been removed to keep the code readable. Please refer to + /// NdkCameraMetadataTags.h for documentation: + /// https://developer.android.com/ndk/reference/ndk_camera_metadata_tags_8h.html . + /// </summary> + public enum CameraMetadataTag + { + SectionColorCorrection = 0, + SectionControl = 1, + SectionEdge = 3, + SectionFlash = 4, + SectionFlashInfo = 5, + SectionHotPixel = 6, + SectionJpeg = 7, + SectionLens = 8, + SectionLensInfo = 9, + SectionNoiseReduction = 10, + SectionRequest = 12, + SectionScaler = 13, + SectionSensor = 14, + SectionSensorInfo = 15, + SectionShading = 16, + SectionStatistics = 17, + SectionStatisticsInfo = 18, + SectionTonemap = 19, + SectionInfo = 21, + SectionBlackLevel = 22, + SectionSync = 23, + SectionDepth = 25, + + // Start Value Of Each Section. + ColorCorrectionStart = SectionColorCorrection << 16, + ControlStart = SectionControl << 16, + EdgeStart = SectionEdge << 16, + FlashStart = SectionFlash << 16, + FlashInfoStart = SectionFlashInfo << 16, + HotPixelStart = SectionHotPixel << 16, + JpegStart = SectionJpeg << 16, + LensStart = SectionLens << 16, + LensInfoStart = SectionLensInfo << 16, + NoiseReductionStart = SectionNoiseReduction << 16, + RequestStart = SectionRequest << 16, + ScalerStart = SectionScaler << 16, + SensorStart = SectionSensor << 16, + SensorInfoStart = SectionSensorInfo << 16, + ShadingStart = SectionShading << 16, + StatisticsStart = SectionStatistics << 16, + StatisticsInfoStart = SectionStatisticsInfo << 16, + TonemapStart = SectionTonemap << 16, + InfoStart = SectionInfo << 16, + BlackLevelStart = SectionBlackLevel << 16, + SyncStart = SectionSync << 16, + DepthStart = SectionDepth << 16, + + // Note that we only expose the keys that could be used in the camera metadata from the capture + // result. The keys may only appear in CameraCharacteristics are not exposed here. + ColorCorrectionMode = // Byte (Enum) + ColorCorrectionStart, + + ColorCorrectionTransform = // Rational[33] + ColorCorrectionStart + 1, + + ColorCorrectionGains = // Float[4] + ColorCorrectionStart + 2, + + ColorCorrectionAberrationMode = // Byte (Enum) + ColorCorrectionStart + 3, + + ControlAeAntibandingMode = // Byte (Enum) + ControlStart, + + ControlAeExposureCompensation = // Int32 + ControlStart + 1, + + ControlAeLock = // Byte (Enum) + ControlStart + 2, + + ControlAeMode = // Byte (Enum) + ControlStart + 3, + + ControlAeRegions = // Int32[5areaCount] + ControlStart + 4, + + ControlAeTargetFpsRange = // Int32[2] + ControlStart + 5, + + ControlAePrecaptureTrigger = // Byte (Enum) + ControlStart + 6, + + ControlAfMode = // Byte (Enum) + ControlStart + 7, + + ControlAfRegions = // Int32[5areaCount] + ControlStart + 8, + + ControlAfTrigger = // Byte (Enum) + ControlStart + 9, + + ControlAwbLock = // Byte (Enum) + ControlStart + 10, + + ControlAwbMode = // Byte (Enum) + ControlStart + 11, + + ControlAwbRegions = // Int32[5areaCount] + ControlStart + 12, + + ControlCaptureIntent = // Byte (Enum) + ControlStart + 13, + + ControlEffectMode = // Byte (Enum) + ControlStart + 14, + + ControlMode = // Byte (Enum) + ControlStart + 15, + + ControlSceneMode = // Byte (Enum) + ControlStart + 16, + + ControlVideoStabilizationMode = // Byte (Enum) + ControlStart + 17, + + ControlAeState = // Byte (Enum) + ControlStart + 31, + + ControlAfState = // Byte (Enum) + ControlStart + 32, + + ControlAwbState = // Byte (Enum) + ControlStart + 34, + + ControlPostRawSensitivityBoost = // Int32 + ControlStart + 40, + + EdgeMode = // Byte (Enum) + EdgeStart, + + FlashMode = // Byte (Enum) + FlashStart + 2, + + FlashState = // Byte (Enum) + FlashStart + 5, + + HotPixelMode = // Byte (Enum) + HotPixelStart, + + JpegGpsCoordinates = // Double[3] + JpegStart, + + JpegGpsProcessingMethod = // Byte + JpegStart + 1, + + JpegGpsTimestamp = // Int64 + JpegStart + 2, + + JpegOrientation = // Int32 + JpegStart + 3, + + JpegQuality = // Byte + JpegStart + 4, + + JpegThumbnailQuality = // Byte + JpegStart + 5, + + JpegThumbnailSize = // Int32[2] + JpegStart + 6, + + LensAperture = // Float + LensStart, + + LensFilterDensity = // Float + LensStart + 1, + + LensFocalLength = // Float + LensStart + 2, + + LensFocusDistance = // Float + LensStart + 3, + + LensOpticalStabilizationMode = // Byte (Enum) + LensStart + 4, + + LensPoseRotation = // Float[4] + LensStart + 6, + + LensPoseTranslation = // Float[3] + LensStart + 7, + + LensFocusRange = // Float[2] + LensStart + 8, + + LensState = // Byte (Enum) + LensStart + 9, + + LensIntrinsicCalibration = // Float[5] + LensStart + 10, + + LensRadialDistortion = // Float[6] + LensStart + 11, + + NoiseReductionMode = // Byte (Enum) + NoiseReductionStart, + + RequestPipelineDepth = // Byte + RequestStart + 9, + + ScalerCropRegion = // Int32[4] + ScalerStart, + + SensorExposureTime = // Int64 + SensorStart, + + SensorFrameDuration = // Int64 + SensorStart + 1, + + SensorSensitivity = // Int32 + SensorStart + 2, + + SensorTimestamp = // Int64 + SensorStart + 16, + + SensorNeutralColorPoint = // Rational[3] + SensorStart + 18, + + SensorNoiseProfile = // Double[2Cfa Channels] + SensorStart + 19, + + SensorGreenSplit = // Float + SensorStart + 22, + + SensorTestPatternData = // Int32[4] + SensorStart + 23, + + SensorTestPatternMode = // Int32 (Enum) + SensorStart + 24, + + SensorRollingShutterSkew = // Int64 + SensorStart + 26, + + SensorDynamicBlackLevel = // Float[4] + SensorStart + 28, + + SensorDynamicWhiteLevel = // Int32 + SensorStart + 29, + + ShadingMode = // Byte (Enum) + ShadingStart, + + StatisticsFaceDetectMode = // Byte (Enum) + StatisticsStart, + + StatisticsHotPixelMapMode = // Byte (Enum) + StatisticsStart + 3, + + StatisticsFaceIds = // Int32[N] + StatisticsStart + 4, + + StatisticsFaceLandmarks = // Int32[N6] + StatisticsStart + 5, + + StatisticsFaceRectangles = // Int32[N4] + StatisticsStart + 6, + + StatisticsFaceScores = // Byte[N] + StatisticsStart + 7, + + StatisticsLensShadingMap = // Float[4nm] + StatisticsStart + 11, + + StatisticsSceneFlicker = // Byte (Enum) + StatisticsStart + 14, + + StatisticsHotPixelMap = // Int32[2n] + StatisticsStart + 15, + + StatisticsLensShadingMapMode = // Byte (Enum) + StatisticsStart + 16, + + TonemapCurveBlue = // Float[N2] + TonemapStart, + + TonemapCurveGreen = // Float[N2] + TonemapStart + 1, + + TonemapCurveRed = // Float[N2] + TonemapStart + 2, + + TonemapMode = // Byte (Enum) + TonemapStart + 3, + + TonemapGamma = // Float + TonemapStart + 6, + + TonemapPresetCurve = // Byte (Enum) + TonemapStart + 7, + + BlackLevelLock = // Byte (Enum) + BlackLevelStart, + + SyncFrameNumber = // Int64 (Enum) + SyncStart, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..0ed78a81d966c68c30d4cefab15fd6ea673e6a94 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataTag.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 68f2bf600965540b080a2244b1221f8e +timeCreated: 1511913936 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs new file mode 100644 index 0000000000000000000000000000000000000000..f91296059095f76c82a5e2625d493a870cd824c9 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs @@ -0,0 +1,271 @@ +//----------------------------------------------------------------------- +// <copyright file="CameraMetadataValue.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Runtime.InteropServices; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Struct to contain camera metadata's value. When querying data from the struct, caller is responsible + /// for making sure the querying data type matches the m_type. + /// + /// For example: if m_type is NdkCameraMetadataType.Byte, caller should only use + /// CameraMetadataValue.AsByte() to access the value. + /// </summary> + [StructLayout(LayoutKind.Explicit)] + public struct CameraMetadataValue + { + [FieldOffset(0)] + private NdkCameraMetadataType m_Type; + [FieldOffset(4)] + private sbyte m_ByteValue; + [FieldOffset(4)] + private int m_IntValue; + [FieldOffset(4)] + private long m_LongValue; + [FieldOffset(4)] + private float m_FloatValue; + [FieldOffset(4)] + private double m_DoubleValue; + [FieldOffset(4)] + private CameraMetadataRational m_RationalValue; + + /// <summary> + /// Constructs CameraMetadataValue using sbyte. This constructor only sets the sbyte field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="byteValue">The byte value set to the struct.</param> + public CameraMetadataValue(sbyte byteValue) + { + m_IntValue = 0; + m_LongValue = 0; + m_FloatValue = 0; + m_DoubleValue = 0; + m_RationalValue = new CameraMetadataRational(); + + m_Type = NdkCameraMetadataType.Byte; + m_ByteValue = byteValue; + } + + /// <summary> + /// Constructs CameraMetadataValue using int. This constructor only sets the int field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="intValue">The int value set to the struct.</param> + public CameraMetadataValue(int intValue) + { + m_ByteValue = 0; + m_LongValue = 0; + m_FloatValue = 0; + m_DoubleValue = 0; + m_RationalValue = new CameraMetadataRational(); + + m_Type = NdkCameraMetadataType.Int32; + m_IntValue = intValue; + } + + /// <summary> + /// Constructs CameraMetadataValue using long. This constructor only sets the long field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="longValue">The long value set to the struct.</param> + public CameraMetadataValue(long longValue) + { + m_ByteValue = 0; + m_IntValue = 0; + m_FloatValue = 0; + m_DoubleValue = 0; + m_RationalValue = new CameraMetadataRational(); + + m_Type = NdkCameraMetadataType.Int64; + m_LongValue = longValue; + } + + /// <summary> + /// Constructs CameraMetadataValue using float. This constructor only sets the float field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="floatValue">The float value set to the struct.</param> + public CameraMetadataValue(float floatValue) + { + m_ByteValue = 0; + m_IntValue = 0; + m_LongValue = 0; + m_DoubleValue = 0; + m_RationalValue = new CameraMetadataRational(); + + m_Type = NdkCameraMetadataType.Float; + m_FloatValue = floatValue; + } + + /// <summary> + /// Constructs CameraMetadataValue using double. This constructor only sets the double field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="doubleValue">The double value set to the struct.</param> + public CameraMetadataValue(double doubleValue) + { + m_ByteValue = 0; + m_IntValue = 0; + m_LongValue = 0; + m_FloatValue = 0; + m_RationalValue = new CameraMetadataRational(); + + m_Type = NdkCameraMetadataType.Double; + m_DoubleValue = doubleValue; + } + + /// <summary> + /// Constructs CameraMetadataValue using CameraMetadataRational. This constructor only sets the CameraMetadataRational field + /// in the struct, leaving the rest of the data to default value. + /// </summary> + /// <param name="rationalValue">The CameraMetadataRational value set to the struct.</param> + public CameraMetadataValue(CameraMetadataRational rationalValue) + { + m_ByteValue = 0; + m_IntValue = 0; + m_LongValue = 0; + m_FloatValue = 0; + m_DoubleValue = 0; + + m_Type = NdkCameraMetadataType.Rational; + m_RationalValue = rationalValue; + } + + /// <summary> + /// Gets sbyte value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns sbyte value stored in the struct.</returns> + public sbyte AsByte() + { + if (m_Type != NdkCameraMetadataType.Byte) + { + LogError(NdkCameraMetadataType.Byte); + } + + return m_ByteValue; + } + + /// <summary> + /// Gets int value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns int value stored in the struct.</returns> + public int AsInt() + { + if (m_Type != NdkCameraMetadataType.Int32) + { + LogError(NdkCameraMetadataType.Int32); + } + + return m_IntValue; + } + + /// <summary> + /// Gets float value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns float value stored in the struct.</returns> + public float AsFloat() + { + if (m_Type != NdkCameraMetadataType.Float) + { + LogError(NdkCameraMetadataType.Float); + } + + return m_FloatValue; + } + + /// <summary> + /// Gets long value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns long value stored in the struct.</returns> + public long AsLong() + { + if (m_Type != NdkCameraMetadataType.Int64) + { + LogError(NdkCameraMetadataType.Int64); + } + + return m_LongValue; + } + + /// <summary> + /// Gets double value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns double value stored in the struct.</returns> + public double AsDouble() + { + if (m_Type != NdkCameraMetadataType.Double) + { + LogError(NdkCameraMetadataType.Double); + } + + return m_DoubleValue; + } + + /// <summary> + /// Gets CameraMetadataRational value from the struct. This function checks if the querying type matches the internal + /// type field, and logs error if the types do not match. + /// </summary> + /// <returns>Returns CameraMetadataRational value stored in the struct.</returns> + public CameraMetadataRational AsRational() + { + if (m_Type != NdkCameraMetadataType.Rational) + { + LogError(NdkCameraMetadataType.Rational); + } + + return m_RationalValue; + } + + private void LogError(NdkCameraMetadataType requestedType) + { + ARDebug.LogErrorFormat("Error getting value from CameraMetadataType due to type mismatch. " + + "requested type = {0}, internal type = {1}\n" + + "Are you sure you are querying the correct type?", requestedType, m_Type); + } + } + + /// <summary> + /// CameraMetadataRational follows the layout of ACameraMetadata_rational struct in NDK. + /// Please refer to NdkCameraMetadata.h for documentation: + /// https://developer.android.com/ndk/reference/ndk_camera_metadata_8h.html . + /// </summary> + [StructLayout(LayoutKind.Sequential)] + public struct CameraMetadataRational + { + /// <summary> + /// The numerator of the metadata rational. + /// </summary> + public int Numerator; + + /// <summary> + /// The denominator of the metadata rational. + /// </summary> + public int Denominator; + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..282edeff9ee86809dcea367eb2290dd39d913d34 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/CameraMetadataValue.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: e7bf42f9fcf4548e8bfeb90b36d40891 +timeCreated: 1511904539 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor.meta new file mode 100644 index 0000000000000000000000000000000000000000..2aad0c912b9f8ba7e487750b53f232b8d337cf60 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: cfb05be3ca34b4826b62df99f182da2b +folderAsset: yes +timeCreated: 1518226182 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs new file mode 100644 index 0000000000000000000000000000000000000000..d82e27edbaa9a444b2e7fbef5dc90af48f7db2e6 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------- +// <copyright file="ARCoreRequiredMenuItem.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.IO; + using UnityEditor; + using UnityEngine; + + [InitializeOnLoad] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public static class ARCoreRequiredMenuItem + { + private const string k_MenuName = "Edit/Project Settings/ARCore/ARCore Required"; + private const int k_MenuPriority = 901; + + [MenuItem(k_MenuName, false, k_MenuPriority)] + private static void ToggleARCoreRequiredMenuItem() + { + ARCoreProjectSettings.Instance.IsARCoreRequired = !ARCoreProjectSettings.Instance.IsARCoreRequired; + ARCoreProjectSettings.Instance.Save(); + } + + [MenuItem(k_MenuName, true, k_MenuPriority)] + private static bool ValidateARCoreRequiredMenuItem() + { + Menu.SetChecked(k_MenuName, ARCoreProjectSettings.Instance.IsARCoreRequired); + return true; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..eb0f191dcd51873b1f2e2111a0e866fc5c387efd --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/ARCoreRequiredMenuItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 09ecd63d3da8a410a90244cc9a8a049f +timeCreated: 1518228501 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..47c82f3101fe788234f6fdfa6ebffaa8d43e672b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs @@ -0,0 +1,77 @@ +//----------------------------------------------------------------------- +// <copyright file="BuildHelper.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System.Diagnostics.CodeAnalysis; + using UnityEditor; + using UnityEditor.Build; +#if UNITY_2018_1_OR_NEWER + using UnityEditor.Build.Reporting; +#endif + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] +#if UNITY_2018_1_OR_NEWER + public class BuildHelper : IPreprocessBuildWithReport +#else + public class BuildHelper : IPreprocessBuild +#endif + { + [SuppressMessage("UnityRules.UnityStyleRules", "US1000:FieldsMustBeUpperCamelCase", + Justification = "Overriden property.")] + public int callbackOrder + { + get + { + return 0; + } + } + +#if UNITY_2018_1_OR_NEWER + public void OnPreprocessBuild(BuildReport report) + { +#else + public void OnPreprocessBuild(BuildTarget target, string path) + { +#endif + var isARCoreRequired = ARCoreProjectSettings.Instance.IsARCoreRequired; + + Debug.LogFormat("Building application with {0} ARCore support.", + isARCoreRequired ? "REQUIRED" : "OPTIONAL"); + + const string k_RequiredAARPath = "Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar"; + const string k_OptionalAARPath = "Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar"; + PluginImporter arRequiredAAR = AssetImporter.GetAtPath(k_RequiredAARPath) as PluginImporter; + PluginImporter arOptionalAAR = AssetImporter.GetAtPath(k_OptionalAARPath) as PluginImporter; + + if (arRequiredAAR == null || arOptionalAAR == null) + { + throw new UnityEditor.Build.BuildFailedException( + "Not finding google_ar_required.aar and google_ar_optional.aar files needed for ARCore support. " + + "Were they moved from the ARCore SDK?"); + } + + arRequiredAAR.SetCompatibleWithPlatform(BuildTarget.Android, isARCoreRequired); + arOptionalAAR.SetCompatibleWithPlatform(BuildTarget.Android, !isARCoreRequired); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8bc81ad30781c42732c8d1d923151ab7f07fccfd --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Editor/BuildHelper.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 51b018421df5e4defbf0a70c95a5f749 +timeCreated: 1518228237 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs new file mode 100644 index 0000000000000000000000000000000000000000..cbc94c62dcd5072454dafa078ac8ec6b765fd85b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs @@ -0,0 +1,74 @@ +//----------------------------------------------------------------------- +// <copyright file="EnvironmentalLight.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + using UnityEngine.Rendering; + + /// <summary> + /// A component that automatically adjust lighting settings for the scene + /// to be inline with those estimated by ARCore. + /// </summary> + [ExecuteInEditMode] + public class EnvironmentalLight : MonoBehaviour + { + /// <summary> + /// Unity update method that sets global light estimation shader constant to match + /// ARCore's calculated values. + /// </summary> + public void Update() + { +#if UNITY_EDITOR + // Set _GlobalLightEstimation to 1 in editor, if the value is not set, all materials + // using light estimation shaders will be black. + Shader.SetGlobalFloat("_GlobalLightEstimation", 1.0f); +#else + if (Frame.LightEstimate.State != LightEstimateState.Valid) + { + return; + } + + // Use the following function to compute color scale: + // * linear growth from (0.0, 0.0) to (1.0, LinearRampThreshold) + // * slow growth from (1.0, LinearRampThreshold) + const float linearRampThreshold = 0.8f; + const float middleGray = 0.18f; + const float inclination = 0.4f; + + float normalizedIntensity = Frame.LightEstimate.PixelIntensity / middleGray; + float colorScale = 1.0f; + + if (normalizedIntensity < 1.0f) + { + colorScale = normalizedIntensity * linearRampThreshold; + } + else + { + float b = (linearRampThreshold / inclination) - 1.0f; + float a = (b + 1.0f) / b * linearRampThreshold; + colorScale = a * (1.0f - (1.0f / ((b * normalizedIntensity) + 1.0f))); + } + + Shader.SetGlobalFloat("_GlobalLightEstimation", colorScale); +#endif + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a844d198156bbc2e4410b972ef6b9702d8853bfa --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/EnvironmentalLight.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 92a4cf446a0c7334aaceb5457be27894 +timeCreated: 1510799851 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs new file mode 100644 index 0000000000000000000000000000000000000000..c0b77463ca5df32f2ff46fe3fbbd8d8922448abc --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs @@ -0,0 +1,322 @@ +//----------------------------------------------------------------------- +// <copyright file="Frame.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Provides a snapshot of the state of ARCore at a specific timestamp associated with the current frame. Frame + /// holds information about ARCore's state including tracking status, the pose of the camera relative to the world, + /// estimated lighting parameters, and information on updates to objects (like Planes or Point Clouds) that ARCore + /// is tracking. + /// </summary> + public class Frame + { + //// @cond EXCLUDE_FROM_DOXYGEN + + private static List<TrackableHit> s_TmpTrackableHitList = new List<TrackableHit>(); + + //// @endcond + + /// <summary> + /// Gets the pose of the ARCore device for the frame in Unity world coordinates. + /// </summary> + public static Pose Pose + { + get + { + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return Pose.identity; + } + + var cameraHandle = nativeSession.FrameApi.AcquireCamera(); + Pose result = nativeSession.CameraApi.GetPose(cameraHandle); + nativeSession.CameraApi.Release(cameraHandle); + return result; + } + } + + /// <summary> + /// Gets the current light estimate for this frame. + /// </summary> + public static LightEstimate LightEstimate + { + get + { + // TODO (b/73256094): Remove isTracking when fixed. + var nativeSession = LifecycleManager.Instance.NativeSession; + var isTracking = LifecycleManager.Instance.SessionStatus == SessionStatus.Tracking; + if (nativeSession == null || !isTracking) + { + return new LightEstimate(LightEstimateState.NotValid, 0.0f); + } + + return nativeSession.FrameApi.GetLightEstimate(); + } + } + + /// <summary> + /// Performs a raycast against physical objects being tracked by ARCore. + /// Output the closest hit from the camera. + /// Note that the Unity's screen coordinate (0, 0) + /// starts from bottom left. + /// </summary> + /// <param name="x">Horizontal touch position in Unity's screen coordiante.</param> + /// <param name="y">Vertical touch position in Unity's screen coordiante.</param> + /// <param name="filter">A filter bitmask where each {@link TrackableHitFlag} which is set represents a category + /// of raycast hits the method call should consider valid.</param> + /// <param name="hitResult">A {@link TrackableHit} that will be set if the raycast is successful.</param> + /// <returns><c>true</c> if the raycast had a hit, otherwise <c>false</c>.</returns> + public static bool Raycast(float x, float y, TrackableHitFlags filter, + out TrackableHit hitResult) + { + hitResult = new TrackableHit(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return false; + } + + // Note that the Unity's screen coordinate (0, 0) starts from bottom left. + bool foundHit = nativeSession.HitTestApi.Raycast(nativeSession.FrameHandle, x, Screen.height - y, filter, + s_TmpTrackableHitList, true); + + if (foundHit && s_TmpTrackableHitList.Count != 0) + { + hitResult = s_TmpTrackableHitList[0]; + } + + return foundHit; + } + + /// <summary> + /// Performs a raycast against physical objects being tracked by ARCore. + /// Output all hits from the camera. + /// Note that the Unity's screen coordinate (0, 0) + /// starts from bottom left. + /// </summary> + /// <param name="x">Horizontal touch position in Unity's screen coordiante.</param> + /// <param name="y">Vertical touch position in Unity's screen coordiante.</param> + /// <param name="filter">A filter bitmask where each {@link TrackableHitFlag} which is set represents a category + /// of raycast hits the method call should consider valid.</param> + /// <param name="hitResults">A list of {@link TrackableHit} that will be set if the raycast is successful.</param> + /// <returns><c>true</c> if the raycast had a hit, otherwise <c>false</c>.</returns> + public static bool RaycastAll(float x, float y, TrackableHitFlags filter, List<TrackableHit> hitResults) + { + hitResults.Clear(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return false; + } + + return nativeSession.HitTestApi.Raycast(nativeSession.FrameHandle, x, Screen.height - y, filter, hitResults, true); + } + + /// <summary> + /// Container for state related to the ARCore camera image metadata for the Frame. + /// </summary> + public static class CameraMetadata + { + /// <summary> + /// Get camera image metadata value. The querying value type needs to match the returned type. + /// The type could be checked in CameraMetadata.cs. + /// </summary> + /// <param name="metadataTag">Metadata type.</param> + /// <param name="outMetadataList">Result list of the requested values.</param> + /// <returns><c>true</c> if getting metadata value successfully, otherwise <c>false</c>.</returns> + public static bool TryGetValues(CameraMetadataTag metadataTag, List<CameraMetadataValue> outMetadataList) + { + outMetadataList.Clear(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return false; + } + + var metadataHandle = nativeSession.FrameApi.AcquireImageMetadata(); + var isSuccess = nativeSession.CameraMetadataApi.TryGetValues(metadataHandle, metadataTag, outMetadataList); + nativeSession.CameraMetadataApi.Release(metadataHandle); + return isSuccess; + } + + /// <summary> + /// Get all available tags in the current frame's metadata. + /// </summary> + /// <param name="outMetadataTags">Result list of the tags.</param> + /// <returns><c>true</c> if getting tags successfully, otherwise <c>false</c>.</returns> + public static bool GetAllCameraMetadataTags(List<CameraMetadataTag> outMetadataTags) + { + outMetadataTags.Clear(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return false; + } + + var metadataHandle = nativeSession.FrameApi.AcquireImageMetadata(); + var isSuccess = nativeSession.CameraMetadataApi.GetAllCameraMetadataTags(metadataHandle, + outMetadataTags); + nativeSession.CameraMetadataApi.Release(metadataHandle); + return isSuccess; + } + } + + /// <summary> + /// Container for state related to the ARCore point cloud for the Frame. + /// </summary> + public static class PointCloud + { + /// <summary> + /// Gets a value indicating whether new point cloud data became available in the current frame. + /// </summary> + /// <returns><c>true</c> if new point cloud data became available in the current frame, otherwise + /// <c>false</c>.</returns> + public static bool IsUpdatedThisFrame + { + get + { + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return false; + } + + return nativeSession.IsPointCloudNew; + } + } + + /// <summary> + /// Gets the count of point cloud points in the frame. + /// </summary> + public static int PointCount + { + get + { + // TODO (b/73256094): Remove isTracking when fixed. + var nativeSession = LifecycleManager.Instance.NativeSession; + var isTracking = LifecycleManager.Instance.SessionStatus == SessionStatus.Tracking; + if (nativeSession == null || !isTracking) + { + return 0; + } + + return nativeSession.PointCloudApi.GetNumberOfPoints(nativeSession.PointCloudHandle); + } + } + + /// <summary> + /// Gets a point from the point cloud collection at an index. + /// </summary> + /// <param name="index">The index of the point cloud point to get.</param> + /// <returns>The point from the point cloud at <c>index</c>.</returns> + public static Vector3 GetPoint(int index) + { + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return Vector3.zero; + } + + return nativeSession.PointCloudApi.GetPoint(nativeSession.PointCloudHandle, index); + } + + /// <summary> + /// Copies the point cloud for a frame into a supplied list reference. + /// </summary> + /// <param name="points">A list that will be filled with point cloud points by this method call.</param> + public static void CopyPoints(List<Vector4> points) + { + points.Clear(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return; + } + + nativeSession.PointCloudApi.CopyPoints(nativeSession.PointCloudHandle, points); + } + } + + /// <summary> + /// Container for state related to the ARCore camera for the frame. + /// </summary> + public static class CameraImage + { + /// <summary> + /// Gets a texture used from the device's rear camera. + /// </summary> + public static Texture Texture + { + get + { + return LifecycleManager.Instance.BackgroundTexture; + } + } + + /// <summary> + /// Gets a ApiDisplayUvCoords to properly display the camera texture. + /// </summary> + public static ApiDisplayUvCoords DisplayUvCoords + { + get + { + ApiDisplayUvCoords displayUvCoords = new ApiDisplayUvCoords(new Vector2(0, 1), + new Vector2(1, 1), new Vector2(0, 0), new Vector2(1, 0)); + + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null || Texture == null) + { + return displayUvCoords; + } + + nativeSession.FrameApi.TransformDisplayUvCoords(ref displayUvCoords); + return displayUvCoords; + } + } + + /// <summary> + /// Gets the projection matrix for the frame. + /// </summary> + /// <param name="nearClipping">The near clipping plane for the projection matrix.</param> + /// <param name="farClipping">The far clipping plane for the projection matrix.</param> + /// <returns>The projection matrix for the frame.</returns> + public static Matrix4x4 GetCameraProjectionMatrix(float nearClipping, float farClipping) + { + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null || Texture == null) + { + return Matrix4x4.identity; + } + + var cameraHandle = nativeSession.FrameApi.AcquireCamera(); + var result = nativeSession.CameraApi.GetProjectionMatrix(cameraHandle, nearClipping, farClipping); + nativeSession.CameraApi.Release(cameraHandle); + return result; + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5921558ef57ff61172050845a5080d125356b5ed --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Frame.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f23179d83fac54b6898d7f842a3ecf83 +timeCreated: 1503161028 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs new file mode 100644 index 0000000000000000000000000000000000000000..e4be3aa60d6ab6955ec17fdc23d44102d1254807 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------- +// <copyright file="LightEstimate.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + + /// <summary> + /// An estimate of lighting conditions in the environment corresponding to + /// an AR frame. + /// </summary> + public struct LightEstimate + { + /// <summary> + /// Constructor for a LightEstimate. + /// </summary> + /// <param name="state">State of the estimate.</param> + /// <param name="pixelIntensity">Average pixel intensity. Values range from 0.0 + /// to 1.0, where 0.0 represents black and 1.0 represents white.</param> + public LightEstimate(LightEstimateState state, float pixelIntensity) + { + State = state; + PixelIntensity = pixelIntensity; + } + + /// <summary> + /// Gets the state of the current estimate. + /// </summary> + public LightEstimateState State { get; private set; } + + /// <summary> + /// Gets an average pixel intensity. Values range from 0.0 to 1.0, where 0.0 + /// represents black and 1.0 represents white. + /// </summary> + public float PixelIntensity { get; private set; } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d70fb42508aacb9ebdd37cf7726869d145b45202 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimate.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fda591ded80f4d6489368b5527603e86 +timeCreated: 1502160887 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs new file mode 100644 index 0000000000000000000000000000000000000000..1707c6f0d09b8e0e00859574406c039a61be9754 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs @@ -0,0 +1,38 @@ +//----------------------------------------------------------------------- +// <copyright file="LightEstimateState.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// Possible states for <see cref="LightEstimate"/>. + /// </summary> + public enum LightEstimateState + { + /// <summary> + /// Estimate is not valid and should not be used. + /// </summary> + NotValid, + + /// <summary> + /// Estimate is valid. + /// </summary> + Valid, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..fe600dea8ab43b38ebb746d92103b8332602db95 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/LightEstimateState.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4f3ad9d6ff6f214438ef1a961ef9b921 +timeCreated: 1510799673 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers.meta new file mode 100644 index 0000000000000000000000000000000000000000..fd4ba917939835d1d85bb5519584f22f821c2db8 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0e71c3224f80341e8bce7e10bfca6462 +folderAsset: yes +timeCreated: 1510945633 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..27daf42d2b10dfb548018396a5cfbf1446ca8238 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs @@ -0,0 +1,361 @@ +//----------------------------------------------------------------------- +// <copyright file="LifecycleManager.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class LifecycleManager + { + private static LifecycleManager s_Instance = new LifecycleManager(); + + private CheckApkAvailabilityResultCallback m_CheckApkAvailabilityResultCallback; + + private RequestApkInstallationResultCallback m_RequestApkInstallationResultCallback; + + private CameraPermissionRequestProvider m_RequestCameraPermissionCallback; + + private EarlyUpdateCallback m_EarlyUpdateCallback; + + private Texture2D m_BackgroundTexture; + + private ARCoreSession m_SessionComponent; + + private NativeSession m_NativeSession; + + private List<Action<ApkAvailabilityStatus>> m_PendingAvailabilityCheckCallbacks = + new List<Action<ApkAvailabilityStatus>>(); + + private List<Action<ApkInstallationStatus>> m_PendingInstallationRequestCallbacks = + new List<Action<ApkInstallationStatus>>(); + + static LifecycleManager() + { + Instance._Initialize(); + } + + private delegate void CheckApkAvailabilityResultCallback(ApiAvailability status, + IntPtr context); + + private delegate void RequestApkInstallationResultCallback( + ApiApkInstallationStatus status, IntPtr context); + + private delegate void CameraPermissionsResultCallback(bool granted, + IntPtr context); + + private delegate void CameraPermissionRequestProvider( + CameraPermissionsResultCallback onComplete, IntPtr context); + + private delegate void SessionCreationResultCallback( + IntPtr sessionHandle, IntPtr frameHandle, IntPtr context, ApiArStatus status); + + private delegate void EarlyUpdateCallback(); + + public static LifecycleManager Instance + { + get + { + return s_Instance; + } + } + + public Texture2D BackgroundTexture + { + get + { + return m_BackgroundTexture; + } + } + + public NativeSession NativeSession + { + get + { + if (m_NativeSession != null) + { + return m_NativeSession; + } + + IntPtr sessionHandle = IntPtr.Zero; + ExternApi.ArPresto_getSession(ref sessionHandle); + + IntPtr frameHandle = IntPtr.Zero; + ExternApi.ArPresto_getFrame(ref frameHandle); + + if (sessionHandle == IntPtr.Zero || frameHandle == IntPtr.Zero) + { + return null; + } + + m_NativeSession = new NativeSession(sessionHandle, frameHandle); + return m_NativeSession; + } + } + + public SessionStatus SessionStatus + { + get + { + ApiPrestoStatus prestoStatus = ApiPrestoStatus.Uninitialized; + ExternApi.ArPresto_getStatus(ref prestoStatus); + return prestoStatus.ToSessionStatus(); + } + } + + public void CreateSession(ARCoreSession session) + { + session.StartCoroutine(InstantPreviewManager.InitializeIfNeeded()); + + if (m_SessionComponent != null) + { + Debug.LogError("Multiple session components cannot exist in the scene. " + + "Destroying the newest."); + GameObject.Destroy(session); + return; + } + + m_SessionComponent = session; + } + + public void EnableSession() + { + var config = m_SessionComponent.SessionConfig; + if (config != null) + { + ExternApi.ArPresto_setConfiguration(new ApiPrestoConfig(config)); + } + + ExternApi.ArPresto_setEnabled(true); + } + + public void DisableSession() + { + ExternApi.ArPresto_setEnabled(false); + } + + public void DestroySession() + { + m_SessionComponent = null; + } + + public AsyncTask<ApkAvailabilityStatus> CheckApkAvailability() + { + Action<ApkAvailabilityStatus> onComplete; + AsyncTask<ApkAvailabilityStatus> task = + new AsyncTask<ApkAvailabilityStatus>(out onComplete); + + ExternApi.ArPresto_checkApkAvailability(m_CheckApkAvailabilityResultCallback, + IntPtr.Zero); + + m_PendingAvailabilityCheckCallbacks.Add(onComplete); + + return task; + } + + public AsyncTask<ApkInstallationStatus> RequestApkInstallation(bool userRequested) + { + Action<ApkInstallationStatus> onComplete; + AsyncTask<ApkInstallationStatus> task = + new AsyncTask<ApkInstallationStatus>(out onComplete); + + ExternApi.ArPresto_requestApkInstallation(userRequested, + m_RequestApkInstallationResultCallback, IntPtr.Zero); + + m_PendingInstallationRequestCallbacks.Add(onComplete); + + return task; + } + + [AOT.MonoPInvokeCallback(typeof(CheckApkAvailabilityResultCallback))] + private static void OnCheckApkAvailabilityResultTrampoline( + ApiAvailability status, IntPtr context) + { + Instance._OnCheckApkAvailabilityResult(status.ToApkAvailabilityStatus()); + } + + [AOT.MonoPInvokeCallback(typeof(RequestApkInstallationResultCallback))] + private static void OnApkInstallationResultTrampoline( + ApiApkInstallationStatus status, IntPtr context) + { + Instance._OnRequestApkInstallationResult(status.ToApkInstallationStatus()); + } + + [AOT.MonoPInvokeCallback(typeof(CameraPermissionRequestProvider))] + private static void RequestCameraPermissionTrampoline( + CameraPermissionsResultCallback onComplete, IntPtr context) + { + Instance._RequestCameraPermission(onComplete, context); + } + + [AOT.MonoPInvokeCallback(typeof(EarlyUpdateCallback))] + private static void EarlyUpdateTrampoline() + { + Instance._EarlyUpdate(); + } + + private void _Initialize() + { + m_EarlyUpdateCallback = new EarlyUpdateCallback(EarlyUpdateTrampoline); + ExternApi.ArCoreUnity_setArPrestoInitialized(m_EarlyUpdateCallback); + + IntPtr javaVMHandle = IntPtr.Zero; + IntPtr activityHandle = IntPtr.Zero; + ExternApi.ArCoreUnity_getJniInfo(ref javaVMHandle, ref activityHandle); + + m_CheckApkAvailabilityResultCallback = + new CheckApkAvailabilityResultCallback(OnCheckApkAvailabilityResultTrampoline); + + m_RequestApkInstallationResultCallback = + new RequestApkInstallationResultCallback(OnApkInstallationResultTrampoline); + + m_RequestCameraPermissionCallback = + new CameraPermissionRequestProvider(RequestCameraPermissionTrampoline); + + ExternApi.ArPresto_initialize(javaVMHandle, activityHandle, + m_RequestCameraPermissionCallback); + } + + private void _RequestCameraPermission(CameraPermissionsResultCallback onComplete, + IntPtr context) + { + const string cameraPermissionName = "android.permission.CAMERA"; + AndroidPermissionsManager.RequestPermission(cameraPermissionName).ThenAction((grantResult) => + { + onComplete(grantResult.IsAllGranted, context); + }); + } + + private void _EarlyUpdate() + { + AsyncTask.OnUpdate(); + _UpdateTextureIfNeeded(); + + if (m_NativeSession != null) + { + m_NativeSession.SessionApi.SetDisplayGeometry( + Screen.orientation, Screen.width, Screen.height); + m_NativeSession.OnUpdate(); + } + } + + private void _OnCheckApkAvailabilityResult(ApkAvailabilityStatus status) + { + foreach (var onComplete in m_PendingAvailabilityCheckCallbacks) + { + onComplete(status); + } + + m_PendingAvailabilityCheckCallbacks.Clear(); + } + + private void _OnRequestApkInstallationResult(ApkInstallationStatus status) + { + foreach (var onComplete in m_PendingInstallationRequestCallbacks) + { + onComplete(status); + } + + m_PendingInstallationRequestCallbacks.Clear(); + } + + private void _UpdateTextureIfNeeded() + { + // If running in editor, updates background texture from Instant Preview only. + if (InstantPreviewManager.UpdateBackgroundTextureIfNeeded(ref m_BackgroundTexture)) + { + return; + } + + int backgroundTextureId = ExternApi.ArCoreUnity_getBackgroundTextureId(); + + if (NativeSession == null) + { + // This prevents using a texture that has not been filled out by ARCore. + return; + } + else if (backgroundTextureId == -1) + { + return; + } + else if (m_BackgroundTexture != null && + m_BackgroundTexture.GetNativeTexturePtr().ToInt32() == backgroundTextureId) + { + return; + } + else if (m_BackgroundTexture == null) + { + // The Unity-cached size and format of the texture (0x0, ARGB) is not the + // actual format of the texture. This is okay because the texture is not + // accessed by pixels, it is accessed with UV coordinates. + m_BackgroundTexture = Texture2D.CreateExternalTexture(0, 0, TextureFormat.ARGB32, false, + false, new IntPtr(backgroundTextureId)); + return; + } + + m_BackgroundTexture.UpdateExternalTexture(new IntPtr(backgroundTextureId)); + } + + private struct ExternApi + { + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArCoreUnity_getJniInfo(ref IntPtr javaVM, ref IntPtr activity); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArCoreUnity_setArPrestoInitialized(EarlyUpdateCallback onEarlyUpdate); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern int ArCoreUnity_getBackgroundTextureId(); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_initialize(IntPtr javaVM, IntPtr activity, + CameraPermissionRequestProvider requestCameraPermission); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_checkApkAvailability( + CheckApkAvailabilityResultCallback onResult, IntPtr context); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_requestApkInstallation(bool user_requested, + RequestApkInstallationResultCallback onResult, IntPtr context); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_getSession(ref IntPtr sessionHandle); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_setConfiguration(ApiPrestoConfig config); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_setEnabled(bool isEnabled); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_getFrame(ref IntPtr frameHandle); + + [DllImport(ApiConstants.ARCoreShimApi)] + public static extern void ArPresto_getStatus(ref ApiPrestoStatus prestoStatus); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..47689ce8e033c9ebd035fd15ca9bc2c1fdb00b74 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 864c8242be03c4aec8427b8a2286c601 +timeCreated: 1517519681 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..0484e0925de68324ba2eaffe08ade273dfd85b6a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableManager.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class TrackableManager + { + private Dictionary<IntPtr, Trackable> m_TrackableDict = + new Dictionary<IntPtr, Trackable>(new IntPtrEqualityComparer()); + + private NativeSession m_NativeSession; + + private int m_LastUpdateFrame = -1; + + private List<Trackable> m_NewTrackables = new List<Trackable>(); + + private List<Trackable> m_AllTrackables = new List<Trackable>(); + + private List<Trackable> m_UpdatedTrackables = new List<Trackable>(); + + private HashSet<Trackable> m_OldTrackables = new HashSet<Trackable>(); + + public TrackableManager(NativeSession nativeSession) + { + m_NativeSession = nativeSession; + } + + /// <summary> + /// Factory method for creating and reusing TrackedPlane references from native handles. + /// </summary> + /// <param name="nativeHandle">A native handle to a plane that has been acquired. RELEASE WILL BE HANDLED BY + /// THIS METHOD.</param> + /// <returns>A reference to a tracked plane. </returns> + public Trackable TrackableFactory(IntPtr nativeHandle) + { + if (nativeHandle == IntPtr.Zero) + { + return null; + } + + Trackable result; + if (m_TrackableDict.TryGetValue(nativeHandle, out result)) + { + // Release aquired handle and return cached result. + m_NativeSession.TrackableApi.Release(nativeHandle); + return result; + } + + ApiTrackableType trackableType = m_NativeSession.TrackableApi.GetType(nativeHandle); + if (trackableType == ApiTrackableType.Plane) + { + result = new TrackedPlane(nativeHandle, m_NativeSession); + } + else if (trackableType == ApiTrackableType.Point) + { + result = new TrackedPoint(nativeHandle, m_NativeSession); + } + else + { + UnityEngine.Debug.LogFormat("Cant find {0}", trackableType); + throw new NotImplementedException("TrackableFactory:: No constructor for requested trackable type."); + } + + m_TrackableDict.Add(nativeHandle, result); + return result; + } + + public void GetTrackables<T>(List<T> trackables, TrackableQueryFilter filter) where T : Trackable + { + if (m_LastUpdateFrame < Time.frameCount) + { + // Get trackables updated this frame. + m_NativeSession.FrameApi.GetUpdatedTrackables(m_UpdatedTrackables); + + // Get all the trackables in the session. + m_NativeSession.SessionApi.GetAllTrackables(m_AllTrackables); + + // Find trackables that are not in the hashset (new). + m_NewTrackables.Clear(); + for (int i = 0; i < m_AllTrackables.Count; i++) + { + Trackable trackable = m_AllTrackables[i]; + if (!m_OldTrackables.Contains(trackable)) + { + m_NewTrackables.Add(trackable); + m_OldTrackables.Add(trackable); + } + } + + m_LastUpdateFrame = Time.frameCount; + } + + trackables.Clear(); + + if (filter == TrackableQueryFilter.All) + { + for (int i = 0; i < m_AllTrackables.Count; i++) + { + _SafeAdd<T>(m_AllTrackables[i], trackables); + } + } + else if (filter == TrackableQueryFilter.New) + { + for (int i = 0; i < m_NewTrackables.Count; i++) + { + _SafeAdd<T>(m_NewTrackables[i], trackables); + } + } + else if (filter == TrackableQueryFilter.Updated) + { + for (int i = 0; i < m_NewTrackables.Count; i++) + { + _SafeAdd<T>(m_UpdatedTrackables[i], trackables); + } + } + } + + private void _SafeAdd<T>(Trackable trackable, List<T> trackables) where T : Trackable + { + if (trackable is T) + { + trackables.Add(trackable as T); + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..0bcf08ffde9570d6bba0b44562efb53fec97ed0b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Managers/TrackableManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 27167ddd916ef43bbaacd5878c2ae213 +timeCreated: 1510945633 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs new file mode 100644 index 0000000000000000000000000000000000000000..e8959a65303f69f88eb5a9ed9e315309c424d8ef --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------- +// <copyright file="PointCloudPoint.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + + /// <summary> + /// A point in a point cloud. + /// </summary> + public struct PointCloudPoint + { + /// <summary> + /// The x-position of the point. + /// </summary> + public float X; + + /// <summary> + /// The y-position of the point. + /// </summary> + public float Y; + + /// <summary> + /// The z-position of the point. + /// </summary> + public float Z; + + /// <summary> + /// A normalized confidence value for the point. + /// </summary> + public float Confidence; + + /// <summary> + /// Constructs a new PointCloudPoint. + /// </summary> + /// <param name="x">The x-position of the point.</param> + /// <param name="y">The y-position of the point.</param> + /// <param name="z">The z-position of the point.</param> + /// <param name="confidence">The confidence of the point.</param> + public PointCloudPoint(float x, float y, float z, float confidence) + { + this.X = x; + this.Y = y; + this.Z = z; + this.Confidence = confidence; + } + + /// <summary> + /// Implicitly converts a PointCloudPoint to a Vector4. + /// </summary> + /// <param name="point">The point to convert.</param> + public static implicit operator Vector4(PointCloudPoint point) + { + return new Vector4(point.X, point.Y, point.Z, point.Confidence); + } + + /// <summary> + /// Implicitly converts a Vector4 to a PointCloudPoint. + /// </summary> + /// <param name="vectorPoint">The Vector3 to convert.</param> + public static implicit operator PointCloudPoint(Vector4 vectorPoint) + { + return new PointCloudPoint(vectorPoint.x, vectorPoint.y, vectorPoint.z, vectorPoint.w); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8855f91e861471b78f64f0cd3f0eee5744666e3d --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/PointCloudPoint.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f24ed3047ed4646bfab6a8a530dc432c +timeCreated: 1510947955 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs new file mode 100644 index 0000000000000000000000000000000000000000..0cb911cd0e6fb3c72e89e8006348ce3c60febdd9 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs @@ -0,0 +1,112 @@ +//----------------------------------------------------------------------- +// <copyright file="Session.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// Represents an ARCore session, which is an attachment point from the app + /// to the ARCore service. Holds information about the global state for + /// ARCore, manages tracking of Anchors and Planes, and performs hit tests + /// against objects ARCore is tracking in the world. + /// </summary> + public static class Session + { + /// <summary> + /// Gets current session status. + /// </summary> + public static SessionStatus Status + { + get + { + return LifecycleManager.Instance.SessionStatus; + } + } + + /// <summary> + /// Creates a new Anchor at the given <c>Pose</c> that is attached to the <c>Trackable</c>. + /// If trackable is null, it creates a new anchor at a world pose. + /// As ARCore updates its understading of the space, it will update the + /// virtual pose of the of the anchor to attempt to keep the anchor in the same real world location. + /// </summary> + /// <param name="pose">The Unity world pose where the anchor is to be creates.</param> + /// <param name="trackable">The Trackable to attach the Anchor to.</param> + /// <returns>The newly created anchor or null.</returns> + public static Anchor CreateAnchor(Pose pose, Trackable trackable = null) + { + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return null; + } + + if (trackable == null) + { + return nativeSession.SessionApi.CreateAnchor(pose); + } + else + { + return trackable.CreateAnchor(pose); + } + } + + /// <summary> + /// Gets Trackables ARCore has tracked. + /// </summary> + /// <typeparam name="T">The Trackable type to get.</typeparam> + /// <param name="trackables">A reference to a list of T that will be filled by the method call.</param> + /// <param name="filter">A filter on the type of data to return.</param> + public static void GetTrackables<T>(List<T> trackables, TrackableQueryFilter filter = TrackableQueryFilter.All) where T : Trackable + { + trackables.Clear(); + var nativeSession = LifecycleManager.Instance.NativeSession; + if (nativeSession == null) + { + return; + } + + nativeSession.GetTrackables<T>(trackables, filter); + } + + /// <summary> + /// Checks the availability of the ARCore APK on the device. + /// </summary> + /// <returns>An AsyncTask that completes with an ApkAvailabilityStatus when the availability is known.</returns> + public static AsyncTask<ApkAvailabilityStatus> CheckApkAvailability() + { + return LifecycleManager.Instance.CheckApkAvailability(); + } + + /// <summary> + /// Requests an installation of the ARCore APK on the device. + /// </summary> + /// <param name="userRequested">Whether the installation was requested explicity by a user action.</param> + /// <returns>An AsyncTask that completes with an ApkInstallationStatus when the installation + /// status is resolved.</returns> + public static AsyncTask<ApkInstallationStatus> RequestApkInstallation(bool userRequested) + { + return LifecycleManager.Instance.RequestApkInstallation(userRequested); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d1b01983d85edb70da2c610e1b03bcc7e21325f8 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Session.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 37d4175d892ef4e6190e38f26d22434c +timeCreated: 1502156672 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs new file mode 100644 index 0000000000000000000000000000000000000000..6de73ac2c909f1ccbdc36351a29ab2008a37cd22 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs @@ -0,0 +1,74 @@ +//----------------------------------------------------------------------- +// <copyright file="SessionStatus.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// Possible states for the ARCore session. + /// </summary> + public enum SessionStatus + { + /// <summary> + /// The ARCore session has not been initialized. + /// </summary> + None = 0, + + /// <summary> + /// The ARCore session is initializing. + /// </summary> + Initializing = 1, + + /// <summary> + /// The ARCore session is tracking. + /// </summary> + Tracking = 100, + + /// <summary> + /// The ARCore session has lost tracking and is attempting to recover. + /// </summary> + LostTracking = 101, + + /// <summary> + /// The ARCore session is paused. + /// </summary> + NotTracking = 102, + + /// <summary> + /// An ARCore session cannot begin tracking because a fatal error was encountered. + /// </summary> + FatalError = 200, + + /// <summary> + /// An ARCore session cannot begin tracking because the ARCore service APK is not available on the device. + /// </summary> + ErrorApkNotAvailable = 201, + + /// <summary> + /// An ARCore session cannot begin tracking because the Android camera permission is not granted. + /// </summary> + ErrorPermissionNotGranted = 202, + + /// <summary> + /// An ARCore session cannot begin tracking because the session configuration supplied is not supported or no + /// session configuration was supplied. + /// </summary> + ErrorSessionConfigurationNotSupported = 203, + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..40427c87df588f96a8ecbf55bfcd02c94865b3ec --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatus.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 30a41262cba2646c98f6d3cf4e46fb2a +timeCreated: 1516741153 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..6a085132863795fd2204f518ca01d78ad4055a71 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------- +// <copyright file="SessionStatusExtensions.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + + /// <summary> + /// Extension methods for the SessionStatus enumeration. + /// </summary> + public static class SessionStatusExtensions + { + private const int k_NotInitializedGroupStart = 0; + private const int k_ValidSessionGroupStart = 100; + private const int k_ErrorGroupStart = 200; + + /// <summary> + /// Gets whether a SessionStatus is not yet initialized. + /// </summary> + /// <param name="status">The SessionStatus to check.</param> + /// <returns><c>true</c> if the SessionStatus is not initialized, otherwise <c>false</c>.</returns> + public static bool IsNotInitialized(this SessionStatus status) + { + int normalizedValue = (int)status - k_NotInitializedGroupStart; + return normalizedValue >= 0 && normalizedValue < 100; + } + + /// <summary> + /// Gets whether a SessionStatus is initialized and valid. + /// </summary> + /// <param name="status">The SessionStatus to check.</param> + /// <returns><c>true</c> if the SessionStatus is initialized and valid, + /// otherwise <c>false</c>.</returns> + public static bool IsValid(this SessionStatus status) + { + int normalizedValue = (int)status - k_ValidSessionGroupStart; + return normalizedValue >= 0 && normalizedValue < 100; + } + + /// <summary> + /// Gets whether a SessionStatus is an error. + /// </summary> + /// <param name="status">The SessionStatus to check.</param> + /// <returns><c>true</c> if the SessionStatus is an error, + /// otherwise <c>false</c>.</returns> + public static bool IsError(this SessionStatus status) + { + int normalizedValue = (int)status - k_ErrorGroupStart; + return normalizedValue >= 0 && normalizedValue < 100; + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5e626eed243fb7d691a9bbd8500a61fefa0585c7 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/SessionStatusExtensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b8d6e0fc3b3bc44218e96690668c05b4 +timeCreated: 1517519681 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs new file mode 100644 index 0000000000000000000000000000000000000000..e6da5d78030b79923017c6b80651a4fb5c272dad --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------- +// <copyright file="Trackable.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// An object ARCore is tracking in the real world. + /// </summary> + public abstract class Trackable + { + //// @cond EXCLUDE_FROM_DOXYGEN + + /// <summary> + /// A native handle for the ARCore trackable. + /// </summary> + protected IntPtr m_TrackableNativeHandle = IntPtr.Zero; + + /// <summary> + /// The native api for ARCore. + /// </summary> + protected NativeSession m_NativeSession; + + /// <summary> + /// Constructs a new ARCore Trackable. + /// </summary> + protected Trackable() + { + } + + /// <summary> + /// Constructs a new ARCore Trackable. + /// </summary> + /// <param name="trackableNativeHandle">The native handle.</param> + /// <param name="nativeSession">The native session.</param> + protected Trackable(IntPtr trackableNativeHandle, NativeSession nativeSession) + { + m_TrackableNativeHandle = trackableNativeHandle; + m_NativeSession = nativeSession; + } + + ~Trackable() + { + m_NativeSession.TrackableApi.Release(m_TrackableNativeHandle); + } + + //// @endcond + + /// <summary> + /// Gets the tracking state of for the Trackable in the current frame. + /// </summary> + /// <returns>The tracking state of for the Trackable in the current frame.</returns> + public virtual TrackingState TrackingState + { + get + { + // TODO (b/73256094): Remove isTracking when fixed. + var nativeSession = LifecycleManager.Instance.NativeSession; + var isTracking = LifecycleManager.Instance.SessionStatus == SessionStatus.Tracking; + if (nativeSession != m_NativeSession) + { + // Trackables from another session are considered stopped. + return TrackingState.Stopped; + } + else if (!isTracking) + { + // If there are no new frames coming in we must manually return paused. + return TrackingState.Paused; + } + + return m_NativeSession.TrackableApi.GetTrackingState(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Creates an Anchor at the given <c>Pose</c> that is attached to the Trackable where semantics of the + /// attachment relationship are defined by the subcass of Trackable (e.g. TrackedPlane). Note that the + /// relative offset between the Pose of multiple Anchors attached to the same Trackable may change + /// over time as ARCore refines its understanding of the world. + /// </summary> + /// <param name="pose">The Pose of the location to create the anchor.</param> + /// <returns>An Anchor attached to the Trackable at <c>Pose</c>.</returns> + public virtual Anchor CreateAnchor(Pose pose) + { + IntPtr anchorHandle; + if (!m_NativeSession.TrackableApi.AcquireNewAnchor(m_TrackableNativeHandle, pose, out anchorHandle)) + { + Debug.Log("Failed to create anchor on trackable."); + return null; + } + + return Anchor.AnchorFactory(anchorHandle, m_NativeSession); + } + + /// <summary> + /// Gets all anchors attached to the Trackable. + /// </summary> + /// <param name="anchors">A list of anchors to be filled by the method.</param> + public virtual void GetAllAnchors(List<Anchor> anchors) + { + m_NativeSession.TrackableApi.GetAnchors(m_TrackableNativeHandle, anchors); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..b545d65a759c474bc67c148b312a84fdbcf2ac97 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Trackable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: df152580aca434d62a87d4dfefe9ca93 +timeCreated: 1508869129 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs new file mode 100644 index 0000000000000000000000000000000000000000..6033a99cfb32e51bbc7394a3d3d098d747249f80 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableHit.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using UnityEngine; + + /// <summary> + /// Contains information about a raycast hit against a physical object tracked by ARCore. + /// </summary> + public struct TrackableHit + { + //// @cond EXCLUDE_FROM_DOXYGEN + + /// <summary> + /// Constructs a TrackableHit. + /// </summary> + /// <param name="pose">Hit's pose.</param> + /// <param name="distance">Hit's distance from the origin of the ray to the hit.</param> + /// <param name="flags">Type of the hit.</param> + /// <param name="trackable">Trackable object of the hit.</param> + public TrackableHit(Pose pose, float distance, TrackableHitFlags flags, Trackable trackable) + { + Pose = pose; + Distance = distance; + Flags = flags; + Trackable = trackable; + } + + //// @endcond + + /// <summary> + /// Gets the pose where the raycast hit the object in Unity world coordinates. + /// </summary> + public Pose Pose { get; private set; } + + /// <summary> + /// Gets the distance from the origin of the ray to the hit. + /// </summary> + public float Distance { get; private set; } + + /// <summary> + /// Gets a bitmask where set TrackableHitFlag flags correspond to categories of objects + /// the hit belongs to. + /// </summary> + public TrackableHitFlags Flags { get; private set; } + + /// <summary> + /// Gets the hit's trackable object. + /// </summary> + public Trackable Trackable { get; private set; } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..ba3ce6fe98b18dcfe8f9ac4074e144900a8a4943 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHit.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f69a232195c4d4a699cc8501f6ee7649 +timeCreated: 1502302494 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs new file mode 100644 index 0000000000000000000000000000000000000000..8827d6e9e1eacc014df556bb6c603897c87f574f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableHitFlags.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using UnityEngine; + + /// <summary> + /// Flags representing categories of raycast hits. + /// </summary> + [Flags] + public enum TrackableHitFlags + { + /// <summary> + /// This value is returned on a TrackableHit to indicate no collision occurred. + /// + /// If you pass this into Raycast, you will not get any collision results. + /// </summary> + None = 0, + + /// <summary> + /// The collision is within the the TrackedPlane's convex bounding polygon. + /// </summary> + PlaneWithinPolygon = 1 << 0, + + /// <summary> + /// The collision is within the TrackedPlane's bounding box. + /// </summary> + PlaneWithinBounds = 1 << 1, + + /// <summary> + /// The collision is on the TrackedPlane, but not limited to the bounding box or polygon. + /// This acts as if the plane extends out to infinity. + /// </summary> + PlaneWithinInfinity = 1 << 2, + + /// <summary> + /// The collision is on a feature point in the current frame's point cloud. + /// </summary> + FeaturePoint = 1 << 3, + + /// <summary> + /// The collision is on a feature point in the current frame's point cloud + /// that has a surface normal estimate (orientation). + /// </summary> + FeaturePointWithSurfaceNormal = 1 << 4, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..449b096f9538d53d5d05ae2290497df28641a220 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableHitFlags.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a541164e523764394a27cc3803637e58 +timeCreated: 1502302494 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs new file mode 100644 index 0000000000000000000000000000000000000000..4b5fe7bf3eca69029adbad74dab0948fd6ca20da --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackableQueryFilter.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// A filter for trackable queries. + /// </summary> + public enum TrackableQueryFilter + { + /// <summary> + /// Indicates available trackables. + /// </summary> + All, + + /// <summary> + /// Indicates new trackables detected in the current ARCore Frame. + /// </summary> + New, + + /// <summary> + /// Indicates trackables that were updated in the current ARCore Frame. + /// </summary> + Updated, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..7d2ff60e3231e3ad07e7a6df014c44be2b6c3e77 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackableQueryFilter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 21d75659f8470494cbefd71c8b7f25bd +timeCreated: 1510770155 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs new file mode 100644 index 0000000000000000000000000000000000000000..5d7ee6e481cb5b8701261e94ed478ac73d8b2220 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackedPlane.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// A planar surface in the real world detected and tracked by ARCore. + /// </summary> + public class TrackedPlane : Trackable + { + //// @cond EXCLUDE_FROM_DOXYGEN + + /// <summary> + /// Construct TrackedPlane from a native handle. + /// </summary> + /// <param name="nativeHandle">A handle to the native ARCore API Trackable.</param> + /// <param name="nativeApi">The ARCore native api.</param> + public TrackedPlane(IntPtr nativeHandle, NativeSession nativeApi) + : base(nativeHandle, nativeApi) + { + m_TrackableNativeHandle = nativeHandle; + m_NativeSession = nativeApi; + } + + //// @endcond + + /// <summary> + /// Gets a reference to the plane subsuming this plane, if any. If not null, only the subsuming plane should be + /// considered valid for rendering. + /// </summary> + public TrackedPlane SubsumedBy + { + get + { + return m_NativeSession.PlaneApi.GetSubsumedBy(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Gets the position and orientation of the plane's center. + /// </summary> + public Pose CenterPose + { + get + { + return m_NativeSession.PlaneApi.GetCenterPose(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Gets the extent of the plane in the X dimension, centered on the plane position. + /// </summary> + public float ExtentX + { + get + { + return m_NativeSession.PlaneApi.GetExtentX(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Gets the extent of the plane in the Z dimension, centered on the plane position. + /// </summary> + public float ExtentZ + { + get + { + return m_NativeSession.PlaneApi.GetExtentZ(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Gets a list of points (in clockwise order) in Unity world space representing a boundary polygon for + /// the plane. + /// </summary> + /// <param name="boundaryPolygonPoints">A list of <b>Vector3</b> to be filled by the method call.</param> + public void GetBoundaryPolygon(List<Vector3> boundaryPolygonPoints) + { + m_NativeSession.PlaneApi.GetPolygon(m_TrackableNativeHandle, boundaryPolygonPoints); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e1cc6ecdd7480d776dfc2cda03788084e4f0177f --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPlane.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f2d0f75c2c2744f5c8b7c0a18da840a6 +timeCreated: 1502152830 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7c90a01b97e2a5e699df7567f6eeecc1475cc97 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs @@ -0,0 +1,69 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackedPoint.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using GoogleARCoreInternal; + using UnityEngine; + + /// <summary> + /// A point in the real world tracked by ARCore. + /// </summary> + public class TrackedPoint : Trackable + { + //// @cond EXCLUDE_FROM_DOXYGEN + + /// <summary> + /// Construct TrackedPoint from a native handle. + /// </summary> + /// <param name="nativeHandle">A handle to the native ARCore API Trackable.</param> + /// <param name="nativeApi">The ARCore native api.</param> + public TrackedPoint(IntPtr nativeHandle, NativeSession nativeApi) : base(nativeHandle, nativeApi) + { + } + + //// @endcond + + /// <summary> + /// Gets the pose of the TrackedPoint. + /// </summary> + public Pose Pose + { + get + { + return m_NativeSession.PointApi.GetPose(m_TrackableNativeHandle); + } + } + + /// <summary> + /// Gets the orientation mode of the TrackedPoint. + /// </summary> + public TrackedPointOrientationMode OrientationMode + { + get + { + return m_NativeSession.PointApi.GetOrientationMode(m_TrackableNativeHandle); + } + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..dfc1e35eb081e4b3523f0b52750acba0d46f231c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPoint.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d7990c0cac50a48a29eba12ee1f730bc +timeCreated: 1510616957 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs new file mode 100644 index 0000000000000000000000000000000000000000..bd381cc8ba102836f304fd5eb87b582cd2a71e5b --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs @@ -0,0 +1,31 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackedPointOrientationMode.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// The orientation mode for a TrackedPoint. + /// </summary> + public enum TrackedPointOrientationMode + { + Identity = 0, + SurfaceNormal = 1, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..582f1e37b71a111fda28c94bfd52d42aaaf773ab --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackedPointOrientationMode.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f605e8f0dd31a453083b47fb68477792 +timeCreated: 1516989852 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs new file mode 100644 index 0000000000000000000000000000000000000000..def6f4f5a0ed3afffb3f0e5ea18b6814d0ad3721 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +// <copyright file="TrackingState.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCore +{ + /// <summary> + /// Possible tracking states for ARCore. + /// </summary> + public enum TrackingState + { + /// <summary> + /// The entity is actively being tracked. + /// </summary> + Tracking = 0, + + /// <summary> + /// ARCore has paused tracking the entity but may resume tracking it in the future. + /// </summary> + Paused = 1, + + /// <summary> + /// ARCore has stopped tracking the entity and will never resume tracking it. + /// </summary> + Stopped = 2, + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..caac85131f42297fff67766503c8f885ffea3a85 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/TrackingState.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 190efca65a78647b7a60e0e4b2288b27 +timeCreated: 1510509514 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility.meta new file mode 100644 index 0000000000000000000000000000000000000000..7f35db0988967f5265e891d59db3062335968c9a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: df74476279e4c4797bdcc1ff52177a3e +folderAsset: yes +timeCreated: 1502401080 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs new file mode 100644 index 0000000000000000000000000000000000000000..35461c2c65b786ffeb1154a113e23b8d279f47bd --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------- +// <copyright file="ARCoreProjectSettings.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.IO; + using UnityEngine; + + [Serializable] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class ARCoreProjectSettings + { + public string Version; + public bool IsARCoreRequired; + public bool IsInstantPreviewEnabled; + private const string k_VersionString = "V1.0.0"; + private const string k_ProjectSettingsPath = "ProjectSettings/ARCoreProjectSettings.json"; + + static ARCoreProjectSettings() + { + if (Application.isEditor) + { + Instance = new ARCoreProjectSettings(); + Instance.Load(); + } + else + { + Instance = null; + Debug.LogError("Cannot access ARCoreProjectSettings outside of Unity Editor."); + } + } + + public static ARCoreProjectSettings Instance { get; private set; } + + public void Load() + { + Version = k_VersionString; + IsARCoreRequired = true; + IsInstantPreviewEnabled = false; + + if (File.Exists(k_ProjectSettingsPath)) + { + ARCoreProjectSettings settings = JsonUtility.FromJson<ARCoreProjectSettings>( + File.ReadAllText(k_ProjectSettingsPath)); + Version = settings.Version; + IsARCoreRequired = settings.IsARCoreRequired; + } + } + + public void Save() + { + File.WriteAllText(k_ProjectSettingsPath, JsonUtility.ToJson(this)); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5a47a84f5ed7cfde00f41e63834ac04c9f09c176 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARCoreProjectSettings.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 68605a05829544832b871afc8bf03168 +timeCreated: 1518470830 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs new file mode 100644 index 0000000000000000000000000000000000000000..ea335f1f4407703dc3afd6be53bb204f4a3d4a36 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------- +// <copyright file="ARDebug.cs" company="Google"> +// +// Copyright 2016 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Diagnostics; + using UnityEngine; + + /// <summary> + /// A custom class similar to Unity's Debug. + /// </summary> + public class ARDebug + { + /// <summary> + /// Logs an error with a stack trace. + /// </summary> + /// <param name="message">The error message.</param> + public static void LogError(object message) + { + UnityEngine.Debug.LogErrorFormat(message + "\n{0}", new StackTrace(1)); + } + + /// <summary> + /// Logs an error with a stack trace. + /// </summary> + /// <param name="format">The string format.</param> + /// <param name="args">The output arguments.</param> + public static void LogErrorFormat(string format, params object[] args) + { + object[] newArgs = new object[args.Length + 1]; + Array.Copy(args, newArgs, args.Length); + newArgs[args.Length] = new StackTrace(1); + UnityEngine.Debug.LogErrorFormat(format + "\n{" + args.Length + "}", newArgs); + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..1fd07e54880df24815c59975561bab1b93dcc2f4 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ARDebug.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 84b5f07f2795d472e9c6e7bc3ed8bf35 +timeCreated: 1502425714 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..824e9e3741b760d3ca5952f50529aec99f4a5843 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------- +// <copyright file="ConversionHelper.cs" company="Google"> +// +// Copyright 2016 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class ConversionHelper + { + public static void UnityPoseToApiPose(Pose unityPose, out ApiPoseData apiPose) + { + Matrix4x4 glWorld_T_glLocal = Matrix4x4.TRS(unityPose.position, unityPose.rotation, Vector3.one); + Matrix4x4 unityWorld_T_glWorld = Matrix4x4.Scale(new Vector3(1, 1, -1)); + Matrix4x4 unityWorld_T_unityLocal = unityWorld_T_glWorld * glWorld_T_glLocal * unityWorld_T_glWorld.inverse; + + Vector3 position = unityWorld_T_unityLocal.GetColumn(3); + Quaternion rotation = Quaternion.LookRotation(unityWorld_T_unityLocal.GetColumn(2), + unityWorld_T_unityLocal.GetColumn(1)); + + apiPose.X = position.x; + apiPose.Y = position.y; + apiPose.Z = position.z; + apiPose.Qx = rotation.x; + apiPose.Qy = rotation.y; + apiPose.Qz = rotation.z; + apiPose.Qw = rotation.w; + } + + public static void ApiPoseToUnityPose(ApiPoseData apiPose, out Pose unityPose) + { + Matrix4x4 glWorld_T_glLocal = Matrix4x4.TRS(new Vector3(apiPose.X, apiPose.Y, apiPose.Z), + new Quaternion(apiPose.Qx, apiPose.Qy, apiPose.Qz, apiPose.Qw), Vector3.one); + Matrix4x4 unityWorld_T_glWorld = Matrix4x4.Scale(new Vector3(1, 1, -1)); + Matrix4x4 unityWorld_T_unityLocal = unityWorld_T_glWorld * glWorld_T_glLocal * unityWorld_T_glWorld.inverse; + + Vector3 position = unityWorld_T_unityLocal.GetColumn(3); + Quaternion rotation = Quaternion.LookRotation(unityWorld_T_unityLocal.GetColumn(2), + unityWorld_T_unityLocal.GetColumn(1)); + + unityPose = new Pose(position, rotation); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..7295e4317f899bad4b6080ac6bb300952e57fb1a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/ConversionHelper.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1a1be6e2816d24b2ea1d6ec5f4be479d +timeCreated: 1510266639 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs new file mode 100644 index 0000000000000000000000000000000000000000..64d89703e8607e56e3ac3f89d4ae20ccbb3c499c --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------- +// <copyright file="IntPtrEqualityComparer.cs" company="Google"> +// +// Copyright 2017 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using GoogleARCore; + using UnityEngine; + + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", + Justification = "Internal")] + public class IntPtrEqualityComparer : IEqualityComparer<IntPtr> + { + public bool Equals(IntPtr intPtr1, IntPtr intPtr2) + { + return intPtr1 == intPtr2; + } + + public int GetHashCode(IntPtr intPtr) + { + return intPtr.GetHashCode(); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..2b8db03bd6a3c4c4c6b40c7392f302eb270f742a --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/IntPtrEqualityComparer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ef23faba8749e46a5bd33fa98d0b4445 +timeCreated: 1513114243 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..ccdd62af93bbe5a107566a0f770aee3eb0811e57 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs @@ -0,0 +1,65 @@ +//----------------------------------------------------------------------- +// <copyright file="MarshalingHelper.cs" company="Google"> +// +// Copyright 2016 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. +// +// </copyright> +//----------------------------------------------------------------------- + +namespace GoogleARCoreInternal +{ + using System; + using System.Collections.Generic; + using System.Runtime.InteropServices; + using GoogleARCore; + + /// <summary> + /// A helper class for mashalling data. + /// </summary> + public class MarshalingHelper + { + /// <summary> + /// Adds the contents of an unmanaged struct array to a list. + /// </summary> + /// <param name="arrayPtr">A pointer to the unmanged array.</param> + /// <param name="arrayLength">The length of the unmanaged array.</param> + /// <param name="list">A list to append array elements to.</param> + /// <typeparam name="T">The type contained by the unmanaged array.</typeparam> + public static void AddUnmanagedStructArrayToList<T>(IntPtr arrayPtr, int arrayLength, List<T> list) where T : struct + { + if (arrayPtr == IntPtr.Zero || list == null) + { + return; + } + + for (int i = 0; i < arrayLength; i++) + { + list.Add((T)Marshal.PtrToStructure(GetPtrToUnmanagedArrayElement<T>(arrayPtr, i), typeof(T))); + } + } + + /// <summary> + /// Returns a pointer to an element within an unmanaged array. + /// </summary> + /// <returns>A pointer to the desired unmanaged array element.</returns> + /// <param name="arrayPtr">A pointer to the start of the array.</param> + /// <param name="arrayIndex">The index of the desired element pointer.</param> + /// <typeparam name="T">The type contained by the unmanaged array.</typeparam> + public static IntPtr GetPtrToUnmanagedArrayElement<T>(IntPtr arrayPtr, int arrayIndex) where T : struct + { + return new IntPtr(arrayPtr.ToInt64() + (Marshal.SizeOf(typeof(T)) * arrayIndex)); + } + } +} diff --git a/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs.meta b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..2ecb0636fda139d88fff85a52e1b2162ef034fe3 --- /dev/null +++ b/T3-Unity/Assets/GoogleARCore/SDK/Scripts/Utility/MarshalingHelper.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ced698934296748419bf72ad4ac8a66b +timeCreated: 1502400449 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: