Skip to content
This repository was archived by the owner on Nov 8, 2019. It is now read-only.

Commit f3b5391

Browse files
committed
Added Daydream Labs Controller Playground to Samples.
1 parent 7ba8647 commit f3b5391

File tree

3,456 files changed

+603459
-250
lines changed

Some content is hidden

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

3,456 files changed

+603459
-250
lines changed

Samples/CastleDefense/Assets/Game/Scripts/TerrainBehaviour.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using UnityEngine;
1+
// Copyright 2016 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using UnityEngine;
216
using System.Collections;
317
using UnityEngine.EventSystems;
418

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR/Distortion.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright 2015 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
16+
// To use in a surface shader, add the following text to the code:
17+
//
18+
// #pragma surface ... vertex:vert <-- add "vertex:vert" to this line
19+
// #pragma multi_compile __ GVR_DISTORTION <-- copy the next 5 lines
20+
// #include "GvrDistortion.cginc"
21+
// void vert (inout appdata_base v) {
22+
// v.vertex = undistortSurface(v.vertex);
23+
// }
24+
25+
// To use in a vertex shader, modify it as follows:
26+
//
27+
// #pragma multi_compile __ GVR_DISTORTION <-- add these 2 lines
28+
// #include "GvrDistortion.cginc"
29+
//
30+
// v2f vert (appdata_blah v) {
31+
// v2f o;
32+
// o.vertex = undistortVertex(v.vertex); <-- replace "mul(UNITY_MATRIX_MVP, v.vertex)"
33+
// ...
34+
// return o;
35+
// }
36+
37+
#if defined(GVR_DISTORTION)
38+
39+
float4x4 _Undistortion;
40+
float _MaxRadSq;
41+
float _NearClip;
42+
float4x4 _RealProjection;
43+
float4x4 _FixProjection;
44+
45+
float distortionFactor(float rSquared) {
46+
float ret = 0.0;
47+
ret = rSquared * (ret + _Undistortion[1][1]);
48+
ret = rSquared * (ret + _Undistortion[0][1]);
49+
ret = rSquared * (ret + _Undistortion[3][0]);
50+
ret = rSquared * (ret + _Undistortion[2][0]);
51+
ret = rSquared * (ret + _Undistortion[1][0]);
52+
ret = rSquared * (ret + _Undistortion[0][0]);
53+
return ret + 1.0;
54+
}
55+
56+
// Convert point from world space to undistorted camera space.
57+
float4 undistort(float4 pos) {
58+
// Go to camera space.
59+
pos = mul(UNITY_MATRIX_MV, pos);
60+
if (pos.z <= -_NearClip) { // Reminder: Forward is -Z.
61+
// Undistort the point's coordinates in XY.
62+
float r2 = clamp(dot(pos.xy, pos.xy) / (pos.z*pos.z), 0, _MaxRadSq);
63+
pos.xy *= distortionFactor(r2);
64+
}
65+
return pos;
66+
}
67+
68+
// Multiply by no-lens projection matrix after undistortion.
69+
float4 undistortVertex(float4 pos) {
70+
return mul(_RealProjection, undistort(pos));
71+
}
72+
73+
// Surface shader hides away the MVP multiplication, so we have
74+
// to multiply by _FixProjection = inverse(MVP)*_RealProjection.
75+
float4 undistortSurface(float4 pos) {
76+
return mul(_FixProjection, undistort(pos));
77+
}
78+
79+
#else
80+
// Distortion disabled.
81+
82+
// Just do the standard MVP transform.
83+
float4 undistortVertex(float4 pos) {
84+
return mul(UNITY_MATRIX_MVP, pos);
85+
}
86+
87+
// Surface shader hides away the MVP multiplication, so just return pos.
88+
float4 undistortSurface(float4 pos) {
89+
return pos;
90+
}
91+
92+
#endif

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR/Distortion/GvrDistortion.cginc.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR/Editor.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2016 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using UnityEngine;
16+
using UnityEditor;
17+
using System.Collections;
18+
19+
/// A custom editor for properties on the GvrAudioListener script. This appears in the Inspector
20+
/// window of a GvrAudioListener object.
21+
[CustomEditor(typeof(GvrAudioListener))]
22+
public class GvrAudioListenerEditor : Editor {
23+
private SerializedProperty globalGainDb = null;
24+
private SerializedProperty occlusionMask = null;
25+
private SerializedProperty quality = null;
26+
private SerializedProperty worldScale = null;
27+
28+
private GUIContent globalGainLabel = new GUIContent("Global Gain (dB)",
29+
"Sets the global gain of the system. Can be used to adjust the overall output volume.");
30+
private GUIContent occlusionMaskLabel = new GUIContent("Occlusion Mask",
31+
"Sets the global layer mask for occlusion detection.");
32+
private GUIContent qualityLabel = new GUIContent("Quality",
33+
"Sets the quality mode in which the spatial audio will be rendered. " +
34+
"Higher quality modes allow for increased fidelity at the cost of greater CPU usage.");
35+
private GUIContent worldScaleLabel = new GUIContent("World Scale",
36+
"Sets the ratio between game units and real world units (meters).");
37+
38+
void OnEnable () {
39+
globalGainDb = serializedObject.FindProperty("globalGainDb");
40+
occlusionMask = serializedObject.FindProperty("occlusionMask");
41+
quality = serializedObject.FindProperty("quality");
42+
worldScale = serializedObject.FindProperty("worldScale");
43+
}
44+
45+
/// @cond
46+
public override void OnInspectorGUI () {
47+
serializedObject.Update();
48+
49+
// Rendering quality can only be modified through the Inspector in Edit mode.
50+
GUI.enabled = !EditorApplication.isPlaying;
51+
EditorGUILayout.PropertyField(quality, qualityLabel);
52+
GUI.enabled = true;
53+
54+
EditorGUILayout.Separator();
55+
56+
EditorGUILayout.Slider(globalGainDb, GvrAudio.minGainDb, GvrAudio.maxGainDb, globalGainLabel);
57+
EditorGUILayout.Slider(worldScale, GvrAudio.minWorldScale, GvrAudio.maxWorldScale,
58+
worldScaleLabel);
59+
60+
EditorGUILayout.Separator();
61+
62+
EditorGUILayout.PropertyField(occlusionMask, occlusionMaskLabel);
63+
64+
serializedObject.ApplyModifiedProperties();
65+
}
66+
/// @endcond
67+
}

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR/Editor/GvrAudioListenerEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright 2016 Google Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using UnityEngine;
16+
using UnityEditor;
17+
using System.Collections;
18+
19+
/// A custom editor for properties on the GvrAudioRoom script. This appears in the Inspector window
20+
/// of a GvrAudioRoom object.
21+
[CustomEditor(typeof(GvrAudioRoom))]
22+
[CanEditMultipleObjects]
23+
public class GvrAudioRoomEditor : Editor {
24+
private SerializedProperty leftWall = null;
25+
private SerializedProperty rightWall = null;
26+
private SerializedProperty floor = null;
27+
private SerializedProperty ceiling = null;
28+
private SerializedProperty backWall = null;
29+
private SerializedProperty frontWall = null;
30+
private SerializedProperty reflectivity = null;
31+
private SerializedProperty reverbGainDb = null;
32+
private SerializedProperty reverbBrightness = null;
33+
private SerializedProperty reverbTime = null;
34+
private SerializedProperty size = null;
35+
36+
private GUIContent surfaceMaterialsLabel = new GUIContent("Surface Materials",
37+
"Room surface materials to calculate the acoustic properties of the room.");
38+
private GUIContent surfaceMaterialLabel = new GUIContent("Surface Material",
39+
"Surface material used to calculate the acoustic properties of the room.");
40+
private GUIContent reflectivityLabel = new GUIContent("Reflectivity",
41+
"Adjusts what proportion of the direct sound is reflected back by each surface, after an " +
42+
"appropriate delay. Reverberation is unaffected by this setting.");
43+
private GUIContent reverbGainLabel = new GUIContent("Gain (dB)",
44+
"Applies a gain adjustment to the reverberation in the room. The default value will leave " +
45+
"reverb unaffected.");
46+
private GUIContent reverbPropertiesLabel = new GUIContent("Reverb Properties",
47+
"Parameters to adjust the reverb properties of the room.");
48+
private GUIContent reverbBrightnessLabel = new GUIContent("Brightness",
49+
"Adjusts the balance between high and low frequencies in the reverb.");
50+
private GUIContent reverbTimeLabel = new GUIContent("Time",
51+
"Adjusts the overall duration of the reverb by a positive scaling factor.");
52+
private GUIContent sizeLabel = new GUIContent("Size", "Sets the room dimensions.");
53+
54+
void OnEnable () {
55+
leftWall = serializedObject.FindProperty("leftWall");
56+
rightWall = serializedObject.FindProperty("rightWall");
57+
floor = serializedObject.FindProperty("floor");
58+
ceiling = serializedObject.FindProperty("ceiling");
59+
backWall = serializedObject.FindProperty("backWall");
60+
frontWall = serializedObject.FindProperty("frontWall");
61+
reflectivity = serializedObject.FindProperty("reflectivity");
62+
reverbGainDb = serializedObject.FindProperty("reverbGainDb");
63+
reverbBrightness = serializedObject.FindProperty("reverbBrightness");
64+
reverbTime = serializedObject.FindProperty("reverbTime");
65+
size = serializedObject.FindProperty("size");
66+
}
67+
68+
/// @cond
69+
public override void OnInspectorGUI () {
70+
serializedObject.Update();
71+
72+
EditorGUILayout.LabelField(surfaceMaterialsLabel);
73+
++EditorGUI.indentLevel;
74+
DrawSurfaceMaterial(leftWall);
75+
DrawSurfaceMaterial(rightWall);
76+
DrawSurfaceMaterial(floor);
77+
DrawSurfaceMaterial(ceiling);
78+
DrawSurfaceMaterial(backWall);
79+
DrawSurfaceMaterial(frontWall);
80+
--EditorGUI.indentLevel;
81+
82+
EditorGUILayout.Separator();
83+
84+
EditorGUILayout.Slider(reflectivity, 0.0f, GvrAudio.maxReflectivity, reflectivityLabel);
85+
86+
EditorGUILayout.Separator();
87+
88+
EditorGUILayout.LabelField(reverbPropertiesLabel);
89+
++EditorGUI.indentLevel;
90+
EditorGUILayout.Slider(reverbGainDb, GvrAudio.minGainDb, GvrAudio.maxGainDb, reverbGainLabel);
91+
EditorGUILayout.Slider(reverbBrightness, GvrAudio.minReverbBrightness,
92+
GvrAudio.maxReverbBrightness, reverbBrightnessLabel);
93+
EditorGUILayout.Slider(reverbTime, 0.0f, GvrAudio.maxReverbTime, reverbTimeLabel);
94+
--EditorGUI.indentLevel;
95+
96+
EditorGUILayout.Separator();
97+
98+
EditorGUILayout.PropertyField(size, sizeLabel);
99+
100+
serializedObject.ApplyModifiedProperties();
101+
}
102+
/// @endcond
103+
104+
private void DrawSurfaceMaterial (SerializedProperty surfaceMaterial) {
105+
surfaceMaterialLabel.text = surfaceMaterial.displayName;
106+
EditorGUILayout.PropertyField(surfaceMaterial, surfaceMaterialLabel);
107+
}
108+
}

Samples/DaydreamLabsControllerPlayground/Assets/GoogleVR/Editor/GvrAudioRoomEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)