Initial creation of playmodetests repo

This commit is contained in:
Sean Stolberg 2018-05-29 15:14:36 -07:00
Родитель cfb223eab6
Коммит c5cf76416e
535 изменённых файлов: 56525 добавлений и 0 удалений

63
.gitattributes поставляемый Normal file
Просмотреть файл

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

26
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,26 @@
**/Library/
**/Temp/
**/obj/
**/StreamingAssets/
**/.vscode/
**/.vs
**/Library/
*.idea
*.csproj
*.sln
*.suo
*.userprefs
*.app
*.VC.*
.DS_Store
*~
*.swp
.vs/
build/*
TwoStickShooter/Pure/Library/AnnotationManager
*.rsp

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: afb3e05691ff94d2cbad20643e5c5879
folderAsset: yes
timeCreated: 1501181552
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6b1cded3497844b35a3bfac966b428f2
folderAsset: yes
timeCreated: 1496364746
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9586a84d6c32f46b6ab7aeb6042f160d
timeCreated: 1510878073
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a00108229b1e04acd805e57abcdff773
folderAsset: yes
timeCreated: 1492558533
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,151 @@
%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: 1905656715913530}
m_IsPrefabParent: 1
--- !u!1 &1905656715913530
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4892153982037908}
- component: {fileID: 114254441574086558}
m_Layer: 0
m_Name: ARCoreDevice
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1960903772876386
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4923070639190690}
- component: {fileID: 20362215073346118}
- component: {fileID: 114720632237736846}
- component: {fileID: 114923820857209294}
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!4 &4892153982037908
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1905656715913530}
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: 4923070639190690}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4923070639190690
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1960903772876386}
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: 4892153982037908}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &20362215073346118
Camera:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1960903772876386}
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 &114254441574086558
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1905656715913530}
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}
ConnectOnAwake: 1
--- !u!114 &114720632237736846
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1960903772876386}
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
--- !u!114 &114923820857209294
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1960903772876386}
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}

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c10877f7cd5764de18d46d7b777d1faa
timeCreated: 1501460862
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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: EnvironmentalLight
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:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cf498fc35b538884db557f7a9a2c0ef9
timeCreated: 1512062703
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 84e45386d8da3497591c38deb2bccd02
folderAsset: yes
timeCreated: 1502400656
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b2c4e904b5e6b425f8ab111db67d7908
folderAsset: yes
timeCreated: 1497981256
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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}

Просмотреть файл

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 03ad0130a037647aeb60218f61aca114
timeCreated: 1498003566
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,62 @@
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
}
}
FallBack Off
}

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 025775b2b3616154f9eec0261bb8a581
timeCreated: 1510285086
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 93be2b9777c348648a2d9151b7e233fc
folderAsset: yes
timeCreated: 1501825151
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Двоичные данные
ARCore/Assets/GoogleARCore/SDK/Plugins/arcore_client.aar Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,31 @@
fileFormatVersion: 2
guid: 19eddef6ceb6961489b26fb8bf19f1e5
timeCreated: 1510180815
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:

Двоичные данные
ARCore/Assets/GoogleARCore/SDK/Plugins/libarcore_unity_api.so Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,95 @@
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
- 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:

Двоичные данные
ARCore/Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -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:

Двоичные данные
ARCore/Assets/GoogleARCore/SDK/Plugins/unitygar.aar Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 8f3875959d8dd4bdeb9620e0eb96fb3b
folderAsset: yes
timeCreated: 1501446012
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,112 @@
//-----------------------------------------------------------------------
// <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;
//// TODO (mtsmall): Consider if this component is the best way to expose background rendering and discuss approach
//// with Unity.
/// <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 (Application.isEditor)
{
enabled = false;
return;
}
if (BackgroundMaterial == null)
{
Debug.LogError("ArCameraBackground:: No material assigned.");
return;
}
m_Camera = GetComponent<Camera>();
}
private void OnDisable()
{
if (m_BackgroundRenderer != null)
{
m_BackgroundRenderer.camera = null;
m_BackgroundRenderer = null;
}
}
private void Update()
{
if (BackgroundMaterial == null)
{
// A background rending material has not been assigned.
return;
}
else if (Frame.CameraImage.Texture == null)
{
// TODO (mtsmall): Consider rendering a default background in this case.
// No texture is available.
return;
}
const string mainTexVar = "_MainTex";
const string topLeftRightVar = "_UvTopLeftRight";
const string bottomLeftRightVar = "_UvBottomLeftRight";
BackgroundMaterial.SetTexture(mainTexVar, Frame.CameraImage.Texture);
ApiDisplayUvCoords 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;
}
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,216 @@
//-----------------------------------------------------------------------
// <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 System;
using System.Runtime.InteropServices;
using GoogleARCoreInternal;
using UnityEngine;
using UnityEngine.XR;
/// <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>
/// Toggles whether the tango service should be automatically connected upon Awake.
/// </summary>
[Tooltip("Toggles whether the tango service should be automatically connected upon Awake.")]
public bool ConnectOnAwake = false;
private SessionManager m_SessionManager;
/// <summary>
/// Unity Awake.
/// </summary>
public void Awake()
{
if (Application.isEditor)
{
enabled = false;
return;
}
if (FindObjectsOfType<ARCoreSession>().Length > 1)
{
ARDebug.LogError("Multiple SessionComponents present in the game scene. Destroying the gameobject " +
"of the newest one.");
Destroy(gameObject);
return;
}
m_SessionManager = SessionManager.CreateSession();
Session.Initialize(m_SessionManager);
if (Session.ConnectionState != SessionConnectionState.Uninitialized)
{
ARDebug.LogError("Could not create an ARCore session. The current Unity Editor may not support this " +
"version of ARCore.");
return;
}
if (ConnectOnAwake)
{
Connect();
}
}
/// <summary>
/// Unity OnDestroy.
/// </summary>
public void OnDestroy()
{
Frame.Destroy();
Session.Destroy();
}
/// <summary>
/// Unity Update.
/// </summary>
public void Update()
{
if (m_SessionManager == null)
{
return;
}
AsyncTask.OnUpdate();
}
/// <summary>
/// Connects an ARSession using {@link sessionConfig} configuration. Note that if user permissions are needed
/// they will be requested and thus this is an asynchronous method.
/// </summary>
/// <returns>An {@link AsyncTask<T>} that completes when the connection has been made or failed. </returns>
public AsyncTask<SessionConnectionState> Connect()
{
return Connect(SessionConfig);
}
/// <summary>
/// Connects an ARSession. Note that if user permissions are needed they will be requested and thus this is an
/// asynchronous method.
/// </summary>
/// <param name="sessionConfig">The session configuration.</param>
/// <returns>An {@link AsyncTask<T>} that completes when the connection has been made or failed. </returns>
public AsyncTask<SessionConnectionState> Connect(ARCoreSessionConfig sessionConfig)
{
const string androidCameraPermissionName = "android.permission.CAMERA";
if (m_SessionManager == null)
{
ARDebug.LogError("Cannot connect because ARCoreSession failed to initialize.");
return new AsyncTask<SessionConnectionState>(SessionConnectionState.Uninitialized);
}
if (sessionConfig == null)
{
ARDebug.LogError("Unable to connect ARSession session due to missing ARSessionConfig.");
m_SessionManager.ConnectionState = SessionConnectionState.MissingConfiguration;
return new AsyncTask<SessionConnectionState>(Session.ConnectionState);
}
// We have already connected at least once.
if (Session.ConnectionState != SessionConnectionState.Uninitialized)
{
ARDebug.LogError("Multiple attempts to connect to the ARSession. Note that the ARSession connection " +
"spans the lifetime of the application and cannot be reconfigured. This will change in future " +
"versions of ARCore.");
return new AsyncTask<SessionConnectionState>(Session.ConnectionState);
}
// Create an asynchronous task for the potential permissions flow and service connection.
Action<SessionConnectionState> onTaskComplete;
var returnTask = new AsyncTask<SessionConnectionState>(out onTaskComplete);
returnTask.ThenAction((connectionState) =>
{
m_SessionManager.ConnectionState = connectionState;
});
// Attempt service connection immediately if permissions are granted.
if (AndroidPermissionsManager.IsPermissionGranted(androidCameraPermissionName))
{
_ResumeSession(sessionConfig, onTaskComplete);
return returnTask;
}
// Request needed permissions and attempt service connection if granted.
AndroidPermissionsManager.RequestPermission(androidCameraPermissionName).ThenAction((requestResult) =>
{
if (requestResult.IsAllGranted)
{
_ResumeSession(sessionConfig, onTaskComplete);
}
else
{
ARDebug.LogError("ARCore connection failed because a needed permission was rejected.");
onTaskComplete(SessionConnectionState.UserRejectedNeededPermission);
}
});
return returnTask;
}
/// <summary>
/// Connects to the ARCore service.
/// </summary>
/// <param name="sessionConfig">The session configuration to connect with.</param>
/// <param name="onComplete">A callback for when the result of the connection attempt is known.</param>
private void _ResumeSession(ARCoreSessionConfig sessionConfig, Action<SessionConnectionState> onComplete)
{
if (!m_SessionManager.CheckSupported(sessionConfig))
{
ARDebug.LogError("The requested ARCore session configuration is not supported.");
onComplete(SessionConnectionState.InvalidConfiguration);
return;
}
if (!m_SessionManager.SetConfiguration(sessionConfig))
{
ARDebug.LogError("ARCore connection failed because the current configuration is not supported.");
onComplete(SessionConnectionState.InvalidConfiguration);
return;
}
Frame.Initialize(m_SessionManager.FrameManager);
// ArSession_resume needs to be called in the UI thread due to b/69682628.
AsyncTask.PerformActionInUIThread(() =>
{
if (!m_SessionManager.Resume())
{
onComplete(SessionConnectionState.ConnectToServiceFailed);
}
else
{
onComplete(SessionConnectionState.Connected);
}
});
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,122 @@
//-----------------------------------------------------------------------
// <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 NativeApi m_NativeApi;
private TrackingState m_LastFrameTrackingState = TrackingState.Stopped;
/// <summary>
/// Gets the tracking state of the anchor.
/// </summary>
public TrackingState TrackingState
{
get
{
return m_NativeApi.Anchor.GetTrackingState(m_AnchorNativeHandle);
}
}
//// @cond EXCLUDE_FROM_DOXYGEN
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented",
Justification = "Internal")]
public static Anchor AnchorFactory(IntPtr anchorNativeHandle, NativeApi nativeApi)
{
if (anchorNativeHandle == IntPtr.Zero)
{
return null;
}
Anchor result;
if (s_AnchorDict.TryGetValue(anchorNativeHandle, out result))
{
// Release acquired handle and return cached result
result.m_NativeApi.Anchor.Release(anchorNativeHandle);
return result;
}
Anchor anchor = (new GameObject()).AddComponent<Anchor>();
anchor.gameObject.name = "Anchor";
anchor.m_AnchorNativeHandle = anchorNativeHandle;
anchor.m_NativeApi = nativeApi;
anchor.Update();
s_AnchorDict.Add(anchorNativeHandle, anchor);
return anchor;
}
//// @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_NativeApi.Anchor.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_NativeApi.Anchor.Release(m_AnchorNativeHandle);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,170 @@
//-----------------------------------------------------------------------
// <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)
{
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 (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 }));
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 11813694e8abb437eb9ef46ed1cc67c5
folderAsset: yes
timeCreated: 1502400396
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public AnchorApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public Pose GetPose(IntPtr anchorHandle)
{
var poseHandle = m_NativeApi.Pose.Create();
ExternApi.ArAnchor_getPose(m_NativeApi.SessionHandle, anchorHandle, poseHandle);
Pose resultPose = m_NativeApi.Pose.ExtractPoseValue(poseHandle);
m_NativeApi.Pose.Destroy(poseHandle);
return resultPose;
}
public TrackingState GetTrackingState(IntPtr anchorHandle)
{
ApiTrackingState trackingState = ApiTrackingState.Stopped;
ExternApi.ArAnchor_getTrackingState(m_NativeApi.SessionHandle, anchorHandle,
ref trackingState);
return trackingState.ToTrackingState();
}
public void Detach(IntPtr anchorHandle)
{
ExternApi.ArAnchor_detach(m_NativeApi.SessionHandle, anchorHandle);
}
public void Release(IntPtr anchorHandle)
{
ExternApi.ArAnchor_release(anchorHandle);
}
public IntPtr CreateList()
{
IntPtr listHandle = IntPtr.Zero;
ExternApi.ArAnchorList_create(m_NativeApi.SessionHandle, ref listHandle);
return listHandle;
}
public int GetListSize(IntPtr anchorListHandle)
{
int size = 0;
ExternApi.ArAnchorList_getSize(m_NativeApi.SessionHandle, anchorListHandle, ref size);
return size;
}
public IntPtr AcquireListItem(IntPtr anchorListHandle, int index)
{
IntPtr anchorHandle = IntPtr.Zero;
ExternApi.ArAnchorList_acquireItem(m_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------
// <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
{
public const string ARCoreNativeApi = "arcore_sdk";
public const string ARCoreShimApi = "arcore_unity_api";
// NDK camera API is a system API after Android 24.
public const string NdkCameraApi = "camera2ndk";
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
}
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public CameraApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public TrackingState GetTrackingState(IntPtr cameraHandle)
{
ApiTrackingState apiTrackingState = ApiTrackingState.Stopped;
ExternApi.ArCamera_getTrackingState(m_NativeApi.SessionHandle,
cameraHandle, ref apiTrackingState);
return apiTrackingState.ToTrackingState();
}
public Pose GetPose(IntPtr cameraHandle)
{
if (cameraHandle == IntPtr.Zero)
{
return Pose.identity;
}
IntPtr poseHandle = m_NativeApi.Pose.Create();
ExternApi.ArCamera_getDisplayOrientedPose(m_NativeApi.SessionHandle, cameraHandle,
poseHandle);
Pose resultPose = m_NativeApi.Pose.ExtractPoseValue(poseHandle);
m_NativeApi.Pose.Destroy(poseHandle);
return resultPose;
}
public Matrix4x4 GetProjectionMatrix(IntPtr cameraHandle, float near, float far)
{
Matrix4x4 matrix = Matrix4x4.identity;
ExternApi.ArCamera_getProjectionMatrix(m_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public CameraMetadataApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
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_NativeApi.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,148 @@
//-----------------------------------------------------------------------
// <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 NativeApi m_NativeApi;
public FrameApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public long GetTimestamp(IntPtr frameHandle)
{
long timestamp = 0;
ExternApi.ArFrame_getTimestamp(m_NativeApi.SessionHandle, frameHandle,
ref timestamp);
return timestamp;
}
public IntPtr AcquireCamera(IntPtr frameHandle)
{
if (frameHandle == IntPtr.Zero)
{
return IntPtr.Zero;
}
IntPtr cameraHandle = IntPtr.Zero;
ExternApi.ArFrame_acquireCamera(m_NativeApi.SessionHandle, frameHandle,
ref cameraHandle);
return cameraHandle;
}
public IntPtr AcquirePointCloud(IntPtr frameHandle)
{
IntPtr pointCloudHandle = IntPtr.Zero;
ExternApi.ArFrame_acquirePointCloud(m_NativeApi.SessionHandle, frameHandle,
ref pointCloudHandle);
return pointCloudHandle;
}
public IntPtr AcquireImageMetadata(IntPtr frameHandle)
{
IntPtr imageMetadataHandle = IntPtr.Zero;
ExternApi.ArFrame_acquireImageMetadata(m_NativeApi.SessionHandle, frameHandle, ref imageMetadataHandle);
return imageMetadataHandle;
}
public LightEstimate GetLightEstimate(IntPtr frameHandle)
{
IntPtr lightEstimateHandle = m_NativeApi.LightEstimate.Create();
ExternApi.ArFrame_getLightEstimate(m_NativeApi.SessionHandle, frameHandle,
lightEstimateHandle);
LightEstimateState state = m_NativeApi.LightEstimate.GetState(lightEstimateHandle);
float pixelIntensity = m_NativeApi.LightEstimate.GetPixelIntensity(lightEstimateHandle);
m_NativeApi.LightEstimate.Destroy(lightEstimateHandle);
return new LightEstimate(state, pixelIntensity);
}
public void TransformDisplayUvCoords(IntPtr frameHandle, ref ApiDisplayUvCoords uv)
{
ApiDisplayUvCoords uvOut = new ApiDisplayUvCoords();
ExternApi.ArFrame_transformDisplayUvCoords(m_NativeApi.SessionHandle, frameHandle,
ApiDisplayUvCoords.NumFloats, ref uv, ref uvOut);
uv = uvOut;
}
public void GetUpdatedTrackables(IntPtr frameHandle, List<Trackable> trackables)
{
IntPtr listHandle = m_NativeApi.TrackableList.Create();
ExternApi.ArFrame_getUpdatedTrackables(m_NativeApi.SessionHandle, frameHandle,
ApiTrackableType.BaseTrackable, listHandle);
trackables.Clear();
int count = m_NativeApi.TrackableList.GetCount(listHandle);
for (int i = 0; i < count; i++)
{
IntPtr trackableHandle = m_NativeApi.TrackableList.AcquireItem(listHandle, i);
trackables.Add(m_NativeApi.TrackableFactory(trackableHandle));
}
m_NativeApi.TrackableList.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,173 @@
//-----------------------------------------------------------------------
// <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 NativeApi m_NativeApi;
public HitTestApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
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_NativeApi.SessionHandle, ref hitResultListHandle);
ExternApi.ArFrame_hitTest(m_NativeApi.SessionHandle, frameHandle, x, y, hitResultListHandle);
int hitListSize = 0;
ExternApi.ArHitResultList_getSize(m_NativeApi.SessionHandle, hitResultListHandle, ref hitListSize);
for (int i = 0; i < hitListSize; i++)
{
TrackableHit trackableHit = new TrackableHit();
if (HitResultListGetItemAt(hitResultListHandle, i, ref 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, ref TrackableHit outTrackableHit)
{
// Query the hit result.
IntPtr hitResultHandle = IntPtr.Zero;
ExternApi.ArHitResult_create(m_NativeApi.SessionHandle, ref hitResultHandle);
ExternApi.ArHitResultList_getItem(m_NativeApi.SessionHandle, hitResultListHandle, index, hitResultHandle);
if (hitResultHandle == IntPtr.Zero)
{
ExternApi.ArHitResult_destroy(hitResultHandle);
return false;
}
// Query the pose from hit result.
IntPtr poseHandle = m_NativeApi.Pose.Create();
ExternApi.ArHitResult_getHitPose(m_NativeApi.SessionHandle, hitResultHandle, poseHandle);
Pose hitPose = m_NativeApi.Pose.ExtractPoseValue(poseHandle);
// Query the distance from hit result.
float hitDistance = 0.0f;
ExternApi.ArHitResult_getDistance(m_NativeApi.SessionHandle, hitResultHandle, ref hitDistance);
// Query the trackable from hit result.
IntPtr trackableHandle = IntPtr.Zero;
ExternApi.ArHitResult_acquireTrackable(m_NativeApi.SessionHandle, hitResultHandle, ref trackableHandle);
Trackable trackable = m_NativeApi.TrackableFactory(trackableHandle);
m_NativeApi.Trackable.Release(trackableHandle);
// Calculate trackable hit flags.
TrackableHitFlags flag = TrackableHitFlags.None;
if (trackable == null)
{
Debug.Log("Could not create trackable from hit result.");
m_NativeApi.Pose.Destroy(poseHandle);
return false;
}
else if (trackable is TrackedPlane)
{
if (m_NativeApi.Plane.IsPoseInPolygon(trackableHandle, poseHandle))
{
flag |= TrackableHitFlags.PlaneWithinPolygon;
}
if (m_NativeApi.Plane.IsPoseInExtents(trackableHandle, poseHandle))
{
flag |= TrackableHitFlags.PlaneWithinBounds;
}
flag |= TrackableHitFlags.PlaneWithinInfinity;
}
else if (trackable is TrackedPoint)
{
flag |= TrackableHitFlags.PointCloud;
}
else
{
m_NativeApi.Pose.Destroy(poseHandle);
return false;
}
outTrackableHit = new TrackableHit(hitPose, hitDistance, flag, trackable);
m_NativeApi.Pose.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public LightEstimateApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public IntPtr Create()
{
IntPtr lightEstimateHandle = IntPtr.Zero;
ExternApi.ArLightEstimate_create(m_NativeApi.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_NativeApi.SessionHandle, lightEstimateHandle, ref state);
return state.ToLightEstimateState();
}
public float GetPixelIntensity(IntPtr lightEstimateHandle)
{
float pixelIntensity = 0;
ExternApi.ArLightEstimate_getPixelIntensity(m_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,186 @@
//-----------------------------------------------------------------------
// <copyright file="NativeApi.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 NativeApi
{
private Dictionary<IntPtr, Trackable> m_TrackableDict = new Dictionary<IntPtr, Trackable>(new IntPtrEqualityComparer());
private IntPtr m_SessionHandle = IntPtr.Zero;
private EarlyUpdateCallback m_OnEarlyUpdate;
private NativeApi()
{
}
~NativeApi()
{
Destroy();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void EarlyUpdateCallback(IntPtr frameHandle, int textureId);
public IntPtr SessionHandle
{
get
{
return m_SessionHandle;
}
}
public AnchorApi Anchor { get; private set; }
public CameraApi Camera { get; private set; }
public FrameApi Frame { get; private set; }
public HitTestApi HitTest { get; private set; }
public LightEstimateApi LightEstimate { get; private set; }
public PlaneApi Plane { get; private set; }
public PointApi Point { get; private set; }
public PointCloudApi PointCloud { get; private set; }
public PoseApi Pose { get; private set; }
public SessionApi Session { get; private set; }
public SessionConfigApi SessionConfig { get; private set; }
public TrackableApi Trackable { get; private set; }
public TrackableListApi TrackableList { get; private set; }
public CameraMetadataApi CameraMetadata { get; private set; }
public static NativeApi CreateSession()
{
NativeApi nativeApi = new NativeApi();
ExternApi.ArCoreUnity_createSession(ref nativeApi.m_SessionHandle);
if (nativeApi.m_SessionHandle == IntPtr.Zero)
{
Debug.LogError("ARCore failed to create a session.");
return null;
}
nativeApi.Anchor = new AnchorApi(nativeApi);
nativeApi.Camera = new CameraApi(nativeApi);
nativeApi.Frame = new FrameApi(nativeApi);
nativeApi.HitTest = new HitTestApi(nativeApi);
nativeApi.LightEstimate = new LightEstimateApi(nativeApi);
nativeApi.Plane = new PlaneApi(nativeApi);
nativeApi.Point = new PointApi(nativeApi);
nativeApi.PointCloud = new PointCloudApi(nativeApi);
nativeApi.Pose = new PoseApi(nativeApi);
nativeApi.Session = new SessionApi(nativeApi);
nativeApi.SessionConfig = new SessionConfigApi(nativeApi);
nativeApi.Trackable = new TrackableApi(nativeApi);
nativeApi.TrackableList = new TrackableListApi(nativeApi);
nativeApi.CameraMetadata = new CameraMetadataApi(nativeApi);
nativeApi.Session.ReportEngineType();
return nativeApi;
}
public void Destroy()
{
if (m_SessionHandle != IntPtr.Zero)
{
ExternApi.ArCoreUnity_destroySession();
m_SessionHandle = IntPtr.Zero;
}
}
public bool Resume(EarlyUpdateCallback onEarlyUpdate)
{
m_OnEarlyUpdate = onEarlyUpdate;
return ExternApi.ArCoreUnity_resumeSession(m_OnEarlyUpdate);
}
/// <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.
Trackable.Release(nativeHandle);
return result;
}
ApiTrackableType trackableType = Trackable.GetType(nativeHandle);
if (trackableType == ApiTrackableType.Plane)
{
result = new TrackedPlane(nativeHandle, this);
}
else if (trackableType == ApiTrackableType.Point)
{
result = new TrackedPoint(nativeHandle, this);
}
else
{
UnityEngine.Debug.LogFormat("Cant find {0}", trackableType);
throw new NotImplementedException("TrackableFactory:: No contructor for requested trackable type.");
}
m_TrackableDict.Add(nativeHandle, result);
return result;
}
private struct ExternApi
{
[DllImport(ApiConstants.ARCoreShimApi)]
public static extern void ArCoreUnity_createSession(ref IntPtr sessionHandle);
[DllImport(ApiConstants.ARCoreShimApi)]
public static extern void ArCoreUnity_destroySession();
[DllImport(ApiConstants.ARCoreShimApi)]
public static extern bool ArCoreUnity_resumeSession(EarlyUpdateCallback earlyUpdate);
}
}
}

Просмотреть файл

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 7d20494e9cc8541f4bf16ac8a1eec2ef
timeCreated: 1509308701
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
private float[] m_TmpPoints;
private GCHandle m_TmpPointsHandle;
public PlaneApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
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_NativeApi.Pose.Create();
ExternApi.ArPlane_getCenterPose(m_NativeApi.SessionHandle, planeHandle, poseHandle);
Pose resultPose = m_NativeApi.Pose.ExtractPoseValue(poseHandle);
m_NativeApi.Pose.Destroy(poseHandle);
return resultPose;
}
public float GetExtentX(IntPtr planeHandle)
{
float extentX = 0.0f;
ExternApi.ArPlane_getExtentX(m_NativeApi.SessionHandle, planeHandle, ref extentX);
return extentX;
}
public float GetExtentZ(IntPtr planeHandle)
{
float extentZ = 0.0f;
ExternApi.ArPlane_getExtentZ(m_NativeApi.SessionHandle, planeHandle, ref extentZ);
return extentZ;
}
public void GetPolygon(IntPtr planeHandle, List<Vector3> points)
{
points.Clear();
int pointCount = 0;
ExternApi.ArPlane_getPolygonSize(m_NativeApi.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_NativeApi.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_NativeApi.SessionHandle, planeHandle, ref subsumerHandle);
return m_NativeApi.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_NativeApi.Pose.Create(pose);
ExternApi.ArPlane_isPoseInExtents(m_NativeApi.SessionHandle, planeHandle, poseHandle, ref isPoseInExtents);
m_NativeApi.Pose.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_NativeApi.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_NativeApi.Pose.Create(pose);
ExternApi.ArPlane_isPoseInPolygon(m_NativeApi.SessionHandle, planeHandle, poseHandle, ref isPoseInPolygon);
m_NativeApi.Pose.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,56 @@
//-----------------------------------------------------------------------
// <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 NativeApi m_NativeApi;
public PointApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public Pose GetPose(IntPtr planeHandle)
{
var poseHandle = m_NativeApi.Pose.Create();
ExternApi.ArPoint_getPose(m_NativeApi.SessionHandle, planeHandle, poseHandle);
Pose resultPose = m_NativeApi.Pose.ExtractPoseValue(poseHandle);
m_NativeApi.Pose.Destroy(poseHandle);
return resultPose;
}
private struct ExternApi
{
[DllImport(ApiConstants.ARCoreNativeApi)]
public static extern void ArPoint_getPose(IntPtr session, IntPtr point, IntPtr out_pose);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -0,0 +1,114 @@
//-----------------------------------------------------------------------
// <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 NativeApi m_NativeApi;
private float[] m_CachedVector = new float[4];
public PointCloudApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public long GetTimestamp(IntPtr pointCloudHandle)
{
long timestamp = 0;
ExternApi.ArPointCloud_getTimestamp(m_NativeApi.SessionHandle, pointCloudHandle, ref timestamp);
return timestamp;
}
public int GetNumberOfPoints(IntPtr pointCloudHandle)
{
int pointCount = 0;
ExternApi.ArPointCloud_getNumberOfPoints(m_NativeApi.SessionHandle, pointCloudHandle, ref pointCount);
// TODO (xuguo): remove the divide by 4 after b/69389164 is fixed.
return pointCount / 4;
}
public Vector4 GetPoint(IntPtr pointCloudHandle, int index)
{
IntPtr pointCloudNativeHandle = IntPtr.Zero;
ExternApi.ArPointCloud_getData(m_NativeApi.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public PoseApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
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_NativeApi.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public SessionApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public void ReportEngineType()
{
ExternApi.ArSession_reportEngineType(m_NativeApi.SessionHandle, "Unity",
Application.unityVersion);
}
public ApiArStatus CheckSupported(ARCoreSessionConfig config)
{
IntPtr configHandle;
if (config == null)
{
configHandle = IntPtr.Zero;
return ApiArStatus.ErrorUnsupportedConfiguration;
}
else
{
configHandle = m_NativeApi.SessionConfig.Create();
m_NativeApi.SessionConfig.UpdateApiConfigWithArCoreSessionConfig(configHandle, config);
}
ApiArStatus ret = ExternApi.ArSession_checkSupported(m_NativeApi.SessionHandle, configHandle);
m_NativeApi.SessionConfig.Destroy(configHandle);
return ret;
}
public bool SetConfiguration(ARCoreSessionConfig sessionConfig)
{
IntPtr configHandle = m_NativeApi.SessionConfig.Create();
m_NativeApi.SessionConfig.UpdateApiConfigWithArCoreSessionConfig(configHandle, sessionConfig);
bool ret = ExternApi.ArSession_configure(m_NativeApi.SessionHandle, configHandle) == 0;
m_NativeApi.SessionConfig.Destroy(configHandle);
return ret;
}
public void GetAllTrackables(List<Trackable> trackables)
{
IntPtr listHandle = m_NativeApi.TrackableList.Create();
ExternApi.ArSession_getAllTrackables(m_NativeApi.SessionHandle, ApiTrackableType.BaseTrackable, listHandle);
trackables.Clear();
int count = m_NativeApi.TrackableList.GetCount(listHandle);
for (int i = 0; i < count; i++)
{
IntPtr trackableHandle = m_NativeApi.TrackableList.AcquireItem(listHandle, i);
trackables.Add(m_NativeApi.TrackableFactory(trackableHandle));
}
m_NativeApi.TrackableList.Destroy(listHandle);
}
public Anchor CreateAnchor(Pose pose)
{
IntPtr poseHandle = m_NativeApi.Pose.Create(pose);
IntPtr anchorHandle = IntPtr.Zero;
ExternApi.ArSession_acquireNewAnchor(m_NativeApi.SessionHandle, poseHandle, ref anchorHandle);
var anchorResult = Anchor.AnchorFactory(anchorHandle, m_NativeApi);
m_NativeApi.Pose.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public SessionConfigApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public IntPtr Create()
{
IntPtr configHandle = IntPtr.Zero;
ExternApi.ArConfig_create(m_NativeApi.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_NativeApi.SessionHandle, configHandle, lightingMode);
var planeFindingMode = ApiPlaneFindingMode.Disabled;
if (arCoreSessionConfig.EnablePlaneFinding)
{
planeFindingMode = ApiPlaneFindingMode.Horizontal;
}
ExternApi.ArConfig_setPlaneFindingMode(m_NativeApi.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_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public TrackableApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public ApiTrackableType GetType(IntPtr trackableHandle)
{
ApiTrackableType type = ApiTrackableType.Plane;
ExternApi.ArTrackable_getType(m_NativeApi.SessionHandle, trackableHandle, ref type);
return type;
}
public TrackingState GetTrackingState(IntPtr trackableHandle)
{
ApiTrackingState apiTrackingState = ApiTrackingState.Stopped;
ExternApi.ArTrackable_getTrackingState(m_NativeApi.SessionHandle, trackableHandle,
ref apiTrackingState);
return apiTrackingState.ToTrackingState();
}
public bool AcquireNewAnchor(IntPtr trackableHandle, Pose pose, out IntPtr anchorHandle)
{
IntPtr poseHandle = m_NativeApi.Pose.Create(pose);
anchorHandle = IntPtr.Zero;
int status = ExternApi.ArTrackable_acquireNewAnchor(m_NativeApi.SessionHandle, trackableHandle, poseHandle,
ref anchorHandle);
m_NativeApi.Pose.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_NativeApi.Anchor.CreateList();
ExternApi.ArTrackable_getAnchors(m_NativeApi.SessionHandle, trackableHandle, anchorListHandle);
anchors.Clear();
int anchorCount = m_NativeApi.Anchor.GetListSize(anchorListHandle);
for (int i = 0; i < anchorCount; i++)
{
IntPtr anchorHandle = m_NativeApi.Anchor.AcquireListItem(anchorListHandle, i);
Anchor anchor = Anchor.AnchorFactory(anchorHandle, m_NativeApi);
if (anchor == null)
{
Debug.LogFormat("Unable to find Anchor component for handle {0}", anchorHandle);
}
else
{
anchors.Add(anchor);
}
}
m_NativeApi.Anchor.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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 NativeApi m_NativeApi;
public TrackableListApi(NativeApi nativeApi)
{
m_NativeApi = nativeApi;
}
public IntPtr Create()
{
IntPtr handle = IntPtr.Zero;
ExternApi.ArTrackableList_create(m_NativeApi.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_NativeApi.SessionHandle, listHandle, ref count);
return count;
}
public IntPtr AcquireItem(IntPtr listHandle, int index)
{
IntPtr trackableHandle = IntPtr.Zero;
ExternApi.ArTrackableList_acquireItem(m_NativeApi.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);
}
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 17818a5e2bd077f4fbaf893257754c05
timeCreated: 1512178510
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b3aabcae5f79543dea8251d640bde6ad
folderAsset: yes
timeCreated: 1502330118
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -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;
}
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше