GvrBetaHeadset.cs
5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//-----------------------------------------------------------------------
// <copyright file="GvrBetaHeadset.cs" company="Google LLC">
// Copyright 2019 Google LLC. 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>
//-----------------------------------------------------------------------
/// <summary>Daydream Beta API.</summary>
/// <remarks>
/// This API surface is for experimental purposes and may change or be removed in any future release
/// without forewarning.
/// </remarks>
namespace GoogleVR.Beta
{
using System;
using System.Runtime.InteropServices;
using Gvr.Internal;
using UnityEngine;
/// <summary>
/// The different supported appearances that determine how see-through camera
/// frames will be drawn.
/// </summary>
/// <remarks>Matches the C API enum `gvr_beta_see_through_camera_mode`.</remarks>
public enum GvrBetaSeeThroughCameraMode
{
/// <summary>The default behavior where no camera frames will be drawn.</summary>
Disabled = 0,
/// <summary>
/// The monochrome image will be shown as a grayscale image.
/// A theoretical color image will be shown in color.
/// </summary>
RawImage = 1,
/// <summary>
/// The monochrome image will be mapped to a blue to orange to white color
/// gradient.
/// </summary>
ToneMap = 2,
}
/// <summary>
/// The different scene types that an app can have. These control where the scene
/// is rendered from. Generally in a virtual scene the scene should be rendered from
/// the users' eyes while an augmented scene should be rendered from the camera's
/// position to match the see-through images. More details can be found in the
/// online developer documentation.
/// </summary>
public enum GvrBetaSeeThroughSceneType
{
/// <summary>Virtual scene type.</summary>
/// <remarks>
/// This represents a scene either composed entirely of virtual objects
/// with no see-through or a scene that is primarily virtual with small
/// cut outs for see-through. No head pose adjustments are applied with this
/// scene type.
/// </remarks>
Virtual = 0,
/// <summary>Augmented scene type with virtual objects.</summary>
/// <remarks>
/// This represents a scene that is primarily see-through with sparse virtual
/// objects inside the real environment. Head poses are adjusted based on camera
/// geometry to make virtual objects track properly with the real environment.
/// </remarks>
Augmented = 1
}
/// <summary>Daydream headset beta API.</summary>
public class GvrBetaHeadset : GvrHeadset
{
private static GvrBetaSeeThroughCameraMode currentCameraMode;
private static GvrBetaSeeThroughSceneType currentSceneType;
/// <summary>Initial see-through camera mode set when this object starts.</summary>
[SerializeField]
private GvrBetaSeeThroughCameraMode initialCameraMode =
GvrBetaSeeThroughCameraMode.Disabled;
/// <summary>Initial see-through scene type set when this object starts.</summary>
[SerializeField]
private GvrBetaSeeThroughSceneType initialSceneType = GvrBetaSeeThroughSceneType.Virtual;
/// <summary>Gets or sets the current see-through camera mode.</summary>
/// <value>The see-through camera mode.</value>
public static GvrBetaSeeThroughCameraMode CameraMode
{
get { return currentCameraMode; }
set { SetSeeThroughConfig(value, currentSceneType); }
}
/// <summary>Gets or sets the current see-through scene type.</summary>
/// <value>The see-through scene type.</value>
public static GvrBetaSeeThroughSceneType SceneType
{
get { return currentSceneType; }
set { SetSeeThroughConfig(currentCameraMode, value); }
}
/// <summary>Sets the current see-through camera mode and scene type.</summary>
/// <param name="cameraMode">The see-through camera mode to be set.</param>
/// <param name="sceneType">The see-through scene type to be set.</param>
public static void SetSeeThroughConfig(GvrBetaSeeThroughCameraMode cameraMode,
GvrBetaSeeThroughSceneType sceneType)
{
currentCameraMode = cameraMode;
currentSceneType = sceneType;
GvrBetaHeadsetProvider.SetSeeThroughConfig(cameraMode, sceneType);
}
private void Start()
{
SetSeeThroughConfig(initialCameraMode, initialSceneType);
}
}
}