diff --git a/CHANGELOG b/CHANGELOG index a681c874..879aec7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -78,3 +78,32 @@ v0.5.1 (7/22/2015): - Removed the INTERNET permission from AndroidManifest.xml. - Split the demos into a separate unitypackage. - Ignore gyro drift setting on iOS (it doesn't need it). + +v0.5.2 (10/12/2015): +- General performance improvements and CPU load reduction to reduce thermal throttling. +- New gyro drift correction method for better stability across more phones. +- Onboarding and Setup dialogs now support localized language strings. For Android this + is automatic. For iOS, enable Localizations in the Xcode project. +- Default distortion correction method is now done entirely in Unity to avoid + GL.IssuePluginEvent() overhead. The old native C++ version still available if issues arise. +- The GL.IssuePluginEvent() call uses a unique ID in order to be compatible with other native + plugins. (This only matters if you use the old Native distortion method.) +- A new CardboardCamera prefab manages both full screen clear and distortion + correction. It is included in CardboardMain, or created automatically if needed. +- Distortion correction is now done during the Camera rendering phase, which means + that uGUI Screen Space Overlays (and OnGUI) will appear onscreen now. +- The new distortion correction method is compatible with Metal (iOS) and multi- + threaded rendering (Android). +- The offscreen rendertexture used for distortion correction takes properties from + project settings (e.g. antialiasing, pixel format). Depth now defaults to 24 bits. +- The offscreen rendertexture resolution is padded to account for the barrel distortion, + in order to reduce relative fuzziness in pixels near the center. +- The Cardboard object has a simple slider to adjust the scale of the rendertexture + resolution globally. Dial down to increase performance. +- There is now an onscreen Back Button that functions like the normal Android back + button (which is hidden in immersive mode). You can turn it on or off, and choose + how to respond. +- Recent versions of Unity (5.1.x and 5.2.x) have changed the way they report DPI, which + is affecting the SDKs calculation of screen size. This has been worked around. +- A bug in the StereoController.AddStereoRig() function which cached the eyes array before + filling it in has been fixed. diff --git a/Cardboard/DemoScene/DemoScene.unity b/Cardboard/DemoScene/DemoScene.unity index 8c7deb75..12d2bbe0 100644 --- a/Cardboard/DemoScene/DemoScene.unity +++ b/Cardboard/DemoScene/DemoScene.unity @@ -24,7 +24,7 @@ RenderSettings: m_FlareStrength: 1 m_FlareFadeSpeed: 3 m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} m_ObjectHideFlags: 0 --- !u!127 &3 LevelGameManager: @@ -38,7 +38,7 @@ LightmapSettings: m_BakedColorSpace: 0 m_UseDualLightmapsInForward: 0 m_LightmapEditorSettings: - m_Resolution: 50 + m_Resolution: 1 m_LastUsedResolution: 0 m_TextureWidth: 1024 m_TextureHeight: 1024 @@ -53,10 +53,10 @@ LightmapSettings: m_FinalGatherGradientThreshold: 0 m_FinalGatherInterpolationPoints: 15 m_AOAmount: 0 - m_AOMaxDistance: .100000001 + m_AOMaxDistance: 1 m_AOContrast: 1 m_LODSurfaceMappingDistance: 1 - m_Padding: 0 + m_Padding: 2 m_TextureCompression: 0 m_LockAtlas: 0 --- !u!196 &5 @@ -75,134 +75,34 @@ NavMeshSettings: heightInaccuracy: 10 tileSizeHint: 0 m_NavMesh: {fileID: 0} ---- !u!1 &56998189 +--- !u!1 &143686265 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100006, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} serializedVersion: 4 m_Component: - - 4: {fileID: 56998190} - - 20: {fileID: 56998196} - - 124: {fileID: 56998195} - - 92: {fileID: 56998194} - - 81: {fileID: 56998193} - - 114: {fileID: 56998192} - - 114: {fileID: 56998197} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera + - 4: {fileID: 143686266} + m_Layer: 5 + m_Name: Gaze Pointer + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &56998190 +--- !u!4 &143686266 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400006, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 143686265} 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: 1644755742} - - {fileID: 802802344} - m_Father: {fileID: 1133015247} + - {fileID: 1453583987} + m_Father: {fileID: 2019452641} m_RootOrder: 1 ---- !u!114 &56998192 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400006, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b6788e8e1b3f7447db6657ef0959d3ce, type: 3} - m_Name: - m_EditorClassIdentifier: - directRender: 1 - stereoMultiplier: 1 - matchMonoFOV: 0 - matchByZoom: 0 - centerOfInterest: {fileID: 0} - radiusOfInterest: 0 - checkStereoComfort: 1 - screenParallax: 0 - stereoPaddingX: 0 - stereoPaddingY: 0 ---- !u!81 &56998193 -AudioListener: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 8100000, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 ---- !u!92 &56998194 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 9200004, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 ---- !u!124 &56998195 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 12400004, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 ---- !u!20 &56998196 -Camera: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 2000004, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: .300000012 - far clip plane: 1000 - 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_HDR: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: .0219999999 ---- !u!114 &56998197 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 56998189} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -768656878, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_EventMask: - serializedVersion: 2 - m_Bits: 4294967291 --- !u!1 &159634548 GameObject: m_ObjectHideFlags: 0 @@ -335,66 +235,6 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 188087729} ---- !u!1001 &202588249 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalPosition.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 100004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 400006, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: m_RootOrder - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: tapIsTrigger - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - propertyPath: syncWithCardboardApp - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_RootGameObject: {fileID: 1427108206} - m_IsPrefabParent: 0 - m_IsExploded: 1 --- !u!1 &389255504 GameObject: m_ObjectHideFlags: 0 @@ -421,7 +261,7 @@ Light: serializedVersion: 3 m_Type: 2 m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Intensity: 3 + m_Intensity: 5 m_Range: 20 m_SpotAngle: 30 m_CookieSize: 10 @@ -534,7 +374,7 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1427108208} + - m_Target: {fileID: 653490968} m_MethodName: Recenter m_Mode: 1 m_Arguments: @@ -670,8 +510,7 @@ MonoBehaviour: m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -706,141 +545,339 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 500035572} ---- !u!1 &802802339 +--- !u!1 &564964838 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} serializedVersion: 4 m_Component: - - 4: {fileID: 802802344} - - 20: {fileID: 802802343} - - 92: {fileID: 802802342} - - 124: {fileID: 802802341} - - 114: {fileID: 802802340} - m_Layer: 0 - m_Name: Main Camera Right + - 224: {fileID: 564964841} + - 222: {fileID: 564964840} + - 114: {fileID: 564964839} + - 114: {fileID: 564964842} + m_Layer: 5 + m_Name: FPS m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &802802340 +--- !u!114 &564964839 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400002, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 802802339} + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 564964838} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5c9cfdc6c389e2742aa40f991195d828, type: 3} + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} m_Name: m_EditorClassIdentifier: - eye: 1 - toggleCullingMask: - serializedVersion: 2 - m_Bits: 0 ---- !u!124 &802802341 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 12400000, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 802802339} - m_Enabled: 1 ---- !u!92 &802802342 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 9200000, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 802802339} - m_Enabled: 1 ---- !u!20 &802802343 -Camera: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 30 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 6 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: FPS +--- !u!222 &564964840 +CanvasRenderer: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 2000000, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 802802339} - m_Enabled: 0 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: .5 - y: 0 - width: .5 - height: 1 - near clip plane: .300000012 - far clip plane: 1000 - 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_HDR: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: .0219999999 ---- !u!4 &802802344 -Transform: + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 564964838} +--- !u!224 &564964841 +RectTransform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 802802339} + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 564964838} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: .0299999993, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 56998190} - m_RootOrder: 1 ---- !u!1 &876778148 -GameObject: + m_Father: {fileID: 892995910} + m_RootOrder: 0 + m_AnchorMin: {x: .5, y: .5} + m_AnchorMax: {x: .5, y: .5} + m_AnchoredPosition: {x: -870, y: -496} + m_SizeDelta: {x: 176, y: 68} + m_Pivot: {x: .5, y: .5} +--- !u!114 &564964842 +MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 564964838} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 11534fd325088423a9e85baae960115b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &653490966 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 100004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} serializedVersion: 4 m_Component: - - 224: {fileID: 876778149} - - 222: {fileID: 876778153} - - 114: {fileID: 876778152} - - 114: {fileID: 876778151} - - 95: {fileID: 876778150} + - 4: {fileID: 653490967} + - 114: {fileID: 653490968} m_Layer: 0 - m_Name: VRModeButton + m_Name: CardboardMain m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!224 &876778149 -RectTransform: +--- !u!4 &653490967 +Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 876778148} - m_LocalRotation: {x: -8.94069672e-08, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_PrefabParentObject: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 653490966} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 188087730} - m_Father: {fileID: 1968184281} - m_RootOrder: 2 - m_AnchorMin: {x: .5, y: .5} - m_AnchorMax: {x: .5, y: .5} - m_AnchoredPosition: {x: 0, y: -50} - m_SizeDelta: {x: 160, y: 40} - m_Pivot: {x: .5, y: .5} ---- !u!95 &876778150 -Animator: + - {fileID: 2019452641} + - {fileID: 697923556} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &653490968 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 653490966} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3} + m_Name: + m_EditorClassIdentifier: + vrModeEnabled: 1 + distortionCorrection: 2 + enableAlignmentMarker: 1 + enableSettingsButton: 1 + backButtonMode: 0 + tapIsTrigger: 0 + neckModelScale: 1 + autoDriftCorrection: 1 + electronicDisplayStabilization: 0 + syncWithCardboardApp: 0 + autoUntiltHead: 1 + UseUnityRemoteInput: 0 + screenSize: 0 + deviceType: 0 + stereoScreenScale: 1 +--- !u!1 &660583659 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 100006, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + serializedVersion: 4 + m_Component: + - 4: {fileID: 660583660} + - 20: {fileID: 660583665} + - 124: {fileID: 660583664} + - 92: {fileID: 660583663} + - 81: {fileID: 660583662} + - 114: {fileID: 660583661} + - 114: {fileID: 660583666} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &660583660 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 400006, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + 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: 1954690951} + - {fileID: 904718822} + m_Father: {fileID: 2019452641} + m_RootOrder: 0 +--- !u!114 &660583661 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11400006, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b6788e8e1b3f7447db6657ef0959d3ce, type: 3} + m_Name: + m_EditorClassIdentifier: + directRender: 1 + keepStereoUpdated: 0 + stereoMultiplier: 1 + matchMonoFOV: 0 + matchByZoom: 0 + centerOfInterest: {fileID: 0} + radiusOfInterest: 0 + checkStereoComfort: 1 + stereoAdjustSmoothing: .100000001 + screenParallax: 0 + stereoPaddingX: 0 + stereoPaddingY: 0 +--- !u!81 &660583662 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 8100000, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 +--- !u!92 &660583663 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 9200004, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 +--- !u!124 &660583664 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 12400004, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 +--- !u!20 &660583665 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2000004, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + 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_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!114 &660583666 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 660583659} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -768656878, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EventMask: + serializedVersion: 2 + m_Bits: 4286578651 +--- !u!1 &697923555 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 150430, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + serializedVersion: 4 + m_Component: + - 4: {fileID: 697923556} + m_Layer: 0 + m_Name: Stereo Render + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &697923556 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 450430, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 697923555} + 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: 1232138944} + - {fileID: 1172773252} + m_Father: {fileID: 653490967} + m_RootOrder: 1 +--- !u!1 &876778148 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 224: {fileID: 876778149} + - 222: {fileID: 876778153} + - 114: {fileID: 876778152} + - 114: {fileID: 876778151} + - 95: {fileID: 876778150} + m_Layer: 0 + m_Name: DistortionButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &876778149 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 876778148} + m_LocalRotation: {x: -8.94069672e-08, 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: 188087730} + m_Father: {fileID: 1968184281} + m_RootOrder: 2 + m_AnchorMin: {x: .5, y: .5} + m_AnchorMax: {x: .5, y: .5} + m_AnchoredPosition: {x: 0, y: -50} + m_SizeDelta: {x: 160, y: 40} + m_Pivot: {x: .5, y: .5} +--- !u!95 &876778150 +Animator: serializedVersion: 3 m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} @@ -934,6 +971,183 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 876778148} +--- !u!1 &892995906 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 224: {fileID: 892995910} + - 223: {fileID: 892995909} + - 114: {fileID: 892995908} + - 114: {fileID: 892995907} + m_Layer: 5 + m_Name: Overlay Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &892995907 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892995906} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4286578683 +--- !u!114 &892995908 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892995906} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1920, y: 1080} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: .5 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &892995909 +Canvas: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892995906} + m_Enabled: 1 + serializedVersion: 2 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 1 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!224 &892995910 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 892995906} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 564964841} + m_Father: {fileID: 0} + m_RootOrder: 6 + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &904718817 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + serializedVersion: 4 + m_Component: + - 4: {fileID: 904718822} + - 20: {fileID: 904718821} + - 124: {fileID: 904718819} + - 114: {fileID: 904718818} + m_Layer: 0 + m_Name: Main Camera Right + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &904718818 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11400002, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 904718817} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5c9cfdc6c389e2742aa40f991195d828, type: 3} + m_Name: + m_EditorClassIdentifier: + eye: 1 + toggleCullingMask: + serializedVersion: 2 + m_Bits: 0 +--- !u!124 &904718819 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 12400000, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 904718817} + m_Enabled: 1 +--- !u!20 &904718821 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2000000, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 904718817} + m_Enabled: 0 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: .5 + y: 0 + width: .5 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + 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_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!4 &904718822 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 400000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 904718817} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: .0299999993, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 660583660} + m_RootOrder: 1 --- !u!1 &955127915 GameObject: m_ObjectHideFlags: 0 @@ -1006,7 +1220,7 @@ Transform: m_LocalScale: {x: .5, y: .5, z: .5} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 1 --- !u!199 &955127920 ParticleSystemRenderer: m_ObjectHideFlags: 0 @@ -1014,8 +1228,8 @@ ParticleSystemRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 955127915} m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 m_LightmapIndex: 255 m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} m_Materials: @@ -1294,7 +1508,7 @@ ParticleSystem: minMaxState: 0 gravityModifier: 0 inheritVelocity: 0 - maxNumParticles: 1000 + maxNumParticles: 200 ShapeModule: serializedVersion: 2 enabled: 1 @@ -2123,8 +2337,7 @@ MonoBehaviour: m_Mode: 6 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -2141,8 +2354,7 @@ MonoBehaviour: m_Mode: 6 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -2159,8 +2371,7 @@ MonoBehaviour: m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -2168,6 +2379,98 @@ MonoBehaviour: m_CallState: 2 m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +--- !u!1001 &1073901967 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 150430, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: useDrawMeshNow + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: distortVertices + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: width + value: 40 + objectReference: {fileID: 0} + - target: {fileID: 11450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: height + value: 40 + objectReference: {fileID: 0} + - target: {fileID: 150432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_Layer + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: tapIsTrigger + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: distortionCorrection + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2000004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_CullingMask.m_Bits + value: 4294967295 + objectReference: {fileID: 0} + - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: vrModeEnabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2000004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + propertyPath: backButtonMode + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_RootGameObject: {fileID: 653490966} + m_IsPrefabParent: 0 + m_IsExploded: 1 --- !u!1 &1113738064 GameObject: m_ObjectHideFlags: 0 @@ -2210,7 +2513,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: vrModeOnly: 0 - cursor: {fileID: 2103211065} + cursor: {fileID: 143686265} + showCursor: 1 + scaleCursorSize: 1 clickTime: .100000001 hotspot: {x: .5, y: .5} --- !u!114 &1113738067 @@ -2239,105 +2544,233 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 5 ---- !u!1 &1133015246 +--- !u!1 &1172773251 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100008, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} + m_PrefabParentObject: {fileID: 150432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} serializedVersion: 4 m_Component: - - 4: {fileID: 1133015247} - - 114: {fileID: 1133015248} + - 4: {fileID: 1172773252} + - 20: {fileID: 1172773255} + - 92: {fileID: 1172773254} + - 114: {fileID: 1172773253} m_Layer: 0 - m_Name: Head + m_Name: PostRender m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1133015247 +--- !u!4 &1172773252 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400008, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1133015246} + m_PrefabParentObject: {fileID: 450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1172773251} 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: 2103211069} - - {fileID: 56998190} - m_Father: {fileID: 1427108207} - m_RootOrder: 0 ---- !u!114 &1133015248 + m_Children: [] + m_Father: {fileID: 697923556} + m_RootOrder: 1 +--- !u!114 &1172773253 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400008, guid: b8b03d395f5734e98af91ccf44f9bf47, + m_PrefabParentObject: {fileID: 11450432, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1133015246} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1172773251} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3} + m_Script: {fileID: 11500000, guid: 3995cc6db284649a793472ad14b220f6, type: 3} m_Name: m_EditorClassIdentifier: - trackRotation: 1 - trackPosition: 1 - target: {fileID: 0} - updateEarly: 0 ---- !u!1 &1427108206 +--- !u!92 &1172773254 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 9250434, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1172773251} + m_Enabled: 1 +--- !u!20 &1172773255 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2050432, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1172773251} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 3 + m_BackGroundColor: {r: 1, g: 0, b: 1, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: .5 + m_Depth: 100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!1 &1232138943 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 100004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} + m_PrefabParentObject: {fileID: 150434, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} serializedVersion: 4 m_Component: - - 4: {fileID: 1427108207} - - 114: {fileID: 1427108208} + - 4: {fileID: 1232138944} + - 20: {fileID: 1232138946} + - 114: {fileID: 1232138945} m_Layer: 0 - m_Name: CardboardMain + m_Name: PreRender m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1427108207 +--- !u!4 &1232138944 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1427108206} + m_PrefabParentObject: {fileID: 450434, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1232138943} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1133015247} - m_Father: {fileID: 0} - m_RootOrder: 2 ---- !u!114 &1427108208 + m_Children: [] + m_Father: {fileID: 697923556} + m_RootOrder: 0 +--- !u!114 &1232138945 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, + m_PrefabParentObject: {fileID: 11450434, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1427108206} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1232138943} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3} + m_Script: {fileID: 11500000, guid: 20fb7fbcfb2e642bba6211eb9ea19962, type: 3} m_Name: m_EditorClassIdentifier: - distortionCorrection: 1 - vrModeEnabled: 1 - enableAlignmentMarker: 1 - enableSettingsButton: 1 - tapIsTrigger: 1 - neckModelScale: 1 - autoDriftCorrection: 1 - syncWithCardboardApp: 0 - autoUntiltHead: 1 - UseUnityRemoteInput: 0 - screenSize: 0 - deviceType: 0 +--- !u!20 &1232138946 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2050434, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1232138943} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!1 &1453583983 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1453583987} + - 33: {fileID: 1453583986} + - 136: {fileID: 1453583985} + - 23: {fileID: 1453583984} + m_Layer: 5 + m_Name: Gaze Pointer Cursor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1453583984 +Renderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1453583983} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_LightmapIndex: 255 + m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} + m_Materials: + - {fileID: 2100000, guid: 9eda0932f25ae41a891d5e59269420a0, type: 2} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_LightProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!136 &1453583985 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1453583983} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: .5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1453583986 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1453583983} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1453583987 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1453583983} + m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106709} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: .0199999996, y: .0199999996, z: .0199999996} + m_Children: [] + m_Father: {fileID: 143686266} + m_RootOrder: 0 --- !u!1 &1499060387 GameObject: m_ObjectHideFlags: 0 @@ -2350,7 +2783,7 @@ GameObject: - 114: {fileID: 1499060389} - 114: {fileID: 1499060388} m_Layer: 0 - m_Name: Canvas + m_Name: Floor Canvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2371,7 +2804,7 @@ MonoBehaviour: m_BlockingObjects: 0 m_BlockingMask: serializedVersion: 2 - m_Bits: 4294967291 + m_Bits: 4286578683 --- !u!114 &1499060389 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2402,7 +2835,7 @@ Canvas: m_Enabled: 1 serializedVersion: 2 m_RenderMode: 2 - m_Camera: {fileID: 56998196} + m_Camera: {fileID: 660583665} m_PlaneDistance: 100 m_PixelPerfect: 0 m_ReceivesEvents: 1 @@ -2439,7 +2872,7 @@ GameObject: - 33: {fileID: 1639361860} - 23: {fileID: 1639361858} - 64: {fileID: 1639361857} - m_Layer: 0 + m_Layer: 2 m_Name: Plane m_TagString: Untagged m_Icon: {fileID: 0} @@ -2497,19 +2930,18 @@ Transform: m_LocalScale: {x: 4, y: .5, z: 4} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 ---- !u!1 &1644755741 + m_RootOrder: 2 +--- !u!1 &1954690950 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 100002, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} + m_PrefabInternal: {fileID: 1073901967} serializedVersion: 4 m_Component: - - 4: {fileID: 1644755742} - - 20: {fileID: 1644755746} - - 92: {fileID: 1644755745} - - 124: {fileID: 1644755744} - - 114: {fileID: 1644755743} + - 4: {fileID: 1954690951} + - 20: {fileID: 1954690955} + - 124: {fileID: 1954690953} + - 114: {fileID: 1954690952} m_Layer: 0 m_Name: Main Camera Left m_TagString: Untagged @@ -2517,25 +2949,25 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1644755742 +--- !u!4 &1954690951 Transform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 400002, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1644755741} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1954690950} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -.0299999993, y: -0, z: -0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 56998190} + m_Father: {fileID: 660583660} m_RootOrder: 0 ---- !u!114 &1644755743 +--- !u!114 &1954690952 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 11400004, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1644755741} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1954690950} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5c9cfdc6c389e2742aa40f991195d828, type: 3} @@ -2545,33 +2977,25 @@ MonoBehaviour: toggleCullingMask: serializedVersion: 2 m_Bits: 0 ---- !u!124 &1644755744 +--- !u!124 &1954690953 Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 12400002, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1644755741} - m_Enabled: 1 ---- !u!92 &1644755745 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 9200002, guid: b8b03d395f5734e98af91ccf44f9bf47, - type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1644755741} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1954690950} m_Enabled: 1 ---- !u!20 &1644755746 +--- !u!20 &1954690955 Camera: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 2000002, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} - m_PrefabInternal: {fileID: 202588249} - m_GameObject: {fileID: 1644755741} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 1954690950} m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -2658,6 +3082,52 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: .5, y: .5} +--- !u!1 &2019452640 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 100008, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + serializedVersion: 4 + m_Component: + - 4: {fileID: 2019452641} + - 114: {fileID: 2019452642} + m_Layer: 0 + m_Name: Head + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2019452641 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 400008, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 2019452640} + 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: 660583660} + - {fileID: 143686266} + m_Father: {fileID: 653490967} + m_RootOrder: 0 +--- !u!114 &2019452642 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11400008, guid: b8b03d395f5734e98af91ccf44f9bf47, + type: 2} + m_PrefabInternal: {fileID: 1073901967} + m_GameObject: {fileID: 2019452640} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3} + m_Name: + m_EditorClassIdentifier: + trackRotation: 1 + trackPosition: 1 + target: {fileID: 0} + updateEarly: 0 --- !u!1 &2022752420 GameObject: m_ObjectHideFlags: 0 @@ -2724,59 +3194,3 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 2022752420} ---- !u!1 &2103211065 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 2103211069} - - 33: {fileID: 2103211068} - - 23: {fileID: 2103211066} - m_Layer: 2 - m_Name: GazePointer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!23 &2103211066 -Renderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2103211065} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_LightmapIndex: 255 - m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} - m_Materials: - - {fileID: 2100000, guid: 9eda0932f25ae41a891d5e59269420a0, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_UseLightProbes: 0 - m_LightProbeAnchor: {fileID: 0} - m_ScaleInLightmap: 1 - m_SortingLayerID: 0 - m_SortingOrder: 0 ---- !u!33 &2103211068 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2103211065} - m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &2103211069 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2103211065} - m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106709} - m_LocalPosition: {x: 0, y: -.99000001, z: 0} - m_LocalScale: {x: .0250000004, y: .0250000004, z: .0250000004} - m_Children: [] - m_Father: {fileID: 1133015247} - m_RootOrder: 0 diff --git a/Cardboard/DemoScene/FPS.cs b/Cardboard/DemoScene/FPS.cs new file mode 100644 index 00000000..7e1a0038 --- /dev/null +++ b/Cardboard/DemoScene/FPS.cs @@ -0,0 +1,33 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; +using UnityEngine.UI; + +[RequireComponent(typeof(Text))] +public class FPS : MonoBehaviour { + private Text text; + private float fps = 60; + + void Awake() { + text = GetComponent(); + } + + void LateUpdate() { + float interp = Time.deltaTime / (0.5f + Time.deltaTime); + float currentFPS = 1.0f / Time.deltaTime; + fps = Mathf.Lerp(fps, currentFPS, interp); + text.text = Mathf.RoundToInt(fps) + "fps"; + } +} diff --git a/Cardboard/DemoScene/GazePointer.mat b/Cardboard/DemoScene/GazePointer.mat index d17ba081..89bf42dc 100644 --- a/Cardboard/DemoScene/GazePointer.mat +++ b/Cardboard/DemoScene/GazePointer.mat @@ -27,6 +27,13 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + data: + first: + name: _Illum + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} m_Floats: data: first: @@ -64,6 +71,10 @@ Material: first: name: _Strength second: .200000003 + data: + first: + name: _EmissionLM + second: 0 m_Colors: data: first: @@ -72,7 +83,7 @@ Material: data: first: name: _SpecColor - second: {r: .501960814, g: .501960814, b: .501960814, a: 1} + second: {r: 0, g: 0, b: 0, a: 1} data: first: name: _Emission diff --git a/Cardboard/Distortion/CardboardDistortion.cginc b/Cardboard/Distortion/CardboardDistortion.cginc new file mode 100644 index 00000000..1fea87b2 --- /dev/null +++ b/Cardboard/Distortion/CardboardDistortion.cginc @@ -0,0 +1,62 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// To use in a surface shader, add the following text to the code: +// +// #pragma surface ... vertex:vert <-- add "vertex:vert" to this line +// #include "CardboardDistortion.cginc" <-- copy the next 4 lines +// void vert (inout appdata_base v) { +// v.vertex = undistortSurface(v.vertex); +// } + +// To use in a vertex shader, modify it as follows: +// +// #include "CardboardDistortion.cginc" <-- add this +// +// v2f vert (appdata_blah v) { +// v2f o; +// o.vertex = undistortVertex(v.vertex); <-- replace "mul(UNITY_MATRIX_MVP, v.vertex)" +// ... +// return o; +// } + +float4 _Undistortion; +float _MaxRadSq; +float _NearClip; +float4x4 _RealProjection; +float4x4 _FixProjection; + +// Convert point from world space to undistorted camera space. +float4 undistort(float4 pos) { + // Go to camera space. + pos = mul(UNITY_MATRIX_MV, pos); + if (pos.z <= -_NearClip) { // Reminder: Forward is -Z. + // Undistort the point's coordinates in XY. + float r2 = clamp(dot(pos.xy, pos.xy) / (pos.z*pos.z), 0, _MaxRadSq); + pos.xy *= 1 + (_Undistortion.x + _Undistortion.y*r2)*r2; + } + return pos; +} + +// Multiply by no-lens projection matrix after undistortion. +float4 undistortVertex(float4 pos) { + return mul(_RealProjection, undistort(pos)); +} + +// Surface shader hides away the MVP multiplication, so we have +// to multiply by _FixProjection = inverse(MVP)*_RealProjection. +float4 undistortSurface(float4 pos) { + return mul(_FixProjection, undistort(pos)); +} diff --git a/Cardboard/Editor/CardboardEditor.cs b/Cardboard/Editor/CardboardEditor.cs index f65c6865..2c93608e 100644 --- a/Cardboard/Editor/CardboardEditor.cs +++ b/Cardboard/Editor/CardboardEditor.cs @@ -13,22 +13,23 @@ // limitations under the License. using UnityEngine; -using UnityEngine.Rendering; using UnityEditor; -using UnityEditor.Callbacks; /// @ingroup EditorScripts /// A custom editor for properties on the Cardboard script. This appears in the /// Inspector window of a Cardboard object. Its purpose is to allow changing the /// `Cardboard.SDK` object's properties from their default values. [CustomEditor(typeof(Cardboard))] -[InitializeOnLoad] public class CardboardEditor : Editor { GUIContent vrModeLabel = new GUIContent("VR Mode Enabled", "Sets whether VR mode is enabled."); GUIContent distortionCorrectionLabel = new GUIContent("Distortion Correction", - "Whether distortion correction is performed the SDK."); + "The distortion correction method performed by the SDK."); + + GUIContent stereoScreenScale = new GUIContent("Stereo Screen Scale", + "The screen resolution is multiplied by this value when creating the " + + "RenderTexture for the stereo screen."); GUIContent autoDriftCorrectionLabel = new GUIContent("Auto Drift Correction", "When enabled, drift in the gyro readings is estimated and removed."); @@ -50,6 +51,9 @@ public class CardboardEditor : Editor { "Google Cardboard app to allow the user to configure their individual " + "settings and Cardboard headset parameters."); + GUIContent backButtonLabel = new GUIContent("Back Button", + "Whether to draw the onscreen Back Button."); + GUIContent tapIsTriggerLabel = new GUIContent("Tap Is Trigger", "Whether screen taps are treated as trigger events."); @@ -65,6 +69,7 @@ public class CardboardEditor : Editor { GUIContent deviceTypeLabel = new GUIContent("Device Type", "The Cardboard device type to emulate."); + /// @cond HIDDEN public override void OnInspectorGUI() { GUI.changed = false; @@ -77,12 +82,28 @@ public override void OnInspectorGUI() { EditorGUILayout.LabelField("General Settings", headingStyle); cardboard.VRModeEnabled = EditorGUILayout.Toggle(vrModeLabel, cardboard.VRModeEnabled); - cardboard.DistortionCorrection = - EditorGUILayout.Toggle(distortionCorrectionLabel, cardboard.DistortionCorrection); - cardboard.AutoDriftCorrection = - EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection); + cardboard.DistortionCorrection = (Cardboard.DistortionCorrectionMethod) + EditorGUILayout.EnumPopup(distortionCorrectionLabel, cardboard.DistortionCorrection); + float oldScale = Cardboard.SDK.StereoScreenScale; + float newScale = EditorGUILayout.Slider(stereoScreenScale, oldScale, 0.25f, 2.0f); + if (!Mathf.Approximately(newScale, oldScale)) { + Cardboard.SDK.StereoScreenScale = newScale; + } cardboard.NeckModelScale = EditorGUILayout.Slider(neckModelScaleLabel, cardboard.NeckModelScale, 0, 1); + cardboard.AutoDriftCorrection = + EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection); + + EditorGUILayout.Separator(); + + EditorGUILayout.LabelField("UI Layer Settings", headingStyle); + cardboard.EnableAlignmentMarker = + EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker); + cardboard.EnableSettingsButton = + EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton); + cardboard.BackButtonMode = (Cardboard.BackButtonModes) + EditorGUILayout.EnumPopup(backButtonLabel, cardboard.BackButtonMode); + EditorGUILayout.Separator(); EditorGUILayout.LabelField("Cardboard Settings", headingStyle); @@ -90,12 +111,9 @@ public override void OnInspectorGUI() { cardboard.SyncWithCardboardApp = EditorGUILayout.Toggle(syncWithCardboardLabel, cardboard.SyncWithCardboardApp); #endif - cardboard.EnableAlignmentMarker = - EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker); - cardboard.EnableSettingsButton = - EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton); cardboard.TapIsTrigger = EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger); + EditorGUILayout.Separator(); EditorGUILayout.LabelField(editorSettingsLabel, headingStyle); @@ -110,39 +128,4 @@ public override void OnInspectorGUI() { EditorUtility.SetDirty(cardboard); } } - - static CardboardEditor() { - EditorUserBuildSettings.activeBuildTargetChanged += CheckGraphicsAPI; - } - - [PostProcessBuild] - public static void CheckGraphicsAPI(BuildTarget target, string path) { - CheckGraphicsAPI(); - } - - private static void CheckGraphicsAPI() { -#if UNITY_IOS -#if UNITY_5 || UNITY_4_6 && !UNITY_4_6_1 && !UNITY_4_6_2 -#if UNITY_5 - var iOSBuildTarget = BuildTarget.iOS; - var iOSGraphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.iOS); - bool isOpenGL = true; - foreach (var device in iOSGraphicsAPIs) { - isOpenGL &= (device == GraphicsDeviceType.OpenGLES2 || device == GraphicsDeviceType.OpenGLES3); - } -#else - var iOSBuildTarget = BuildTarget.iPhone; - bool isOpenGL = PlayerSettings.targetIOSGraphics == TargetIOSGraphics.OpenGLES_2_0 - || PlayerSettings.targetIOSGraphics == TargetIOSGraphics.OpenGLES_3_0; -#endif // UNITY_5 - if (EditorUserBuildSettings.activeBuildTarget == iOSBuildTarget - && !Application.isPlaying - && Object.FindObjectOfType() != null - && !isOpenGL) { - Debug.LogWarning("iOS Graphics API should be set to OpenGL for best " + - "distortion-correction performance in Cardboard."); - } -#endif // UNITY_5 || UNITY_4_6 && !UNITY_4_6_1 && !UNITY_4_6_2 -#endif // UNITY_IOS - } } diff --git a/Cardboard/Editor/StereoControllerEditor.cs b/Cardboard/Editor/StereoControllerEditor.cs index 81a903b1..5ca4377d 100644 --- a/Cardboard/Editor/StereoControllerEditor.cs +++ b/Cardboard/Editor/StereoControllerEditor.cs @@ -30,6 +30,7 @@ public class StereoControllerEditor : Editor { private GUIContent updateButton = new GUIContent(ACTION_NAME, "Copy all Camera settings to the stereo cameras."); + /// @cond HIDDEN public override void OnInspectorGUI() { DrawDefaultInspector(); GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false)); @@ -67,6 +68,7 @@ public static void UpdateStereoCamerasContext(MenuCommand command) { var camera = (Camera)command.context; DoUpdateStereoCameras(camera.gameObject); } + /// @endcond private static bool CanUpdateStereoCameras(GameObject go) { return go != null && @@ -109,7 +111,7 @@ private static void DoUpdateStereoCameras(GameObject go) { // Head. var head = go.GetComponent(); if (head != null && !hadHead) { - Undo.RegisterCreatedObjectUndo(head, ACTION_NAME); + Undo.RegisterCreatedObjectUndo(head, ACTION_NAME); } // Eyes. Synchronizes them with controller's camera too. diff --git a/Cardboard/Legacy/DemoScene/DemoScene.unity b/Cardboard/Legacy/DemoScene/DemoScene.unity index 557e749f..f62c78be 100644 --- a/Cardboard/Legacy/DemoScene/DemoScene.unity +++ b/Cardboard/Legacy/DemoScene/DemoScene.unity @@ -84,7 +84,6 @@ GameObject: m_Component: - 4: {fileID: 136762978} - 20: {fileID: 136762982} - - 92: {fileID: 136762981} - 124: {fileID: 136762980} - 114: {fileID: 136762979} m_Layer: 0 @@ -130,14 +129,6 @@ Behaviour: m_PrefabInternal: {fileID: 1097553059} m_GameObject: {fileID: 136762977} m_Enabled: 1 ---- !u!92 &136762981 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 9232582, guid: a177aba586fa54700a4ceaac810edae9, - type: 2} - m_PrefabInternal: {fileID: 1097553059} - m_GameObject: {fileID: 136762977} - m_Enabled: 1 --- !u!20 &136762982 Camera: m_ObjectHideFlags: 0 @@ -148,7 +139,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -407,12 +398,14 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: directRender: 1 + keepStereoUpdated: 0 stereoMultiplier: 1 matchMonoFOV: 0 matchByZoom: 0 centerOfInterest: {fileID: 0} radiusOfInterest: 0 checkStereoComfort: 1 + stereoAdjustSmoothing: .100000001 screenParallax: 0 stereoPaddingX: 0 stereoPaddingY: 0 @@ -450,7 +443,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -499,7 +492,7 @@ Light: serializedVersion: 3 m_Type: 2 m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Intensity: 3 + m_Intensity: 5 m_Range: 20 m_SpotAngle: 30 m_CookieSize: 10 @@ -535,7 +528,164 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 3 +--- !u!1 &655141886 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 176380, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + serializedVersion: 4 + m_Component: + - 4: {fileID: 655141887} + - 20: {fileID: 655141890} + - 92: {fileID: 655141889} + - 114: {fileID: 655141888} + m_Layer: 0 + m_Name: PostRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &655141887 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 476380, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 655141886} + 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: 1357060799} + m_RootOrder: 1 +--- !u!114 &655141888 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11476382, guid: a177aba586fa54700a4ceaac810edae9, + type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 655141886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3995cc6db284649a793472ad14b220f6, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!92 &655141889 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 9276382, guid: a177aba586fa54700a4ceaac810edae9, + type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 655141886} + m_Enabled: 1 +--- !u!20 &655141890 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2076380, guid: a177aba586fa54700a4ceaac810edae9, + type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 655141886} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 3 + m_BackGroundColor: {r: 1, g: 0, b: 1, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: .5 + m_Depth: 100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!1 &857918618 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 176382, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + serializedVersion: 4 + m_Component: + - 4: {fileID: 857918619} + - 20: {fileID: 857918621} + - 114: {fileID: 857918620} + m_Layer: 0 + m_Name: PreRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &857918619 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 476382, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 857918618} + 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: 1357060799} + m_RootOrder: 0 +--- !u!114 &857918620 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11476380, guid: a177aba586fa54700a4ceaac810edae9, + type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 857918618} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20fb7fbcfb2e642bba6211eb9ea19962, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!20 &857918621 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 2076382, guid: a177aba586fa54700a4ceaac810edae9, + type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 857918618} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 --- !u!1 &955127915 GameObject: m_ObjectHideFlags: 0 @@ -607,7 +757,7 @@ Transform: m_LocalScale: {x: .5, y: .5, z: .5} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 2 --- !u!199 &955127920 ParticleSystemRenderer: m_ObjectHideFlags: 0 @@ -615,8 +765,8 @@ ParticleSystemRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 955127915} m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 m_LightmapIndex: 255 m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0} m_Materials: @@ -895,7 +1045,7 @@ ParticleSystem: minMaxState: 0 gravityModifier: 0 inheritVelocity: 0 - maxNumParticles: 1000 + maxNumParticles: 200 ShapeModule: serializedVersion: 2 enabled: 1 @@ -1771,7 +1921,7 @@ Transform: m_LocalScale: {x: 40, y: .00999999978, z: 40} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 1 --- !u!1001 &1097553059 Prefab: m_ObjectHideFlags: 0 @@ -1809,12 +1959,24 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 432576, guid: a177aba586fa54700a4ceaac810edae9, type: 2} propertyPath: m_RootOrder - value: 3 + value: 0 objectReference: {fileID: 0} - target: {fileID: 432580, guid: a177aba586fa54700a4ceaac810edae9, type: 2} propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} + - target: {fileID: 476378, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 132574, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11432576, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + propertyPath: backButtonMode + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: a177aba586fa54700a4ceaac810edae9, type: 2} m_RootGameObject: {fileID: 1832774123} @@ -1829,7 +1991,6 @@ GameObject: m_Component: - 4: {fileID: 1184624216} - 20: {fileID: 1184624215} - - 92: {fileID: 1184624214} - 124: {fileID: 1184624213} - 114: {fileID: 1184624212} m_Layer: 0 @@ -1863,14 +2024,6 @@ Behaviour: m_PrefabInternal: {fileID: 1097553059} m_GameObject: {fileID: 1184624211} m_Enabled: 1 ---- !u!92 &1184624214 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 9232580, guid: a177aba586fa54700a4ceaac810edae9, - type: 2} - m_PrefabInternal: {fileID: 1097553059} - m_GameObject: {fileID: 1184624211} - m_Enabled: 1 --- !u!20 &1184624215 Camera: m_ObjectHideFlags: 0 @@ -1881,7 +2034,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: .5 @@ -1916,6 +2069,186 @@ Transform: m_Children: [] m_Father: {fileID: 334714609} m_RootOrder: 1 +--- !u!1 &1251376591 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 224: {fileID: 1251376595} + - 222: {fileID: 1251376594} + - 114: {fileID: 1251376593} + - 114: {fileID: 1251376592} + m_Layer: 5 + m_Name: FPS + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1251376592 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1251376591} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 11534fd325088423a9e85baae960115b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1251376593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1251376591} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 30 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 6 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: FPS +--- !u!222 &1251376594 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1251376591} +--- !u!224 &1251376595 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1251376591} + 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: 1492670072} + m_RootOrder: 0 + m_AnchorMin: {x: .5, y: .5} + m_AnchorMax: {x: .5, y: .5} + m_AnchoredPosition: {x: -870, y: -486} + m_SizeDelta: {x: 176, y: 68} + m_Pivot: {x: .5, y: .5} +--- !u!1 &1357060798 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 176378, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1357060799} + m_Layer: 0 + m_Name: Stereo Render + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1357060799 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 476378, guid: a177aba586fa54700a4ceaac810edae9, type: 2} + m_PrefabInternal: {fileID: 1097553059} + m_GameObject: {fileID: 1357060798} + 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: 857918619} + - {fileID: 655141887} + m_Father: {fileID: 1832774124} + m_RootOrder: 2 +--- !u!1 &1492670071 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 224: {fileID: 1492670072} + - 223: {fileID: 1492670074} + - 114: {fileID: 1492670073} + m_Layer: 5 + m_Name: Overlay Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1492670072 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1492670071} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1251376595} + m_Father: {fileID: 0} + m_RootOrder: 4 + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &1492670073 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1492670071} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1920, y: 1080} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1492670074 +Canvas: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1492670071} + m_Enabled: 1 + serializedVersion: 2 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 1 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 --- !u!1 &1754851565 GameObject: m_ObjectHideFlags: 0 @@ -1945,7 +2278,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f06724eec91fb4704a525c71a8e8deea, type: 3} m_Name: m_EditorClassIdentifier: - head: {fileID: 299255874} pointerImage: {fileID: 2800000, guid: 53a9e781f887f46e1817489bff4b661d, type: 3} pointerSize: {x: 8, y: 8} pointerSpot: {x: 4, y: 4} @@ -2003,8 +2335,9 @@ Transform: m_Children: - {fileID: 299255873} - {fileID: 1754851570} + - {fileID: 1357060799} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 0 --- !u!114 &1832774125 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2017,17 +2350,20 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3} m_Name: m_EditorClassIdentifier: - distortionCorrection: 1 vrModeEnabled: 1 + distortionCorrection: 2 enableAlignmentMarker: 1 enableSettingsButton: 1 + backButtonMode: 0 tapIsTrigger: 1 neckModelScale: 1 autoDriftCorrection: 1 + electronicDisplayStabilization: 0 autoUntiltHead: 1 UseUnityRemoteInput: 0 screenSize: 0 deviceType: 0 + stereoScreenScale: 1 --- !u!1 &1944093375 GameObject: m_ObjectHideFlags: 0 diff --git a/Cardboard/Legacy/DemoScene/TeleportLegacyUI.cs b/Cardboard/Legacy/DemoScene/TeleportLegacyUI.cs index fde54b13..067ca631 100644 --- a/Cardboard/Legacy/DemoScene/TeleportLegacyUI.cs +++ b/Cardboard/Legacy/DemoScene/TeleportLegacyUI.cs @@ -16,15 +16,13 @@ using System.Collections; public class TeleportLegacyUI : Teleport { - private CardboardHead head; - void Awake() { - head = Camera.main.GetComponent().Head; CardboardOnGUI.IsGUIVisible = true; CardboardOnGUI.onGUICallback += this.OnGUI; } void Update() { + CardboardHead head = Cardboard.Controller.Head; RaycastHit hit; bool isLookedAt = GetComponent().Raycast(head.Gaze, out hit, Mathf.Infinity); SetGazedAt(isLookedAt); diff --git a/Cardboard/Legacy/Prefabs/CardboardMain.prefab b/Cardboard/Legacy/Prefabs/CardboardMain.prefab index c8acf321..26bffdd2 100644 --- a/Cardboard/Legacy/Prefabs/CardboardMain.prefab +++ b/Cardboard/Legacy/Prefabs/CardboardMain.prefab @@ -62,7 +62,6 @@ GameObject: m_Component: - 4: {fileID: 432578} - 20: {fileID: 2032580} - - 92: {fileID: 9232580} - 124: {fileID: 12432580} - 114: {fileID: 11432578} m_Layer: 0 @@ -81,7 +80,6 @@ GameObject: m_Component: - 4: {fileID: 432582} - 20: {fileID: 2032582} - - 92: {fileID: 9232582} - 124: {fileID: 12432582} - 114: {fileID: 11432582} m_Layer: 0 @@ -91,6 +89,56 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &176378 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 476378} + m_Layer: 0 + m_Name: Stereo Render + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &176380 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 476380} + - 20: {fileID: 2076380} + - 92: {fileID: 9276382} + - 114: {fileID: 11476382} + m_Layer: 0 + m_Name: PostRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &176382 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 476382} + - 20: {fileID: 2076382} + - 114: {fileID: 11476380} + m_Layer: 0 + m_Name: PreRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &432574 Transform: m_ObjectHideFlags: 1 @@ -116,6 +164,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 432580} + - {fileID: 476378} m_Father: {fileID: 0} m_RootOrder: 0 --- !u!4 &432578 @@ -155,6 +204,44 @@ Transform: m_Children: [] m_Father: {fileID: 432574} m_RootOrder: 0 +--- !u!4 &476378 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176378} + 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: 476382} + - {fileID: 476380} + m_Father: {fileID: 432576} + m_RootOrder: 1 +--- !u!4 &476380 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176380} + 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: 476378} + m_RootOrder: 1 +--- !u!4 &476382 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176382} + 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: 476378} + m_RootOrder: 0 --- !u!20 &2032578 Camera: m_ObjectHideFlags: 1 @@ -164,7 +251,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -196,7 +283,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: .5 @@ -228,7 +315,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -251,33 +338,90 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: .0219999999 ---- !u!81 &8132582 -AudioListener: +--- !u!20 &2076380 +Camera: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 132578} + m_GameObject: {fileID: 176380} m_Enabled: 1 ---- !u!92 &9232578 -Behaviour: + serializedVersion: 2 + m_ClearFlags: 3 + m_BackGroundColor: {r: 1, g: 0, b: 1, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: .5 + m_Depth: 100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!20 &2076382 +Camera: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176382} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!81 &8132582 +AudioListener: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 132578} m_Enabled: 1 ---- !u!92 &9232580 +--- !u!92 &9232578 Behaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 132580} + m_GameObject: {fileID: 132578} m_Enabled: 1 ---- !u!92 &9232582 +--- !u!92 &9276382 Behaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 132582} + m_GameObject: {fileID: 176380} m_Enabled: 1 --- !u!114 &11432572 MonoBehaviour: @@ -305,12 +449,14 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: directRender: 1 + keepStereoUpdated: 0 stereoMultiplier: 1 matchMonoFOV: 0 matchByZoom: 0 centerOfInterest: {fileID: 0} radiusOfInterest: 0 checkStereoComfort: 1 + stereoAdjustSmoothing: .100000001 screenParallax: 0 stereoPaddingX: 0 stereoPaddingY: 0 @@ -325,13 +471,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3} m_Name: m_EditorClassIdentifier: - distortionCorrection: 1 vrModeEnabled: 1 + distortionCorrection: 2 enableAlignmentMarker: 1 enableSettingsButton: 1 + backButtonMode: 1 tapIsTrigger: 1 neckModelScale: 1 autoDriftCorrection: 1 + electronicDisplayStabilization: 0 + syncWithCardboardApp: 0 autoUntiltHead: 1 UseUnityRemoteInput: 0 screenSize: 0 @@ -381,6 +530,28 @@ MonoBehaviour: toggleCullingMask: serializedVersion: 2 m_Bits: 0 +--- !u!114 &11476380 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20fb7fbcfb2e642bba6211eb9ea19962, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11476382 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 176380} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3995cc6db284649a793472ad14b220f6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!124 &12432578 Behaviour: m_ObjectHideFlags: 1 diff --git a/Cardboard/Legacy/Scripts/CardboardOnGUI.cs b/Cardboard/Legacy/Scripts/CardboardOnGUI.cs index 2b1e95f3..ec6ffd7d 100644 --- a/Cardboard/Legacy/Scripts/CardboardOnGUI.cs +++ b/Cardboard/Legacy/Scripts/CardboardOnGUI.cs @@ -17,6 +17,7 @@ /// @ingroup LegacyScripts /// A utility class for redirecting OnGUI()-based UI elements onto a texture, /// which can be drawn on a surface in the scene and thus appear in stereo. +/// /// The auxiliary CardboardOnGUIWindow class handles displaying the texture /// in the scene. CardboardOnGUI captures the OnGUI() calls, which need to be /// modified slightly for this to work, and handles feeding back fake mouse diff --git a/Cardboard/Legacy/Scripts/CardboardOnGUIMouse.cs b/Cardboard/Legacy/Scripts/CardboardOnGUIMouse.cs index efdfeaef..c8bd02f5 100644 --- a/Cardboard/Legacy/Scripts/CardboardOnGUIMouse.cs +++ b/Cardboard/Legacy/Scripts/CardboardOnGUIMouse.cs @@ -16,20 +16,13 @@ using System.Collections; /// @ingroup LegacyScripts -/// Attach this script to the same object as CardboardOnGUI itself. It can draw a -/// cursor image into the GUI texture to show the location of the mouse pointer. It +/// This script shows the location of the mouse pointer on the GUI texture. +/// +/// Attach this script to the same object as CardboardOnGUI itself. It /// supports moving the mouse with the user's gaze, and clicking on the UI with the /// trigger, but other mouse-controlling devices, such as gamepads, will work as well. public class CardboardOnGUIMouse : MonoBehaviour { - /// If the app supports the use of some other pointing device, e.g. a gamepad - /// or bluetooth mouse, then this field can be left null. When set to a - /// CardboardHead instance, then the user's head in effect becomes the mouse - /// pointer and the Cardboard trigger becomes the mouse button. The user - /// looks at a GUI button and pulls the trigger to click it. - [Tooltip("The CardboardHead which drives the simulated mouse.")] - public CardboardHead head; - /// The image to draw into the captured GUI texture representing the current /// pointer position. [Tooltip("What to draw on the GUI surface for the simulated mouse pointer.")] @@ -56,6 +49,8 @@ public class CardboardOnGUIMouse : MonoBehaviour { private int pointerY; void LateUpdate() { + StereoController controller = Cardboard.Controller; + CardboardHead head = controller ? controller.Head : null; if (head == null) { // Pointer not being controlled by user's head, so we bail. pointerVisible = true; // Draw pointer wherever Unity thinks the mouse is. return; @@ -96,7 +91,7 @@ void LateUpdate() { pointerVisible = true; } - // Draw the fake mouse pointer. Called by CardboardOnGUI after the rest of the UI is done. + /// Draw the fake mouse pointer. Called by CardboardOnGUI after the rest of the UI is done. public void DrawPointerImage() { if (pointerImage == null || !pointerVisible || !enabled) { return; diff --git a/Cardboard/Legacy/Scripts/CardboardOnGUIWindow.cs b/Cardboard/Legacy/Scripts/CardboardOnGUIWindow.cs index 096d5329..7d0e91db 100644 --- a/Cardboard/Legacy/Scripts/CardboardOnGUIWindow.cs +++ b/Cardboard/Legacy/Scripts/CardboardOnGUIWindow.cs @@ -16,12 +16,12 @@ /// @ingroup LegacyScripts /// Works with CardboardOnGUI to show all or part of the OnGUI-rendered -/// UI on a mesh in the scene. There should be one or more of these -/// as children of the CardboardOnGUI gameobject. Each one specifies -/// the region of the captured OnGUI screen to show on its own mesh. -/// This allows you to place pieces of the GUI in the scene at different -/// distances and angles to the user without having to change any of the -/// OnGUI methods themselves. +/// UI on a mesh in the scene. +/// +/// There should be one or more of these as children of the CardboardOnGUI gameobject. +/// Each one specifies the region of the captured OnGUI screen to show on its own mesh. +/// This allows you to place pieces of the GUI in the scene at different distances and angles +/// to the user without having to change any of the OnGUI methods themselves. /// /// Each instance can pick out a different region of the GUI texture to show (see /// #rect). Use the object's transform to position and orient this region in @@ -48,10 +48,6 @@ public class CardboardOnGUIWindow : MonoBehaviour { private MeshRenderer meshRenderer; - void Reset() { - rect = new Rect(0,0,1,1); // Make window show the full GUI screen. - } - /// Determines the portion of the CardboardOnGUI texture to draw on the attached /// mesh. The units are exactly the same as a Camera component's `Viewport Rect`: /// `(0,0)` is the bottom left corner and `(1,1)` the top right. Use it to pick out @@ -67,6 +63,10 @@ void Awake() { } } + void Reset() { + rect = new Rect(0,0,1,1); // Make window show the full GUI screen. + } + /// Make a material that points to the target texture. Texture scale /// and offset will be controlled by #rect. public void Create(RenderTexture target) { diff --git a/Cardboard/Legacy/Scripts/LegacyCardboardAndroidDevice.cs b/Cardboard/Legacy/Scripts/LegacyCardboardAndroidDevice.cs deleted file mode 100644 index e6031ac4..00000000 --- a/Cardboard/Legacy/Scripts/LegacyCardboardAndroidDevice.cs +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if UNITY_ANDROID - -using System.Runtime.InteropServices; -using UnityEngine; - -// Android device using the Google Cardboard SDK for Android. -public class LegacyCardboardAndroidDevice : BaseAndroidDevice { - [DllImport("RenderingPlugin")] - private static extern void InitFromUnity(int textureID); - - // Event IDs supported by our native render plugin. - private const int kPerformDistortionCorrection = 1; - private const int kDrawCardboardUILayer = 2; - - private const string cardboardClass = - "com.google.vrtoolkit.cardboard.plugins.unity.UnityCardboardActivity"; - - private Matrix4x4 headView = new Matrix4x4(); - private Matrix4x4 leftEyeView = new Matrix4x4(); - private Matrix4x4 rightEyeView = new Matrix4x4(); - - private float[] frameInfo = null; - - public override void Init() { - ConnectToActivity(); - } - - protected override void ConnectToActivity() { - try { - using (AndroidJavaClass player = new AndroidJavaClass(cardboardClass)) { - androidActivity = player.CallStatic("getActivity"); - } - } catch (AndroidJavaException e) { - androidActivity = null; - Debug.LogError("Cannot access UnityCardboardActivity. " - + "Verify that the jar is in Assets/Plugins/Android. " + e); - } - } - - public override void SetDistortionCorrectionEnabled(bool enabled) { - CallObjectMethod(androidActivity, "setDistortionCorrectionEnabled", enabled); - } - - public override void SetVRModeEnabled(bool enabled) { - CallObjectMethod(androidActivity, "setVRModeEnabled", enabled); - } - - public override void SetAlignmentMarkerEnabled(bool enabled) { - CallObjectMethod(androidActivity, "setAlignmentMarkerEnabled", enabled); - } - - public override void SetSettingsButtonEnabled(bool enabled) { - CallObjectMethod(androidActivity, "setSettingsButtonEnabled", enabled); - } - - public override void SetTapIsTrigger(bool enabled) { - CallObjectMethod(androidActivity, "setTapIsTrigger", enabled); - } - - public override void SetNeckModelScale(float scale) { - CallObjectMethod(androidActivity, "setNeckModelFactor", scale); - } - - public override void SetAutoDriftCorrectionEnabled(bool enabled) { - CallObjectMethod(androidActivity, "setGyroBiasEstimationEnabled", enabled); - } - - public override void SetStereoScreen(RenderTexture stereoScreen) { - if (androidActivity != null) { - InitFromUnity(stereoScreen != null ? stereoScreen.GetNativeTextureID() : 0); - } - } - - public override void UpdateState() { - // Pass nominal clip distances - will correct later for each camera. - if (!CallObjectMethod(ref frameInfo, androidActivity, "getFrameParams", 1.0f /* near */, 1000.0f /* far */)) { - return; - } - - // Extract the matrices (currently that's all we get back). - int j = 0; - for (int i = 0; i < 16; ++i, ++j) { - headView[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - leftEyeView[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - leftEyeDistortedProjection[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - rightEyeView[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - rightEyeDistortedProjection[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - leftEyeUndistortedProjection[i] = frameInfo[j]; - } - for (int i = 0; i < 16; ++i, ++j) { - rightEyeUndistortedProjection[i] = frameInfo[j]; - } - - leftEyeUndistortedViewport = new Rect(frameInfo[j], frameInfo[j+1], - frameInfo[j+2], frameInfo[j+3]); - leftEyeDistortedViewport = leftEyeUndistortedViewport; - j += 4; - rightEyeUndistortedViewport = new Rect(frameInfo[j], frameInfo[j+1], - frameInfo[j+2], frameInfo[j+3]); - rightEyeDistortedViewport = rightEyeUndistortedViewport; - - // Convert views to left-handed coordinates because Unity uses them - // for Transforms, which is what we will update from the views. - // Also invert because the incoming matrices go from camera space to - // cardboard space, and we want the opposite. - // Lastly, cancel out the head rotation from the eye views, - // because we are applying that on a parent object. - leftEyePose.SetRightHanded(headView * leftEyeView.inverse); - rightEyePose.SetRightHanded(headView * rightEyeView.inverse); - headPose.SetRightHanded(headView.inverse); - } - - override public void UpdateScreenData() { - CardboardProfile.Device device = new CardboardProfile.Device(); - CardboardProfile.Screen screen = new CardboardProfile.Screen(); - - float[] lensData = null; - if (CallObjectMethod(ref lensData, androidActivity, "getLensParameters")) { - device.lenses.separation = lensData[0]; - device.lenses.offset = lensData[1]; - device.lenses.screenDistance = lensData[2]; - device.lenses.alignment = (int)lensData[3]; - } - - float[] screenSize = null; - if (CallObjectMethod(ref screenSize, androidActivity, "getScreenSizeMeters")) { - screen.width = screenSize[0]; - screen.height = screenSize[1]; - screen.border = screenSize[2]; - } - - float[] distCoeff = null; - if (CallObjectMethod(ref distCoeff, androidActivity, "getDistortionCoefficients")) { - device.distortion.k1 = distCoeff[0]; - device.distortion.k2 = distCoeff[1]; - } - - float[] invDistCoeff = null; - if (CallObjectMethod(ref invDistCoeff, androidActivity, "getInverseDistortionCoefficients")) { - device.inverse.k1 = invDistCoeff[0]; - device.inverse.k2 = invDistCoeff[1]; - } - - float[] maxFov = null; - if (CallObjectMethod(ref maxFov, androidActivity, "getLeftEyeMaximumFOV")) { - device.maxFOV.outer = maxFov[0]; - device.maxFOV.upper = maxFov[1]; - device.maxFOV.inner = maxFov[2]; - device.maxFOV.lower = maxFov[3]; - } - - Profile.screen = screen; - Profile.device = device; - } - - public override void Recenter() { - CallObjectMethod(androidActivity, "resetHeadTracker"); - } - - public override void SetTouchCoordinates(int x, int y) { - CallObjectMethod(androidActivity, "setTouchCoordinates", x, y); - } - - public override void PostRender(bool vrMode) { - if (vrMode) { - if (Cardboard.SDK.DistortionCorrection && Cardboard.SDK.NativeDistortionCorrectionSupported) { - GL.IssuePluginEvent(kPerformDistortionCorrection); - } - if (Cardboard.SDK.EnableAlignmentMarker || Cardboard.SDK.EnableSettingsButton) { - GL.IssuePluginEvent(kDrawCardboardUILayer); - } - GL.InvalidateState(); - } - } -} - -#endif diff --git a/Cardboard/Legacy/Scripts/SkyboxMesh.cs b/Cardboard/Legacy/Scripts/SkyboxMesh.cs index 7e722053..d4b793fa 100755 --- a/Cardboard/Legacy/Scripts/SkyboxMesh.cs +++ b/Cardboard/Legacy/Scripts/SkyboxMesh.cs @@ -24,6 +24,8 @@ using UnityEngine; /// @ingroup LegacyScripts +/// This script builds a stereo correct version of the skybox. +/// /// Unity 4's built-in skybox backgrounds do not work correctly for stereo rendering. /// Since the same exact image is rendered to each eye, the background has zero /// parallax. Given the optics of Cardboard, this yields an effective stereo depth diff --git a/Cardboard/Legacy/Scripts/StereoLensFlare.cs b/Cardboard/Legacy/Scripts/StereoLensFlare.cs index 68fcfbf0..f69b6adf 100644 --- a/Cardboard/Legacy/Scripts/StereoLensFlare.cs +++ b/Cardboard/Legacy/Scripts/StereoLensFlare.cs @@ -16,9 +16,11 @@ using System.Collections; /// @ingroup LegacyScripts +/// +/// This script can be attached to a Lens Flare to make it stereo-aware in Directional mode. +/// /// Unity 4's built-in lens flares do not work correctly for stereo rendering when in -/// Directional mode, for similar reasons as the skybox mentioned previously. This -/// script can be attached to a Lens Flare to make it stereo-aware directional. +/// Directional mode, for similar reasons as the skybox. /// /// To use it, add the script to a Lens Flare and clear the flare's Directional flag /// so that the flare is actually positional. This script keeps the flare at a diff --git a/Cardboard/Package.md b/Cardboard/Package.md index 5b82f541..c6280e0c 100644 --- a/Cardboard/Package.md +++ b/Cardboard/Package.md @@ -5,10 +5,12 @@ The Unity plugin package contains the following: * _Cardboard.cs_ - Singleton connection to the native code VR device. * _CardboardEye.cs_ - Applies an eye view/projection to a stereo camera. * _CardboardHead.cs_ - Applies the Cardboard head view to its transform. +* _CardboardPreRender.cs_ - Clears entire frame in VR mode. +* _CardboardPostRender.cs_ - Applies distortion correction in VR mode. * _GazeInputModule.cs_ - Control uGUI elements with gaze and trigger. * _Pose3D.cs_ - Contains a rotation and translation. -* _RadialUndistortionEffect.cs_ - Image Effect simulating distortion correction. * _StereoController.cs_ - Controls mono vs stereo rendering. +* _StereoRenderEffect.cs_ - Handles the non-Direct-Render pass for stereo Image Effects. **Editor Scripts** @@ -17,13 +19,14 @@ The Unity plugin package contains the following: **Prefabs** +* _CardboardCamera.prefab - Handles whole frame clearing and distortion correction in Unity. * _CardboardMain.prefab_ - A drop-in replacement for a Main Camera object. * _CardboardHead.prefab_ - A drop-in replacement for other cameras. * _CardboardAdapter.prefab_ - Adds stereo rendering to an existing camera. **Shaders** -* _RadialUndistortionEffect.cs_ - Shader for simulating distortion correction. +* _UnlitTexture.shader_ - Draw the distortion mesh with the rendered scene. **Demo** diff --git a/Cardboard/Prefabs/CardboardAdapter.prefab b/Cardboard/Prefabs/CardboardAdapter.prefab index aa3fd914..b70e443e 100644 --- a/Cardboard/Prefabs/CardboardAdapter.prefab +++ b/Cardboard/Prefabs/CardboardAdapter.prefab @@ -9,7 +9,6 @@ GameObject: m_Component: - 4: {fileID: 400000} - 20: {fileID: 2000000} - - 92: {fileID: 9200000} - 124: {fileID: 12400000} - 114: {fileID: 11400000} m_Layer: 0 @@ -28,7 +27,6 @@ GameObject: m_Component: - 4: {fileID: 400002} - 20: {fileID: 2000002} - - 92: {fileID: 9200002} - 124: {fileID: 12400002} - 114: {fileID: 11400002} m_Layer: 0 @@ -156,20 +154,6 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: .0219999999 ---- !u!92 &9200000 -Behaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100000} - m_Enabled: 1 ---- !u!92 &9200002 -Behaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100002} - m_Enabled: 1 --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 1 @@ -182,6 +166,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: eye: 1 + toggleCullingMask: + serializedVersion: 2 + m_Bits: 0 --- !u!114 &11400002 MonoBehaviour: m_ObjectHideFlags: 1 @@ -194,6 +181,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: eye: 0 + toggleCullingMask: + serializedVersion: 2 + m_Bits: 0 --- !u!114 &11400004 MonoBehaviour: m_ObjectHideFlags: 1 @@ -205,6 +195,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3} m_Name: m_EditorClassIdentifier: + trackRotation: 1 + trackPosition: 1 target: {fileID: 0} updateEarly: 0 --- !u!124 &12400000 diff --git a/Cardboard/Prefabs/CardboardCamera.prefab b/Cardboard/Prefabs/CardboardCamera.prefab new file mode 100644 index 00000000..45896d06 --- /dev/null +++ b/Cardboard/Prefabs/CardboardCamera.prefab @@ -0,0 +1,195 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &113102 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 413102} + - 20: {fileID: 2013102} + - 114: {fileID: 11413102} + m_Layer: 0 + m_Name: PreRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &113104 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 413104} + - 20: {fileID: 2013104} + - 92: {fileID: 9213102} + - 114: {fileID: 11413104} + m_Layer: 0 + m_Name: PostRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &113106 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 413106} + m_Layer: 0 + m_Name: CardboardCamera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &413102 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113102} + 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: 413106} + m_RootOrder: 0 +--- !u!4 &413104 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113104} + 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: 413106} + m_RootOrder: 1 +--- !u!4 &413106 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113106} + 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: 413102} + - {fileID: 413104} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!20 &2013102 +Camera: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113102} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!20 &2013104 +Camera: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113104} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 3 + m_BackGroundColor: {r: 1, g: 0, b: 1, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: .5 + m_Depth: 100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!92 &9213102 +Behaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113104} + m_Enabled: 1 +--- !u!114 &11413102 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113102} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20fb7fbcfb2e642bba6211eb9ea19962, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11413104 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 113104} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3995cc6db284649a793472ad14b220f6, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !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: 113106} + m_IsPrefabParent: 1 + m_IsExploded: 1 diff --git a/Cardboard/Prefabs/CardboardHead.prefab b/Cardboard/Prefabs/CardboardHead.prefab index 063d89dd..5b7870d9 100644 --- a/Cardboard/Prefabs/CardboardHead.prefab +++ b/Cardboard/Prefabs/CardboardHead.prefab @@ -9,7 +9,6 @@ GameObject: m_Component: - 4: {fileID: 400000} - 20: {fileID: 2000000} - - 92: {fileID: 9200000} - 124: {fileID: 12400000} - 114: {fileID: 11400000} m_Layer: 0 @@ -28,7 +27,6 @@ GameObject: m_Component: - 4: {fileID: 400002} - 20: {fileID: 2000002} - - 92: {fileID: 9200002} - 124: {fileID: 12400002} - 114: {fileID: 11400002} m_Layer: 0 @@ -64,7 +62,7 @@ GameObject: - 4: {fileID: 400006} - 20: {fileID: 2000004} - 124: {fileID: 12400004} - - 92: {fileID: 9200004} + - 92: {fileID: 9246874} - 81: {fileID: 8100000} - 114: {fileID: 11400006} m_Layer: 0 @@ -228,21 +226,7 @@ AudioListener: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 100006} m_Enabled: 1 ---- !u!92 &9200000 -Behaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100000} - m_Enabled: 1 ---- !u!92 &9200002 -Behaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100002} - m_Enabled: 1 ---- !u!92 &9200004 +--- !u!92 &9246874 Behaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -261,6 +245,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: eye: 1 + toggleCullingMask: + serializedVersion: 2 + m_Bits: 0 --- !u!114 &11400002 MonoBehaviour: m_ObjectHideFlags: 1 @@ -273,6 +260,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: eye: 0 + toggleCullingMask: + serializedVersion: 2 + m_Bits: 0 --- !u!114 &11400004 MonoBehaviour: m_ObjectHideFlags: 1 @@ -284,6 +274,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f1578549c7fcc4f6fa1b063992091672, type: 3} m_Name: m_EditorClassIdentifier: + trackRotation: 1 + trackPosition: 1 target: {fileID: 0} updateEarly: 0 --- !u!114 &11400006 @@ -298,11 +290,14 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: directRender: 1 + keepStereoUpdated: 0 stereoMultiplier: 1 matchMonoFOV: 0 + matchByZoom: 0 centerOfInterest: {fileID: 0} radiusOfInterest: 0 checkStereoComfort: 1 + stereoAdjustSmoothing: .100000001 screenParallax: 0 stereoPaddingX: 0 stereoPaddingY: 0 diff --git a/Cardboard/Prefabs/CardboardMain.prefab b/Cardboard/Prefabs/CardboardMain.prefab index df030753..11683761 100644 --- a/Cardboard/Prefabs/CardboardMain.prefab +++ b/Cardboard/Prefabs/CardboardMain.prefab @@ -9,7 +9,6 @@ GameObject: m_Component: - 4: {fileID: 400000} - 20: {fileID: 2000000} - - 92: {fileID: 9200000} - 124: {fileID: 12400000} - 114: {fileID: 11400002} m_Layer: 0 @@ -28,7 +27,6 @@ GameObject: m_Component: - 4: {fileID: 400002} - 20: {fileID: 2000002} - - 92: {fileID: 9200002} - 124: {fileID: 12400002} - 114: {fileID: 11400004} m_Layer: 0 @@ -90,6 +88,56 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &150430 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 450430} + m_Layer: 0 + m_Name: Stereo Render + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &150432 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 450432} + - 20: {fileID: 2050432} + - 92: {fileID: 9250434} + - 114: {fileID: 11450432} + m_Layer: 0 + m_Name: PostRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &150434 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 450434} + - 20: {fileID: 2050434} + - 114: {fileID: 11450434} + m_Layer: 0 + m_Name: PreRender + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &400000 Transform: m_ObjectHideFlags: 1 @@ -125,6 +173,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 400008} + - {fileID: 450430} m_Father: {fileID: 0} m_RootOrder: 0 --- !u!4 &400006 @@ -154,6 +203,44 @@ Transform: - {fileID: 400006} m_Father: {fileID: 400004} m_RootOrder: 0 +--- !u!4 &450430 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150430} + 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: 450434} + - {fileID: 450432} + m_Father: {fileID: 400004} + m_RootOrder: 1 +--- !u!4 &450432 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150432} + 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: 450430} + m_RootOrder: 1 +--- !u!4 &450434 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150434} + 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: 450430} + m_RootOrder: 0 --- !u!20 &2000000 Camera: m_ObjectHideFlags: 1 @@ -163,7 +250,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: .5 @@ -195,7 +282,7 @@ Camera: m_Enabled: 0 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -227,7 +314,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: 1} m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -250,26 +337,76 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: .0219999999 ---- !u!81 &8100000 -AudioListener: +--- !u!20 &2050432 +Camera: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100006} + m_GameObject: {fileID: 150432} m_Enabled: 1 ---- !u!92 &9200000 -Behaviour: + serializedVersion: 2 + m_ClearFlags: 3 + m_BackGroundColor: {r: 1, g: 0, b: 1, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: .5 + m_Depth: 100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!20 &2050434 +Camera: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100000} + m_GameObject: {fileID: 150434} m_Enabled: 1 ---- !u!92 &9200002 -Behaviour: + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -100 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!81 &8100000 +AudioListener: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 100002} + m_GameObject: {fileID: 100006} m_Enabled: 1 --- !u!92 &9200004 Behaviour: @@ -278,6 +415,13 @@ Behaviour: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 100006} m_Enabled: 1 +--- !u!92 &9250434 +Behaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150432} + m_Enabled: 1 --- !u!114 &11400002 MonoBehaviour: m_ObjectHideFlags: 1 @@ -320,12 +464,14 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: directRender: 1 + keepStereoUpdated: 0 stereoMultiplier: 1 matchMonoFOV: 0 matchByZoom: 0 centerOfInterest: {fileID: 0} radiusOfInterest: 0 checkStereoComfort: 1 + stereoAdjustSmoothing: .100000001 screenParallax: 0 stereoPaddingX: 0 stereoPaddingY: 0 @@ -355,17 +501,42 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a40b544b8c3553c40852ae7ad35a9343, type: 3} m_Name: m_EditorClassIdentifier: - distortionCorrection: 1 vrModeEnabled: 1 + distortionCorrection: 2 enableAlignmentMarker: 1 enableSettingsButton: 1 + backButtonMode: 1 tapIsTrigger: 1 neckModelScale: 1 autoDriftCorrection: 1 + electronicDisplayStabilization: 0 + syncWithCardboardApp: 0 autoUntiltHead: 1 UseUnityRemoteInput: 0 screenSize: 0 deviceType: 0 +--- !u!114 &11450432 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150432} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3995cc6db284649a793472ad14b220f6, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11450434 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150434} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20fb7fbcfb2e642bba6211eb9ea19962, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!124 &12400000 Behaviour: m_ObjectHideFlags: 1 diff --git a/Cardboard/Prefabs/Prefabs.md b/Cardboard/Prefabs/Prefabs.md index d4c236a0..74c4662d 100644 --- a/Cardboard/Prefabs/Prefabs.md +++ b/Cardboard/Prefabs/Prefabs.md @@ -2,6 +2,31 @@ This section describes the prefabs that are provided by the package. +## CardboardCamera + +This prefab simply contains an instance of the _%CardboardPreRender_ script and +an instance of the _%CardboardPostRender_ script, and a _Camera_ component for +each. + +The CardboardPreRender script is drawn before any stereo rendering occurs. It's +primary job is to clear the full screen, since in VR mode, the stereo cameras don't +always fill the entire frame. + +The CardboardPostRender script is more substantial. It is the last Camera to draw +during Unity's rendering pipeline. It's primary purpose is to now manage distortion +correction. When the new in-Unity distortion method is active, it renders a +predistorted mesh with the stereo screen as its texture. If the old native C++ +distortion method is active, it simply defers this activity to the native plugin. + +Since CardboardPostRender now occurs during the normal Camera rendering phase, any +Screen Space Overlay canvases will be drawn on top of it rather than being covered +up as in prior versions of the SDK. + +This prefab is bundled in the _CardboardMain_ prefab. It is also generated at runtime +automatically if one doesn't exist. You only need to manually include this in the +scene if you are _not_ using _CardboardMain_, and you wish to edit the Camera +component's settings in the Unity editor. + ## CardboardMain This prefab is intended to be a drop-in replacement for a normal Unity camera, diff --git a/Cardboard/Resources/CardboardSettingsButton.png.bytes b/Cardboard/Resources/CardboardSettingsButton.png.bytes deleted file mode 100644 index eabb0a2b..00000000 Binary files a/Cardboard/Resources/CardboardSettingsButton.png.bytes and /dev/null differ diff --git a/Cardboard/Legacy/Resources/SkyboxMesh.shader b/Cardboard/Resources/SkyboxMesh.shader similarity index 97% rename from Cardboard/Legacy/Resources/SkyboxMesh.shader rename to Cardboard/Resources/SkyboxMesh.shader index 3a70eae9..0915df33 100644 --- a/Cardboard/Legacy/Resources/SkyboxMesh.shader +++ b/Cardboard/Resources/SkyboxMesh.shader @@ -26,8 +26,10 @@ Shader "Cardboard/SkyboxMesh" { Category { Tags { "Queue"="Background" } ZWrite Off + ZTest Always Lighting Off Fog {Mode Off} + Cull Off BindChannels { Bind "Color", color Bind "Vertex", vertex diff --git a/Cardboard/Resources/SolidColor.shader b/Cardboard/Resources/SolidColor.shader index 84473874..94d2215d 100644 --- a/Cardboard/Resources/SolidColor.shader +++ b/Cardboard/Resources/SolidColor.shader @@ -17,6 +17,10 @@ Shader "Cardboard/SolidColor" { _Color ("Main Color", COLOR) = (1,1,1,1) } SubShader { - Pass { Color [_Color] } + Pass { + ZWrite Off + ZTest Always + Color [_Color] + } } } \ No newline at end of file diff --git a/Cardboard/Resources/UnlitTexture.shader b/Cardboard/Resources/UnlitTexture.shader new file mode 100644 index 00000000..bfe8a9df --- /dev/null +++ b/Cardboard/Resources/UnlitTexture.shader @@ -0,0 +1,43 @@ +// Copyright 2014 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. + +// Original code by Nora +// http://stereoarts.jp +// +// Retrieved from: +// https://developer.oculusvr.com/forums/viewtopic.php?f=37&t=844#p28982 + +Shader "Cardboard/UnlitTexture" { + Properties { + _MainTex ("Texture", 2D) = "white" {} + } + Category { + Tags { "RenderType" = "Opaque" } + Cull Off + Lighting Off + Fog {Mode Off} + BindChannels { + Bind "Color", color + Bind "Vertex", vertex + Bind "TexCoord", texcoord + } + SubShader { + Pass { + SetTexture [_MainTex] { + Combine primary * texture + } + } + } + } +} diff --git a/Cardboard/Scripts/Cardboard.cs b/Cardboard/Scripts/Cardboard.cs index e57f4d78..5a7dcb73 100644 --- a/Cardboard/Scripts/Cardboard.cs +++ b/Cardboard/Scripts/Cardboard.cs @@ -18,17 +18,19 @@ using System.Collections.Generic; /// @ingroup Scripts +/// This class is the main Cardboard SDK object. +/// /// The Cardboard object communicates with the head-mounted display in order to: /// - Query the device for viewing parameters /// - Retrieve the latest head tracking data /// - Provide the rendered scene to the device for distortion correction /// -/// There should only be one of these in a scene. An instance will be generated -/// at runtime if needed, or you can add one via the Editor if you wish to customize +/// There should only be one of these in a scene. An instance will be generated automatically +/// by this script at runtime, or you can add one via the Editor if you wish to customize /// its starting properties. public class Cardboard : MonoBehaviour { /// The singleton instance of the Cardboard class. - /// Not null: the instance is created on demand if not already present. + /// Not null: the instance is created automatically on demand if not already present. public static Cardboard SDK { get { if (sdk == null) { @@ -45,24 +47,23 @@ public static Cardboard SDK { } private static Cardboard sdk = null; - /// Whether distortion correction is performed by the plugin. If disabled, then it is - /// up to the app to perform whatever distortion correction it would like, if any. - public bool DistortionCorrection { + /// The StereoController instance attached to the main camera, or null if there is none. + public static StereoController Controller { get { - return distortionCorrection; - } - set { - if (value != distortionCorrection && device != null) { - device.SetDistortionCorrectionEnabled(value && NativeDistortionCorrectionSupported); + Camera camera = Camera.main; + // Cache for performance, if possible. + if (camera != currentMainCamera || currentController == null) { + currentMainCamera = camera; + currentController = camera.GetComponent(); } - distortionCorrection = value; + return currentController; } } - [SerializeField] - private bool distortionCorrection = true; + private static Camera currentMainCamera; + private static StereoController currentController; - /// Determine whether the scene renders in stereo or mono. Assign to this field - /// to control stereo/mono mode yourself. + /// Determine whether the scene renders in stereo or mono. + /// True means to render in stereo, and false means to render in mono. public bool VRModeEnabled { get { return vrModeEnabled; @@ -77,6 +78,28 @@ public bool VRModeEnabled { [SerializeField] private bool vrModeEnabled = true; + public enum DistortionCorrectionMethod { + None, + Native, + Unity, + } + + public DistortionCorrectionMethod DistortionCorrection { + get { + return distortionCorrection; + } + set { + if (value != distortionCorrection && device != null) { + device.SetDistortionCorrectionEnabled(value == DistortionCorrectionMethod.Native + && NativeDistortionCorrectionSupported); + device.UpdateScreenData(); + } + distortionCorrection = value; + } + } + [SerializeField] + private DistortionCorrectionMethod distortionCorrection = DistortionCorrectionMethod.Unity; + /// Enables or disables the vertical line rendered between the stereo views to /// help the user align the Cardboard to the phone's screen. public bool EnableAlignmentMarker { @@ -85,7 +108,7 @@ public bool EnableAlignmentMarker { } set { if (value != enableAlignmentMarker && device != null) { - device.SetAlignmentMarkerEnabled(value && NativeUILayerSupported); + device.SetAlignmentMarkerEnabled(value); } enableAlignmentMarker = value; } @@ -111,6 +134,28 @@ public bool EnableSettingsButton { [SerializeField] private bool enableSettingsButton = true; + public enum BackButtonModes { + Off, + OnlyInVR, + On + } + + /// Whether to show the onscreen analog of the (Android) Back Button. + public BackButtonModes BackButtonMode { + get { + return backButtonMode; + } + set { + if (value != backButtonMode && device != null) { + device.SetVRBackButtonEnabled(value != BackButtonModes.Off); + device.SetShowVrBackButtonOnlyInVR(value == BackButtonModes.OnlyInVR); + } + backButtonMode = value; + } + } + [SerializeField] + private BackButtonModes backButtonMode = BackButtonModes.OnlyInVR; + /// When enabled, Cardboard treats a screen tap the same as a trigger pull. public bool TapIsTrigger { get { @@ -161,7 +206,25 @@ public bool AutoDriftCorrection { [SerializeField] private bool autoDriftCorrection = true; + + /// When enabled, drift in the gyro readings is estimated and removed. + public bool ElectronicDisplayStabilization { + get { + return electronicDisplayStabilization; + } + set { + if (value != electronicDisplayStabilization && device != null) { + device.SetElectronicDisplayStabilizationEnabled(value); + } + electronicDisplayStabilization = value; + } + } + [SerializeField] + private bool electronicDisplayStabilization = false; + #if UNITY_IOS + /// Whether to show an option to sync settings with the Cardboard App in the + /// settings dialogue for iOS devices. public bool SyncWithCardboardApp { get { return syncWithCardboardApp; @@ -187,6 +250,7 @@ public bool SyncWithCardboardApp { [HideInInspector] public bool UseUnityRemoteInput = false; + /// The screen size to emulate when testing in the Unity Editor. public CardboardProfile.ScreenSizes ScreenSize { get { return screenSize; @@ -203,6 +267,7 @@ public CardboardProfile.ScreenSizes ScreenSize { [SerializeField] private CardboardProfile.ScreenSizes screenSize = CardboardProfile.ScreenSizes.Nexus5; + /// The device type to emulate when testing in the Unity Editor. public CardboardProfile.DeviceTypes DeviceType { get { return deviceType; @@ -217,26 +282,45 @@ public CardboardProfile.DeviceTypes DeviceType { } } [SerializeField] - public CardboardProfile.DeviceTypes deviceType = CardboardProfile.DeviceTypes.CardboardJun2014; + private CardboardProfile.DeviceTypes deviceType = CardboardProfile.DeviceTypes.CardboardJun2014; #endif - /// The VR device that will be providing input data. + // The VR device that will be providing input data. private static BaseVRDevice device; + /// Whether native distortion correction functionality is supported by the VR device. public bool NativeDistortionCorrectionSupported { get; private set; } + /// Whether the VR device supports showing a native UI layer, for example for settings. public bool NativeUILayerSupported { get; private set; } + public float StereoScreenScale { + get { + return stereoScreenScale; + } + set { + value = Mathf.Clamp(value, 0.1f, 10.0f); // Sanity. + if (stereoScreenScale != value) { + stereoScreenScale = value; + StereoScreen = null; + } + } + } + [SerializeField] + private float stereoScreenScale = 1; + /// The texture that Unity renders the scene to. This is sent to the VR device, - /// which renders it to screen, correcting for lens distortion. + /// which renders it to screen, correcting for lens distortion if native distortion + /// correction is supported. public RenderTexture StereoScreen { get { // Don't need it except for distortion correction. - if (!distortionCorrection || !vrModeEnabled) { + if (distortionCorrection == DistortionCorrectionMethod.None || !vrModeEnabled) { return null; } - if (stereoScreen == null && NativeDistortionCorrectionSupported) { - StereoScreen = CreateStereoScreen(); // Note: use set{} + if (stereoScreen == null) { + // Create on demand. + StereoScreen = device.CreateStereoScreen(); // Note: uses set{} } return stereoScreen; } @@ -244,30 +328,29 @@ public RenderTexture StereoScreen { if (value == stereoScreen) { return; } - if (!NativeDistortionCorrectionSupported && value != null) { - Debug.LogError("Can't set StereoScreen: native distortion correction is not supported."); + if (!SystemInfo.supportsRenderTextures && value != null) { + Debug.LogError("Can't set StereoScreen: RenderTextures are not supported."); return; } if (stereoScreen != null) { stereoScreen.Release(); } stereoScreen = value; - if (stereoScreen != null && !stereoScreen.IsCreated()) { - stereoScreen.Create(); - } if (device != null) { device.SetStereoScreen(stereoScreen); } + if (OnStereoScreenChanged != null) { + OnStereoScreenChanged(stereoScreen); + } } } private static RenderTexture stereoScreen = null; - public bool UseDistortionEffect { - get { - return !NativeDistortionCorrectionSupported && distortionCorrection && vrModeEnabled - && SystemInfo.supportsRenderTextures; - } - } + /// A callback for notifications that the StereoScreen property has changed. + public delegate void StereoScreenChangeDelegate(RenderTexture newStereoScreen); + + /// Occurs when StereoScreen has changed. + public event StereoScreenChangeDelegate OnStereoScreenChanged; /// Describes the current device, including phone screen. public CardboardProfile Profile { @@ -328,9 +411,13 @@ public Vector2 ComfortableViewingRange { return defaultComfortableViewingRange; } } - private readonly Vector2 defaultComfortableViewingRange = new Vector2(1.0f, 100000.0f); + private readonly Vector2 defaultComfortableViewingRange = new Vector2(0.4f, 100000.0f); /// @hide + // Optional. Set to a URI obtained from the Google Cardboard profile generator at + // https://www.google.com/get/cardboard/viewerprofilegenerator/ + // Example: Cardboard I/O 2015 viewer profile + //public Uri DefaultDeviceProfile = new Uri("http://google.com/cardboard/cfg?p=CgZHb29nbGUSEkNhcmRib2FyZCBJL08gMjAxNR0J-SA9JQHegj0qEAAAcEIAAHBCAABwQgAAcEJYADUpXA89OghX8as-YrENP1AAYAM"); public Uri DefaultDeviceProfile = null; private void InitDevice() { @@ -357,15 +444,18 @@ private void InitDevice() { device.SetDefaultDeviceProfile(DefaultDeviceProfile); } - device.SetVRModeEnabled(vrModeEnabled); - device.SetDistortionCorrectionEnabled(distortionCorrection - && NativeDistortionCorrectionSupported); - device.SetAlignmentMarkerEnabled(enableAlignmentMarker - && NativeUILayerSupported); + device.SetAlignmentMarkerEnabled(enableAlignmentMarker); device.SetSettingsButtonEnabled(enableSettingsButton); + device.SetVRBackButtonEnabled(backButtonMode != BackButtonModes.Off); + device.SetShowVrBackButtonOnlyInVR(backButtonMode == BackButtonModes.OnlyInVR); + device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native + && NativeDistortionCorrectionSupported); device.SetTapIsTrigger(tapIsTrigger); device.SetNeckModelScale(neckModelScale); device.SetAutoDriftCorrectionEnabled(autoDriftCorrection); + device.SetElectronicDisplayStabilizationEnabled(electronicDisplayStabilization); + + device.SetVRModeEnabled(vrModeEnabled); device.UpdateScreenData(); } @@ -389,8 +479,23 @@ void Awake() { // Prevent the screen from dimming / sleeping Screen.sleepTimeout = SleepTimeout.NeverSleep; InitDevice(); - AddDummyCamera(); StereoScreen = null; + AddCardboardCamera(); + } + + void AddCardboardCamera() { + var preRender = UnityEngine.Object.FindObjectOfType(); + if (preRender == null) { + var go = new GameObject("PreRender", typeof(CardboardPreRender)); + go.SendMessage("Reset"); + go.transform.parent = transform; + } + var postRender = UnityEngine.Object.FindObjectOfType(); + if (postRender == null) { + var go = new GameObject("PostRender", typeof(CardboardPostRender)); + go.SendMessage("Reset"); + go.transform.parent = transform; + } } /// Emitted whenever a trigger pull occurs. If #TapIsTrigger is set, then it is also @@ -399,9 +504,17 @@ void Awake() { /// Emitted whenever the viewer is tilted on its side. If #TapIsTrigger is set, the /// Escape key issues this as well. - /// @note On Android, Unity sees the Back button as an Escape key. + /// @note On Android, if #TapIsTrigger is off, a tilt event is received as an Escape key. + /// Unity also sees the System Back button as an Escape key. public event Action OnTilt; + /// Emitted whenever the app should respond to a possible change in the device viewer + /// profile, that is, the QR code scanned by the user. + public event Action OnProfileChange; + + /// Emitted whenever the user presses the "VR Back Button". + public event Action OnBackButton; + /// Whether the Cardboard trigger was pulled. True for exactly one complete frame /// after each pull. public bool Triggered { get; private set; } @@ -410,82 +523,78 @@ void Awake() { /// after each tilt. Some apps treat this as a "go back" or "exit scene" action. public bool Tilted { get; private set; } - private bool updated = false; + /// Whether the Cardboard device profile has possibly changed. This is meant to indicate + /// that a new QR code has been scanned, although currently it is actually set any time the + /// application is unpaused, whether it was due to a profile change or not. + public bool ProfileChanged { get; private set; } - private CardboardUILayer uiLayer = null; + /// Whether the user has pressed the "VR Back Button", which is generally meant to toggle + /// in and out of VR mode, although you can use it however you want in your app. + public bool BackButtonPressed { get; private set; } + + // Only call device.UpdateState() once per frame. + private bool updated = false; /// Reads the latest tracking data from the phone. This must be - /// Called before accessing any of the poses and matrices above. + /// called before accessing any of the poses and matrices above. /// /// Multiple invocations per frame are OK: Subsequent calls merely yield the /// cached results of the first call. To minimize latency, it should be first /// called later in the frame (for example, in `LateUpdate`) if possible. public void UpdateState() { if (!updated) { - device.UpdateState(); updated = true; + device.UpdateState(); + DispatchEvents(); } } private void DispatchEvents() { - Triggered = device.triggered || TapIsTrigger && Input.GetMouseButtonDown(0); - Tilted = device.tilted || TapIsTrigger && Input.GetKeyDown(KeyCode.Escape); + // Update flags first by copying from device and other inputs. + Triggered = device.triggered || Input.GetMouseButtonDown(0); + Tilted = device.tilted; + ProfileChanged = device.profileChanged; + BackButtonPressed = device.backButtonPressed || Input.GetKeyDown(KeyCode.Escape); + // Reset device flags. device.triggered = false; device.tilted = false; - - if (Tilted) { - if (OnTilt != null) { - OnTilt(); - } + device.profileChanged = false; + device.backButtonPressed = false; + // All flags updated. Now emit events. + if (Tilted && OnTilt != null) { + OnTilt(); } - if (Triggered) { - if (OnTrigger != null) { - OnTrigger(); - } + if (Triggered && OnTrigger != null) { + OnTrigger(); } - } - - private void AddDummyCamera() { - var go = gameObject; - if (go.GetComponent()) { - go = new GameObject("CardboardDummy"); - go.transform.parent = gameObject.transform; + if (ProfileChanged && OnProfileChange != null) { + OnProfileChange(); + } + if (BackButtonPressed && OnBackButton != null) { + OnBackButton(); } - var cam = go.AddComponent(); - cam.clearFlags = CameraClearFlags.SolidColor; - cam.backgroundColor = Color.black; - cam.cullingMask = 0; - cam.useOcclusionCulling = false; - cam.depth = -100; } IEnumerator EndOfFrame() { while (true) { yield return new WaitForEndOfFrame(); - UpdateState(); - device.PostRender(vrModeEnabled); - if (vrModeEnabled && !NativeUILayerSupported) { - if (uiLayer == null) { - uiLayer = new CardboardUILayer(); - } - uiLayer.Draw(); - } - DispatchEvents(); + UpdateState(); // Just in case it hasn't happened by now. updated = false; } } - /// Return a StereoScreen with sensible default values. - public RenderTexture CreateStereoScreen() { - return device.CreateStereoScreen(); + public void PostRender() { + if (NativeDistortionCorrectionSupported) { + device.PostRender(); + } } - /// Reset the tracker so that the user's current direction becomes forward. + /// Resets the tracker so that the user's current direction becomes forward. public void Recenter() { device.Recenter(); } - /// Set the screen coordinates of the mouse/touch event. + /// Sets the coordinates of the mouse/touch event in screen space. public void SetTouchCoordinates(int x, int y) { device.SetTouchCoordinates(x, y); } @@ -496,6 +605,12 @@ public void ShowSettingsDialog() { } void OnEnable() { +#if UNITY_EDITOR + // This can happen if you edit code while the editor is in Play mode. + if (device == null) { + InitDevice(); + } +#endif device.OnPause(false); StartCoroutine("EndOfFrame"); } @@ -514,7 +629,11 @@ void OnApplicationFocus(bool focus) { } void OnLevelWasLoaded(int level) { - device.Reset(); + device.OnLevelLoaded(level); + } + + void OnApplicationQuit() { + device.OnApplicationQuit(); } void OnDestroy() { @@ -527,17 +646,15 @@ void OnDestroy() { } } - void OnApplicationQuit() { - device.OnApplicationQuit(); - } - //********* OBSOLETE ACCESSORS ********* /// @deprecated Use #DistortionCorrection instead. [System.Obsolete("Use DistortionCorrection instead.")] public bool nativeDistortionCorrection { - get { return DistortionCorrection; } - set { DistortionCorrection = value; } + // Attempt to replicate original behavior of this property. + get { return DistortionCorrection == DistortionCorrectionMethod.Native; } + set { DistortionCorrection = value ? DistortionCorrectionMethod.Native + : DistortionCorrectionMethod.None; } } /// @deprecated diff --git a/Cardboard/Scripts/CardboardEye.cs b/Cardboard/Scripts/CardboardEye.cs index 27a8b334..be4fbf58 100644 --- a/Cardboard/Scripts/CardboardEye.cs +++ b/Cardboard/Scripts/CardboardEye.cs @@ -13,7 +13,6 @@ // limitations under the License. using UnityEngine; -using System.Reflection; /// @ingroup Scripts /// Controls one camera of a stereo pair. Each frame, it mirrors the settings of @@ -44,7 +43,6 @@ public class CardboardEye : MonoBehaviour { /// The StereoController in charge of this eye (and whose mono camera /// we will copy settings from). - private StereoController controller; public StereoController Controller { // This property is set up to work both in editor and in player. get { @@ -60,16 +58,25 @@ public StereoController Controller { } /// Returns the closest ancestor CardboardHead. + /// @note Uses GetComponentInParent(), so the result will be null if no active ancestor is found. public CardboardHead Head { get { return GetComponentInParent(); } } + private StereoController controller; + private StereoRenderEffect stereoEffect; + private Camera monoCamera; + private Matrix4x4 realProj; + private Vector4 projvec; + private Vector4 unprojvec; + private float interpPosition = 1; + #if UNITY_5 // For backwards source code compatibility, since we refer to the camera component A LOT in // this script. - new private Camera camera; + new public Camera camera { get; private set; } void Awake() { camera = GetComponent(); @@ -81,220 +88,192 @@ void Start() { if (ctlr == null) { Debug.LogError("CardboardEye must be child of a StereoController."); enabled = false; + return; } - // Save reference to the found controller. + // Save reference to the found controller and it's camera. controller = ctlr; - // Add an image effect when playing in the editor to preview the distortion correction, since - // native distortion corrrection is only available on the phone. - if (Application.isPlaying && !Cardboard.SDK.NativeDistortionCorrectionSupported - && SystemInfo.supportsRenderTextures) { - var effect = GetComponent(); - if (effect == null) { - effect = gameObject.AddComponent(); - } - } + monoCamera = controller.GetComponent(); + UpdateStereoValues(); } - private void FixProjection(ref Matrix4x4 proj, float near, float far, float ipdScale) { + private void FixProjection(ref Matrix4x4 proj) { // Adjust for non-fullscreen camera. Cardboard SDK assumes fullscreen, // so the aspect ratio might not match. - float aspectFix = camera.rect.height / camera.rect.width / 2; - proj[0, 0] *= aspectFix; - - // Adjust for IPD scale. This changes the vergence of the two frustums. - Vector2 dir = transform.localPosition; // ignore Z - dir = dir.normalized * ipdScale; - proj[0, 2] *= Mathf.Abs(dir.x); - proj[1, 2] *= Mathf.Abs(dir.y); + proj[0, 0] *= camera.rect.height / camera.rect.width / 2; // Cardboard had to pass "nominal" values of near/far to the SDK, which // we fix here to match our mono camera's specific values. + float near = monoCamera.nearClipPlane; + float far = monoCamera.farClipPlane; proj[2, 2] = (near + far) / (near - far); proj[2, 3] = 2 * near * far / (near - far); } - private void Setup() { - // Shouldn't happen because of the check in Start(), but just in case... - if (controller == null) { - return; + private Rect FixViewport(Rect rect) { + // We are rendering straight to the screen. Use the reported rect that is visible + // through the device's lenses. + Rect view = Cardboard.SDK.Viewport(eye); + if (eye == Cardboard.Eye.Right) { + rect.x -= 0.5f; } + rect.width *= 2 * view.width; + rect.x = view.x + 2 * rect.x * view.width; + rect.height *= view.height; + rect.y = view.y + rect.y * view.height; + if (Application.isEditor) { + // The Game window's aspect ratio may not match the fake device parameters. + float realAspect = (float)Screen.width / Screen.height; + float fakeAspect = Cardboard.SDK.Profile.screen.width / Cardboard.SDK.Profile.screen.height; + float aspectComparison = fakeAspect / realAspect; + if (aspectComparison < 1) { + rect.width *= aspectComparison; + rect.x *= aspectComparison; + rect.x += (1 - aspectComparison) / 2; + } else { + rect.height /= aspectComparison; + rect.y /= aspectComparison; + } + } + return rect; + } - var monoCamera = controller.GetComponent(); + public void UpdateStereoValues() { Matrix4x4 proj = Cardboard.SDK.Projection(eye); + realProj = Cardboard.SDK.Projection(eye, Cardboard.Distortion.Undistorted); - CopyCameraAndMakeSideBySide(controller, proj[0,2], proj[1,2]); + CopyCameraAndMakeSideBySide(controller, proj[0, 2], proj[1, 2]); + + // Fix aspect ratio and near/far clipping planes. + FixProjection(ref proj); + FixProjection(ref realProj); + + // Parts of the projection matrices that we need to convert texture coordinates between + // distorted and undistorted frustums. Include the transform between texture space [0..1] + // and NDC [-1..1] (that's what the -1 and the /2 are for). + projvec = new Vector4(proj[0, 0], proj[1, 1], proj[0, 2] - 1, proj[1, 2] - 1) / 2; + unprojvec = new Vector4(realProj[0, 0], realProj[1, 1], + realProj[0, 2] - 1, realProj[1, 2] - 1) / 2; // Zoom the stereo cameras if requested. float lerp = Mathf.Clamp01(controller.matchByZoom) * Mathf.Clamp01(controller.matchMonoFOV); - // Lerping the reciprocal of proj(1,1) so zooming is linear in the frustum width, not the depth. + // Lerping the reciprocal of proj(1,1), so zoom is linear in frustum height not the depth. float monoProj11 = monoCamera.projectionMatrix[1, 1]; float zoom = 1 / Mathf.Lerp(1 / proj[1, 1], 1 / monoProj11, lerp) / proj[1, 1]; proj[0, 0] *= zoom; proj[1, 1] *= zoom; - // Calculate stereo adjustments based on the center of interest. - float ipdScale; - float eyeOffset; - controller.ComputeStereoAdjustment(proj[1, 1], transform.lossyScale.z, - out ipdScale, out eyeOffset); - - // Set up the eye's view transform. - transform.localPosition = ipdScale * Cardboard.SDK.EyePose(eye).Position + - eyeOffset * Vector3.forward; - - // Set up the eye's projection. - float near = monoCamera.nearClipPlane; - float far = monoCamera.farClipPlane; - FixProjection(ref proj, near, far, ipdScale); + // Set the eye camera's projection for rendering. camera.projectionMatrix = proj; - if (Application.isEditor) { // So you can see the approximate frustum in the Scene view when the camera is selected. camera.fieldOfView = 2 * Mathf.Atan(1 / proj[1, 1]) * Mathf.Rad2Deg; } - // Set up variables for an image effect that will do distortion correction, e.g. the - // RadialDistortionEffect. Note that native distortion correction should take precedence - // over an image effect, so if that is active then we don't need to compute these variables. - // (Exception: we're in the editor, so we use the image effect to preview the distortion - // correction, because native distortion correction only works on the phone.) - if (Cardboard.SDK.UseDistortionEffect) { - Matrix4x4 realProj = Cardboard.SDK.Projection(eye, Cardboard.Distortion.Undistorted); - FixProjection(ref realProj, near, far, ipdScale); - // Parts of the projection matrices that we need to convert texture coordinates between - // distorted and undistorted frustums. Include the transform between texture space [0..1] - // and NDC [-1..1] (that's what the -1 and the /2 are for). Also note that the zoom - // factor is removed, because that will interfere with the distortion calculation. - Vector4 projvec = new Vector4(proj[0, 0] / zoom, proj[1, 1] / zoom, - proj[0, 2] - 1, proj[1, 2] - 1) / 2; - Vector4 unprojvec = new Vector4(realProj[0, 0], realProj[1, 1], - realProj[0, 2] - 1, realProj[1, 2] - 1) / 2; - Shader.SetGlobalVector("_Projection", projvec); - Shader.SetGlobalVector("_Unprojection", unprojvec); - CardboardProfile p = Cardboard.SDK.Profile; - Shader.SetGlobalVector("_Undistortion", - new Vector4(p.device.inverse.k1, p.device.inverse.k2)); - Shader.SetGlobalVector("_Distortion", - new Vector4(p.device.distortion.k1, p.device.distortion.k2)); + // Draw to the mono camera's target, or the stereo screen. + camera.targetTexture = monoCamera.targetTexture ?? Cardboard.SDK.StereoScreen; + if (camera.targetTexture == null) { + // When drawing straight to screen, account for lens FOV limits. + // Note: do this after all calls to FixProjection() which needs the unfixed rect. + camera.rect = FixViewport(camera.rect); } + } - if (controller.StereoScreen == null) { - Rect rect = camera.rect; - if (!Cardboard.SDK.DistortionCorrection - || Cardboard.SDK.UseDistortionEffect) { - // We are rendering straight to the screen. Use the reported rect that is visible - // through the device's lenses. - Rect view = Cardboard.SDK.Viewport(eye); - if (eye == Cardboard.Eye.Right) { - rect.x -= 0.5f; - } - rect.width *= 2 * view.width; - rect.x = view.x + 2 * rect.x * view.width; - rect.height *= view.height; - rect.y = view.y + rect.y * view.height; - } - if (Application.isEditor) { - // The Game window's aspect ratio may not match the fake device parameters. - float realAspect = (float)Screen.width / Screen.height; - float fakeAspect = Cardboard.SDK.Profile.screen.width / Cardboard.SDK.Profile.screen.height; - float aspectComparison = fakeAspect / realAspect; - if (aspectComparison < 1) { - rect.width *= aspectComparison; - rect.x *= aspectComparison; - rect.x += (1 - aspectComparison) / 2; - } else { - rect.height /= aspectComparison; - } - } - camera.rect = rect; + private void SetupStereo() { + Cardboard.SDK.UpdateState(); + + // Will need to update view transform if there is a COI, or if there is a remnant of + // prior stereo-adjustment smoothing to finish off. + bool haveCOI = controller.centerOfInterest != null + && controller.centerOfInterest.gameObject.activeInHierarchy; + bool updatePosition = haveCOI || interpPosition < 1; + + if (controller.keepStereoUpdated || Cardboard.SDK.ProfileChanged || Application.isEditor) { + // Set projection and viewport. + UpdateStereoValues(); + // Also view transform. + updatePosition = true; + } + + if (updatePosition) { + // Set view transform. + float proj11 = camera.projectionMatrix[1, 1]; + float zScale = transform.lossyScale.z; + Vector3 eyePos = controller.ComputeStereoEyePosition(eye, proj11, zScale); + // Apply smoothing only if updating position every frame. + interpPosition = controller.keepStereoUpdated || haveCOI ? + Time.deltaTime / (controller.stereoAdjustSmoothing + Time.deltaTime) : 1; + transform.localPosition = Vector3.Lerp(transform.localPosition, eyePos, interpPosition); } - } - /// Called by StereoController to run the whole render pipeline for this camera. - public void Render() { - Setup(); - - // Use the "fast" or "slow" method. Fast means the camera draws right into one half of - // the stereo screen. Slow means it draws first to a side buffer, and then the buffer - // is written to the screen. The slow method is provided because a lot of Image Effects - // don't work if you draw to only part of the window. - if (controller.directRender) { - // Redirect to our stereo screen. - camera.targetTexture = controller.StereoScreen; - // Draw! - camera.Render(); + // Pass necessary information to any shaders doing distortion correction. + if (Cardboard.SDK.DistortionCorrection == Cardboard.DistortionCorrectionMethod.None) { + // Correction matrix for use in surface shaders that do vertex warping for distortion. + // Have to compute it every frame because cameraToWorldMatrix is changing constantly. + var fixProj = camera.cameraToWorldMatrix * + Matrix4x4.Inverse(camera.projectionMatrix) * + realProj; + Shader.SetGlobalMatrix("_RealProjection ", realProj); + Shader.SetGlobalMatrix("_FixProjection ", fixProj); } else { - // Save the viewport rectangle and reset to "full screen". - Rect pixRect = camera.pixelRect; - camera.rect = new Rect (0, 0, 1, 1); - // Redirect to a temporary texture. The defaults are supposedly Android-friendly. - RenderTexture stereoScreen = controller.StereoScreen; - int screenWidth = stereoScreen ? stereoScreen.width : Screen.width; - int screenHeight = stereoScreen ? stereoScreen.height : Screen.height; - int depth = stereoScreen ? stereoScreen.depth : 16; - RenderTextureFormat format = stereoScreen ? stereoScreen.format : RenderTextureFormat.RGB565; - camera.targetTexture = RenderTexture.GetTemporary((int)pixRect.width, (int)pixRect.height, - depth, format); - // Draw! - camera.Render(); - // Blit the temp texture to the stereo screen. - RenderTexture oldTarget = RenderTexture.active; - RenderTexture.active = stereoScreen; - GL.PushMatrix(); - GL.LoadPixelMatrix(0, screenWidth, screenHeight, 0); - // Camera rects are in screen coordinates (bottom left is origin), but DrawTexture takes a - // rect in GUI coordinates (top left is origin). - Rect blitRect = pixRect; - blitRect.y = screenHeight - pixRect.height - pixRect.y; - // Blit! - Graphics.DrawTexture(blitRect, camera.targetTexture); - // Clean up. - GL.PopMatrix(); - RenderTexture.active = oldTarget; - RenderTexture.ReleaseTemporary(camera.targetTexture); + // Not doing vertex-based distortion. Set up the parameters to make any vertex-warping + // shaders in the project leave vertexes alone. + Shader.SetGlobalMatrix("_RealProjection ", camera.projectionMatrix); + Shader.SetGlobalMatrix("_FixProjection ", camera.cameraToWorldMatrix); } - camera.targetTexture = null; + Shader.SetGlobalVector("_Projection", projvec); + Shader.SetGlobalVector("_Unprojection", unprojvec); + Shader.SetGlobalFloat("_NearClip", camera.nearClipPlane); } - /// Alternate means of rendering stereo, when you don't plan to switch in and out of VR mode: - /// In the editor, disable the MainCamera's camera component. Enable the two stereo eye - /// camera components. - /// @note due to a quirk of Unity, there must be at least one camera not rendering to a texture, - /// preferably last in order. If necessary, add a dummy camera to the scene with a high depth - /// value, it's clear flags set to "Don't Clear", and culling mask set to Nothing. void OnPreCull() { - if (camera.enabled) { - Setup(); - camera.targetTexture = controller.StereoScreen; + if (!Cardboard.SDK.VRModeEnabled || !monoCamera.enabled) { + // Keep stereo enabled flag in sync with parent mono camera. + camera.enabled = false; + return; + } + SetupStereo(); + if (!controller.directRender && Cardboard.SDK.StereoScreen != null) { + // Some image effects clobber the whole screen. Add a final image effect to the chain + // which restores side-by-side stereo. + stereoEffect = GetComponent(); + if (stereoEffect == null) { + stereoEffect = gameObject.AddComponent(); + } + stereoEffect.enabled = true; + } else if (stereoEffect != null) { + // Don't need the side-by-side image effect. + stereoEffect.enabled = false; } } - /// Helper to copy camera settings from the controller's mono camera. - /// Used in OnPreCull and the custom editor for StereoController. - /// The parameters parx and pary, if not left at default, should come from a - /// projection matrix returned by the SDK. - /// They affect the apparent depth of the camera's window. See OnPreCull(). + /// Helper to copy camera settings from the controller's mono camera. Used in SetupStereo() and + /// in the custom editor for StereoController. The parameters parx and pary, if not left at + /// default, should come from a projection matrix returned by the SDK. They affect the apparent + /// depth of the camera's window. See SetupStereo(). public void CopyCameraAndMakeSideBySide(StereoController controller, float parx = 0, float pary = 0) { -#if UNITY_5 #if UNITY_EDITOR // Member variable 'camera' not always initialized when this method called in Editor. - // So, we'll just make a local of the same name. + // So, we'll just make a local of the same name. Same for controller's camera. var camera = GetComponent(); + var monoCamera = controller.GetComponent(); #endif -#endif + + float ipd = CardboardProfile.Default.device.lenses.separation * controller.stereoMultiplier; + Vector3 localPosition = Application.isPlaying ? + transform.localPosition : (eye == Cardboard.Eye.Left ? -ipd/2 : ipd/2) * Vector3.right;; // Sync the camera properties. - camera.CopyFrom(controller.GetComponent()); + camera.CopyFrom(monoCamera); camera.cullingMask ^= toggleCullingMask.value; + // Not sure why we have to do this, but if we don't then switching between drawing to + // the main screen or to the stereo rendertexture acts very strangely. + camera.depth = monoCamera.depth; + // Reset transform, which was clobbered by the CopyFrom() call. - // Since we are a child of the mono camera, we inherit its - // transform already. - // Use nominal IPD for the editor. During play, OnPreCull() will - // compute a real value. - float ipd = CardboardProfile.Default.device.lenses.separation * controller.stereoMultiplier; - transform.localPosition = (eye == Cardboard.Eye.Left ? -ipd/2 : ipd/2) * Vector3.right; + // Since we are a child of the mono camera, we inherit its transform already. + transform.localPosition = localPosition; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; @@ -326,7 +305,7 @@ public void CopyCameraAndMakeSideBySide(StereoController controller, // Adjust the window for requested parallax. This affects the apparent depth of the // window in the main camera's screen. Useful for PIP windows only, where rect.width < 1. float parallax = Mathf.Clamp01(controller.screenParallax); - if (controller.GetComponent().rect.width < 1 && parallax > 0) { + if (monoCamera.rect.width < 1 && parallax > 0) { // Note: parx and pary are signed, with opposite signs in each eye. rect.x -= parx / 4 * parallax; // Extra factor of 1/2 because of side-by-side stereo. rect.y -= pary / 2 * parallax; diff --git a/Cardboard/Scripts/CardboardHead.cs b/Cardboard/Scripts/CardboardHead.cs index b0910d54..f7016bdd 100644 --- a/Cardboard/Scripts/CardboardHead.cs +++ b/Cardboard/Scripts/CardboardHead.cs @@ -15,11 +15,13 @@ using UnityEngine; /// @ingroup Scripts +/// This script provides head tracking support for a camera. +/// /// Attach this script to any game object that should match the user's head motion. /// By default, it continuously updates the local transform to Cardboard.HeadView. /// A target object may be specified to provide an alternate reference frame for the motion. /// -/// This script will typically be attached to directly to a Camera object, or to its +/// This script will typically be attached directly to a Camera object, or to its /// parent if you need to offset the camera from the origin. /// Alternatively it can be inserted as a child of the Camera and parent of the /// CardboardEye camera. Do this if you already have steering logic driving the @@ -32,11 +34,13 @@ /// #trackRotation and #trackPosition properties in this case. public class CardboardHead : MonoBehaviour { /// Determines whether to apply the user's head rotation to this gameobject's - /// orientation. + /// orientation. True means to update the gameobject's orientation with the + /// user's head rotation, and false means don't modify the gameobject's orientation. public bool trackRotation = true; /// Determines whether to apply ther user's head offset to this gameobject's - /// position. + /// position. True means to update the gameobject's position with the user's head offset, + /// and false means don't modify the gameobject's position. public bool trackPosition = true; /// The user's head motion will be applied in this object's reference frame @@ -50,14 +54,15 @@ public class CardboardHead : MonoBehaviour { /// Determines whether the head tracking is applied during `LateUpdate()` or - /// `Update()`. The default is `LateUpdate()` to reduce latency. However, some - /// scripts need to use the camera's direction to affect the game play, e.g by - /// casting rays or steering a vehicle, during the `LateUpdate()` phase. + /// `Update()`. The default is false, which means it is applied during `LateUpdate()` + /// to reduce latency. /// + /// However, some scripts may need to use the camera's direction to affect the gameplay, + /// e.g by casting rays or steering a vehicle, during the `LateUpdate()` phase. /// This can cause an annoying jitter because Unity, during this `LateUpdate()` /// phase, will update the head object first on some frames but second on others. - /// If this is the case for your game, try switching the head to use `Update()` - /// by setting this to true. + /// If this is the case for your game, try switching the head to apply head tracking + /// during `Update()` by setting this to true. public bool updateEarly = false; /// Returns a ray based on the heads position and forward direction, after making @@ -97,7 +102,7 @@ private void UpdateHead() { if (target == null) { transform.localRotation = rot; } else { - transform.rotation = rot * target.rotation; + transform.rotation = target.rotation * rot; } } diff --git a/Cardboard/Scripts/CardboardPostRender.cs b/Cardboard/Scripts/CardboardPostRender.cs new file mode 100644 index 00000000..2da02499 --- /dev/null +++ b/Cardboard/Scripts/CardboardPostRender.cs @@ -0,0 +1,335 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; + +[RequireComponent(typeof(Camera))] +public class CardboardPostRender : MonoBehaviour { + +#if UNITY_5 + new public Camera camera { get; private set; } +#endif + + // Distortion mesh parameters. + + // Size of one eye's distortion mesh grid. The whole mesh is two of these grids side by side. + private const int kMeshWidth = 40; + private const int kMeshHeight = 40; + // Whether to apply distortion in the grid coordinates or in the texture coordinates. + private const bool kDistortVertices = true; + + private Mesh distortionMesh; + private Material meshMaterial; + + // UI Layer parameters. + private Material uiMaterial; + private float centerWidthPx; + private float buttonWidthPx; + private float xScale; + private float yScale; + private Matrix4x4 xfm; + + void Reset() { + camera.clearFlags = CameraClearFlags.Depth; + camera.backgroundColor = Color.magenta; // Should be noticeable if the clear flags change. + camera.orthographic = true; + camera.orthographicSize = 0.5f; + camera.cullingMask = 0; + camera.useOcclusionCulling = false; + camera.depth = 100; + } + + void Awake() { +#if UNITY_5 + camera = GetComponent(); +#endif + Reset(); + meshMaterial = new Material(Shader.Find("Cardboard/UnlitTexture")); + uiMaterial = new Material(Shader.Find("Cardboard/SolidColor")); + uiMaterial.color = new Color(0.8f, 0.8f, 0.8f); + if (!Application.isEditor) { + ComputeUIMatrix(); + } + } + +#if UNITY_EDITOR + private float aspectComparison; + + void OnPreCull() { + // The Game window's aspect ratio may not match the fake device parameters. + float realAspect = (float)Screen.width / Screen.height; + float fakeAspect = Cardboard.SDK.Profile.screen.width / Cardboard.SDK.Profile.screen.height; + aspectComparison = fakeAspect / realAspect; + camera.orthographicSize = 0.5f * Mathf.Max(1, aspectComparison); + } +#endif + + void OnRenderObject() { + if (Camera.current != camera) + return; + Cardboard.SDK.UpdateState(); + var correction = Cardboard.SDK.DistortionCorrection; + RenderTexture stereoScreen = Cardboard.SDK.StereoScreen; + if (stereoScreen == null || correction == Cardboard.DistortionCorrectionMethod.None) { + return; + } + if (correction == Cardboard.DistortionCorrectionMethod.Native + && Cardboard.SDK.NativeDistortionCorrectionSupported) { + Cardboard.SDK.PostRender(); + } else { + if (distortionMesh == null || Cardboard.SDK.ProfileChanged) { + RebuildDistortionMesh(); + } + meshMaterial.mainTexture = stereoScreen; + meshMaterial.SetPass(0); + Graphics.DrawMeshNow(distortionMesh, transform.position, transform.rotation); + } + stereoScreen.DiscardContents(); + if (!Cardboard.SDK.NativeUILayerSupported) { + DrawUILayer(); + } + } + + private void RebuildDistortionMesh() { + distortionMesh = new Mesh(); + Vector3[] vertices; + Vector2[] tex; + ComputeMeshPoints(kMeshWidth, kMeshHeight, kDistortVertices, out vertices, out tex); + int[] indices = ComputeMeshIndices(kMeshWidth, kMeshHeight, kDistortVertices); + Color[] colors = ComputeMeshColors(kMeshWidth, kMeshHeight, tex, indices, kDistortVertices); + distortionMesh.vertices = vertices; + distortionMesh.uv = tex; + distortionMesh.colors = colors; + distortionMesh.triangles = indices; + distortionMesh.Optimize(); + distortionMesh.UploadMeshData(true); + } + + private static void ComputeMeshPoints(int width, int height, bool distortVertices, + out Vector3[] vertices, out Vector2[] tex) { + float[] lensFrustum = new float[4]; + float[] noLensFrustum = new float[4]; + Rect viewport; + CardboardProfile profile = Cardboard.SDK.Profile; + profile.GetLeftEyeVisibleTanAngles(lensFrustum); + profile.GetLeftEyeNoLensTanAngles(noLensFrustum); + viewport = profile.GetLeftEyeVisibleScreenRect(noLensFrustum); + vertices = new Vector3[2 * width * height]; + tex = new Vector2[2 * width * height]; + for (int e = 0, vidx = 0; e < 2; e++) { + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++, vidx++) { + float u = (float)i / (width - 1); + float v = (float)j / (height - 1); + float s, t; // The texture coordinates in StereoScreen to read from. + if (distortVertices) { + // Grid points regularly spaced in StreoScreen, and barrel distorted in the mesh. + s = u; + t = v; + float x = Mathf.Lerp(lensFrustum[0], lensFrustum[2], u); + float y = Mathf.Lerp(lensFrustum[3], lensFrustum[1], v); + float d = Mathf.Sqrt(x * x + y * y); + float r = profile.device.distortion.distortInv(d); + float p = x * r / d; + float q = y * r / d; + u = (p - noLensFrustum[0]) / (noLensFrustum[2] - noLensFrustum[0]); + v = (q - noLensFrustum[3]) / (noLensFrustum[1] - noLensFrustum[3]); + } else { + // Grid points regularly spaced in the mesh, and pincushion distorted in + // StereoScreen. + float p = Mathf.Lerp(noLensFrustum[0], noLensFrustum[2], u); + float q = Mathf.Lerp(noLensFrustum[3], noLensFrustum[1], v); + float r = Mathf.Sqrt(p * p + q * q); + float d = profile.device.distortion.distort(r); + float x = p * d / r; + float y = q * d / r; + s = Mathf.Clamp01((x - lensFrustum[0]) / (lensFrustum[2] - lensFrustum[0])); + t = Mathf.Clamp01((y - lensFrustum[3]) / (lensFrustum[1] - lensFrustum[3])); + } + // Convert u,v to mesh screen coordinates. + float aspect = profile.screen.width / profile.screen.height; + u = (viewport.x + u * viewport.width - 0.5f) * aspect; + v = viewport.y + v * viewport.height - 0.5f; + vertices[vidx] = new Vector3(u, v, 1); + // Adjust s to account for left/right split in StereoScreen. + s = (s + e) / 2; + tex[vidx] = new Vector2(s, t); + } + } + float w = lensFrustum[2] - lensFrustum[0]; + lensFrustum[0] = -(w + lensFrustum[0]); + lensFrustum[2] = w - lensFrustum[2]; + w = noLensFrustum[2] - noLensFrustum[0]; + noLensFrustum[0] = -(w + noLensFrustum[0]); + noLensFrustum[2] = w - noLensFrustum[2]; + viewport.x = 1 - (viewport.x + viewport.width); + } + } + + private static Color[] ComputeMeshColors(int width, int height, Vector2[] tex, int[] indices, + bool distortVertices) { + Color[] colors = new Color[2 * width * height]; + for (int e = 0, vidx = 0; e < 2; e++) { + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++, vidx++) { + colors[vidx] = Color.white; + if (distortVertices) { + if (i == 0 || j == 0 || i == (width - 1) || j == (height - 1)) { + colors[vidx] = Color.black; + } + } else { + Vector2 t = tex[vidx]; + t.x = Mathf.Abs(t.x * 2 - 1); + if (t.x <= 0 || t.y <= 0 || t.x >= 1 || t.y >= 1) { + colors[vidx] = Color.black; + } + } + } + } + } + return colors; + } + + private static int[] ComputeMeshIndices(int width, int height, bool distortVertices) { + int[] indices = new int[2 * (width - 1) * (height - 1) * 6]; + int halfwidth = width / 2; + int halfheight = height / 2; + for (int e = 0, vidx = 0, iidx = 0; e < 2; e++) { + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++, vidx++) { + if (i == 0 || j == 0) + continue; + // Build a quad. Lower right and upper left quadrants have quads with the triangle + // diagonal flipped to get the vignette to interpolate correctly. + if ((i <= halfwidth) == (j <= halfheight)) { + // Quad diagonal lower left to upper right. + indices[iidx++] = vidx; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx - width - 1; + indices[iidx++] = vidx - width - 1; + indices[iidx++] = vidx - 1; + indices[iidx++] = vidx; + } else { + // Quad diagonal upper left to lower right. + indices[iidx++] = vidx - 1; + indices[iidx++] = vidx; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx - width; + indices[iidx++] = vidx - width - 1; + indices[iidx++] = vidx - 1; + } + } + } + } + return indices; + } + + private void DrawUILayer() { + bool vrMode = Cardboard.SDK.VRModeEnabled; + if (Application.isEditor) { + ComputeUIMatrix(); + } + uiMaterial.SetPass(0); + if (vrMode && Cardboard.SDK.EnableSettingsButton) { + DrawSettingsButton(); + } + if (vrMode && Cardboard.SDK.EnableAlignmentMarker) { + DrawAlignmentMarker(); + } + if (Cardboard.SDK.BackButtonMode == Cardboard.BackButtonModes.On + || vrMode && Cardboard.SDK.BackButtonMode == Cardboard.BackButtonModes.OnlyInVR) { + DrawVRBackButton(); + } + } + + // The gear has 6 identical sections, each spanning 60 degrees. + private const float kAnglePerGearSection = 60; + + // Half-angle of the span of the outer rim. + private const float kOuterRimEndAngle = 12; + + // Angle between the middle of the outer rim and the start of the inner rim. + private const float kInnerRimBeginAngle = 20; + + // Distance from center to outer rim, normalized so that the entire model + // fits in a [-1, 1] x [-1, 1] square. + private const float kOuterRadius = 1; + + // Distance from center to depressed rim, in model units. + private const float kMiddleRadius = 0.75f; + + // Radius of the inner hollow circle, in model units. + private const float kInnerRadius = 0.3125f; + + // Center line thickness in DP. + private const float kCenterLineThicknessDp = 4; + + // Button width in DP. + private const int kButtonWidthDp = 28; + + // Factor to scale the touch area that responds to the touch. + private const float kTouchSlopFactor = 1.5f; + + private static readonly float[] Angles = { + 0, kOuterRimEndAngle, kInnerRimBeginAngle, + kAnglePerGearSection - kInnerRimBeginAngle, kAnglePerGearSection - kOuterRimEndAngle + }; + + private void ComputeUIMatrix() { + centerWidthPx = kCenterLineThicknessDp / 160.0f * Screen.dpi / 2; + buttonWidthPx = kButtonWidthDp / 160.0f * Screen.dpi / 2; + xScale = buttonWidthPx / Screen.width; + yScale = buttonWidthPx / Screen.height; + xfm = Matrix4x4.TRS(new Vector3(0.5f, yScale, 0), Quaternion.identity, + new Vector3(xScale, yScale, 1)); + } + + private void DrawSettingsButton() { + GL.PushMatrix(); + GL.LoadOrtho(); + GL.MultMatrix(xfm); + GL.Begin(GL.TRIANGLE_STRIP); + for (int i = 0, n = Angles.Length * 6; i <= n; i++) { + float theta = (i / Angles.Length) * kAnglePerGearSection + Angles[i % Angles.Length]; + float angle = (90 - theta) * Mathf.Deg2Rad; + float x = Mathf.Cos(angle); + float y = Mathf.Sin(angle); + float mod = Mathf.PingPong(theta, kAnglePerGearSection / 2); + float lerp = (mod - kOuterRimEndAngle) / (kInnerRimBeginAngle - kOuterRimEndAngle); + float r = Mathf.Lerp(kOuterRadius, kMiddleRadius, lerp); + GL.Vertex3(kInnerRadius * x, kInnerRadius * y, 0); + GL.Vertex3(r * x, r * y, 0); + } + GL.End(); + GL.PopMatrix(); + } + + private void DrawAlignmentMarker() { + int x = Screen.width / 2; + int w = (int)centerWidthPx; + int h = (int)(2 * kTouchSlopFactor * buttonWidthPx); + GL.PushMatrix(); + GL.LoadPixelMatrix(0, Screen.width, 0, Screen.height); + GL.Begin(GL.QUADS); + GL.Vertex3(x - w, h, 0); + GL.Vertex3(x - w, Screen.height - h, 0); + GL.Vertex3(x + w, Screen.height - h, 0); + GL.Vertex3(x + w, h, 0); + GL.End(); + GL.PopMatrix(); + } + + private void DrawVRBackButton() { + } +} diff --git a/Cardboard/Scripts/CardboardPreRender.cs b/Cardboard/Scripts/CardboardPreRender.cs new file mode 100644 index 00000000..7ba14ea7 --- /dev/null +++ b/Cardboard/Scripts/CardboardPreRender.cs @@ -0,0 +1,63 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; + +[RequireComponent(typeof(Camera))] +public class CardboardPreRender : MonoBehaviour { + +#if UNITY_5 + new public Camera camera { get; private set; } +#endif + + void Awake() { +#if UNITY_5 + camera = GetComponent(); +#endif + } + + void Reset() { + camera.clearFlags = CameraClearFlags.SolidColor; + camera.backgroundColor = Color.black; + camera.cullingMask = 0; + camera.useOcclusionCulling = false; + camera.depth = -100; + } + + void OnPreCull() { + Cardboard.SDK.UpdateState(); + if (Cardboard.SDK.ProfileChanged) { + SetShaderGlobals(); + } + camera.clearFlags = Cardboard.SDK.VRModeEnabled ? + CameraClearFlags.SolidColor : CameraClearFlags.Nothing; + var stereoScreen = Cardboard.SDK.StereoScreen; + if (stereoScreen != null && !stereoScreen.IsCreated()) { + stereoScreen.Create(); + } + } + + private void SetShaderGlobals() { + // For any shaders that want to use these numbers for distortion correction. + CardboardProfile p = Cardboard.SDK.Profile; + Shader.SetGlobalVector("_Undistortion", + new Vector4(p.device.inverse.k1, p.device.inverse.k2)); + Shader.SetGlobalVector("_Distortion", + new Vector4(p.device.distortion.k1, p.device.distortion.k2)); + float[] rect = new float[4]; + p.GetLeftEyeVisibleTanAngles(rect); + float r = CardboardProfile.GetMaxRadius(rect); + Shader.SetGlobalFloat("_MaxRadSq", r*r); + } +} diff --git a/Cardboard/Scripts/CardboardProfile.cs b/Cardboard/Scripts/CardboardProfile.cs index 621898df..9dcde678 100644 --- a/Cardboard/Scripts/CardboardProfile.cs +++ b/Cardboard/Scripts/CardboardProfile.cs @@ -1,7 +1,21 @@ -using System; +// Copyright 2014 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; using UnityEngine; -// Measurements of a particular phone in a particular Cardboard device. +/// Measurements of a particular phone in a particular Cardboard device. [System.Serializable] public class CardboardProfile { public CardboardProfile Clone() { @@ -11,8 +25,8 @@ public CardboardProfile Clone() { }; } - // Information about the screen. All distances in meters, measured as the phone is expected - // to be placed in the Cardboard, i.e. landscape orientation. + /// Information about the screen. All distances are in meters, measured as the phone is expected + /// to be placed in the Cardboard, i.e. landscape orientation. [System.Serializable] public struct Screen { public float width; // The long edge of the phone. @@ -20,7 +34,7 @@ public struct Screen { public float border; // Distance from bottom of the cardboard to the bottom edge of screen. } - // Information about the lens placement in the Cardboard. All distances in meters. + /// Information about the lens placement in the Cardboard. All distances are in meters. [System.Serializable] public struct Lenses { public float separation; // Center to center. @@ -36,10 +50,10 @@ public struct Lenses { public const int AlignBottom = 1; // Offset is measured up from bottom of device. } - // Information about the viewing angles through the lenses. All angles in degrees, measured - // away from the optical axis, i.e. angles are all positive. It is assumed that left and right - // eye FOVs are mirror images, so that both have the same inner and outer angles. Angles do not - // need to account for the limits due to screen size. + /// Information about the viewing angles through the lenses. All angles in degrees, measured + /// away from the optical axis, i.e. angles are all positive. It is assumed that left and right + /// eye FOVs are mirror images, so that both have the same inner and outer angles. Angles do not + /// need to account for the limits due to screen size. [System.Serializable] public struct MaxFOV { public float outer; // Towards the side of the screen. @@ -48,8 +62,8 @@ public struct MaxFOV { public float lower; // Towards the bottom of the screen. } - // Information on how the lens distorts light rays. Also used for the (approximate) inverse - // distortion. Assumes a radially symmetric pincushion/barrel distortion model. + /// Information on how the lens distorts light rays. Also used for the (approximate) inverse + /// distortion. Assumes a radially symmetric pincushion/barrel distortion model. [System.Serializable] public struct Distortion { public float k1; @@ -59,8 +73,25 @@ public float distort(float r) { float r2 = r * r; return ((k2 * r2 + k1) * r2 + 1) * r; } + + public float distortInv(float radius) { + // Secant method. + float r0 = 0; + float r1 = 1; + float dr0 = radius - distort(r0); + while (Mathf.Abs(r1 - r0) > 0.0001f) { + float dr1 = radius - distort(r1); + float r2 = r1 - dr1 * ((r1 - r0) / (dr1 - dr0)); + r0 = r1; + r1 = r2; + dr0 = dr1; + } + return r1; + } } + /// Information about a particular device, including specfications on its lenses, FOV, + /// and distortion and inverse distortion coefficients. [System.Serializable] public struct Device { public Lenses lenses; @@ -69,19 +100,20 @@ public struct Device { public Distortion inverse; } - // The combined set of information about a Cardboard profile. + /// Screen parameters of a Cardboard device. public Screen screen; + + /// Device parameters of a Cardboard device. public Device device; - // The vertical offset of the lens centers from the screen center. + /// The vertical offset of the lens centers from the screen center. public float VerticalLensOffset { get { return (device.lenses.offset - screen.border - screen.height/2) * device.lenses.alignment; } } - // Some known profiles. - + /// Some known screen profiles. public enum ScreenSizes { Nexus5, Nexus6, @@ -94,66 +126,77 @@ public enum ScreenSizes { iPhone6p, }; + /// Parameters for a Nexus 5 device. public static readonly Screen Nexus5 = new Screen { width = 0.110f, height = 0.062f, border = 0.004f }; + /// Parameters for a Nexus 6 device. public static readonly Screen Nexus6 = new Screen { width = 0.133f, height = 0.074f, border = 0.004f }; + /// Parameters for a Galaxy S6 device. public static readonly Screen GalaxyS6 = new Screen { width = 0.114f, height = 0.0635f, border = 0.0035f }; + /// Parameters for a Galaxy Note4 device. public static readonly Screen GalaxyNote4 = new Screen { width = 0.125f, height = 0.0705f, border = 0.0045f }; + /// Parameters for a LG G3 device. public static readonly Screen LGG3 = new Screen { width = 0.121f, height = 0.068f, border = 0.003f }; + /// Parameters for an iPhone 4 device. public static readonly Screen iPhone4 = new Screen { width = 0.075f, height = 0.050f, border = 0.0045f }; + /// Parameters for an iPhone 5 device. public static readonly Screen iPhone5 = new Screen { width = 0.089f, height = 0.050f, border = 0.0045f }; + /// Parameters for an iPhone 6 device. public static readonly Screen iPhone6 = new Screen { width = 0.104f, height = 0.058f, border = 0.005f }; + /// Parameters for an iPhone 6p device. public static readonly Screen iPhone6p = new Screen { width = 0.112f, height = 0.068f, border = 0.005f }; + /// Some known Cardboard device profiles. public enum DeviceTypes { CardboardJun2014, CardboardMay2015, GoggleTechC1Glass, }; + /// Parameters for a Cardboard v1. public static readonly Device CardboardJun2014 = new Device { lenses = { separation = 0.060f, @@ -174,26 +217,28 @@ public enum DeviceTypes { inverse = ApproximateInverse(0.441f, 0.156f) }; + /// Parameters for a Cardboard v2. public static readonly Device CardboardMay2015 = new Device { lenses = { - separation = 0.062f, + separation = 0.064f, offset = 0.035f, - screenDistance = 0.037f, + screenDistance = 0.039f, alignment = Lenses.AlignBottom, }, maxFOV = { - outer = 50.0f, - inner = 50.0f, - upper = 50.0f, - lower = 50.0f + outer = 60.0f, + inner = 60.0f, + upper = 60.0f, + lower = 60.0f }, distortion = { - k1 = 0.26f, - k2 = 0.27f + k1 = 0.34f, + k2 = 0.55f }, - inverse = ApproximateInverse(0.26f, 0.27f) + inverse = ApproximateInverse(0.34f, 0.55f) }; + /// Parameters for a Go4D C1-Glass. public static readonly Device GoggleTechC1Glass = new Device { lenses = { separation = 0.065f, @@ -214,12 +259,13 @@ public enum DeviceTypes { inverse = ApproximateInverse(0.3f, 0) }; - // Nexus 5 in a v1 Cardboard. + /// Nexus 5 in a Cardboard v1. public static readonly CardboardProfile Default = new CardboardProfile { screen = Nexus5, device = CardboardJun2014 }; + /// Returns a CardboardProfile with the given parameters. public static CardboardProfile GetKnownProfile(ScreenSizes screenSize, DeviceTypes deviceType) { Screen screen; switch (screenSize) { @@ -256,6 +302,9 @@ public static CardboardProfile GetKnownProfile(ScreenSizes screenSize, DeviceTyp case DeviceTypes.CardboardMay2015: device = CardboardMay2015; break; + case DeviceTypes.GoggleTechC1Glass: + device = GoggleTechC1Glass; + break; default: device = CardboardJun2014; break; @@ -263,12 +312,14 @@ public static CardboardProfile GetKnownProfile(ScreenSizes screenSize, DeviceTyp return new CardboardProfile { screen = screen, device = device }; } - public void GetLeftEyeVisibleTanAngles(ref float[] result) { + /// Calculates the tan-angles from the maximum FOV for the left eye for the + /// current device and screen parameters. + public void GetLeftEyeVisibleTanAngles(float[] result) { // Tan-angles from the max FOV. - float fovLeft = (float) Math.Tan(-device.maxFOV.outer * Math.PI / 180); - float fovTop = (float) Math.Tan(device.maxFOV.upper * Math.PI / 180); - float fovRight = (float) Math.Tan(device.maxFOV.inner * Math.PI / 180); - float fovBottom = (float) Math.Tan(-device.maxFOV.lower * Math.PI / 180); + float fovLeft = Mathf.Tan(-device.maxFOV.outer * Mathf.Deg2Rad); + float fovTop = Mathf.Tan(device.maxFOV.upper * Mathf.Deg2Rad); + float fovRight = Mathf.Tan(device.maxFOV.inner * Mathf.Deg2Rad); + float fovBottom = Mathf.Tan(-device.maxFOV.lower * Mathf.Deg2Rad); // Viewport size. float halfWidth = screen.width / 4; float halfHeight = screen.height / 2; @@ -280,7 +331,7 @@ public void GetLeftEyeVisibleTanAngles(ref float[] result) { float screenLeft = device.distortion.distort((centerX - halfWidth) / centerZ); float screenTop = device.distortion.distort((centerY + halfHeight) / centerZ); float screenRight = device.distortion.distort((centerX + halfWidth) / centerZ); - float screenBottom = device.distortion.distort((centerY - halfWidth) / centerZ); + float screenBottom = device.distortion.distort((centerY - halfHeight) / centerZ); // Compare the two sets of tan-angles and take the value closer to zero on each side. result[0] = Math.Max(fovLeft, screenLeft); result[1] = Math.Min(fovTop, screenTop); @@ -288,12 +339,14 @@ public void GetLeftEyeVisibleTanAngles(ref float[] result) { result[3] = Math.Max(fovBottom, screenBottom); } - public void GetLeftEyeNoLensTanAngles(ref float[] result) { + /// Calculates the tan-angles from the maximum FOV for the left eye for the + /// current device and screen parameters, assuming no lenses. + public void GetLeftEyeNoLensTanAngles(float[] result) { // Tan-angles from the max FOV. - float fovLeft = device.inverse.distort((float)Math.Tan(-device.maxFOV.outer * Math.PI / 180)); - float fovTop = device.inverse.distort((float)Math.Tan(device.maxFOV.upper * Math.PI / 180)); - float fovRight = device.inverse.distort((float)Math.Tan(device.maxFOV.inner * Math.PI / 180)); - float fovBottom = device.inverse.distort((float)Math.Tan(-device.maxFOV.lower * Math.PI / 180)); + float fovLeft = device.distortion.distortInv(Mathf.Tan(-device.maxFOV.outer * Mathf.Deg2Rad)); + float fovTop = device.distortion.distortInv(Mathf.Tan(device.maxFOV.upper * Mathf.Deg2Rad)); + float fovRight = device.distortion.distortInv(Mathf.Tan(device.maxFOV.inner * Mathf.Deg2Rad)); + float fovBottom = device.distortion.distortInv(Mathf.Tan(-device.maxFOV.lower * Mathf.Deg2Rad)); // Viewport size. float halfWidth = screen.width / 4; float halfHeight = screen.height / 2; @@ -305,7 +358,7 @@ public void GetLeftEyeNoLensTanAngles(ref float[] result) { float screenLeft = (centerX - halfWidth) / centerZ; float screenTop = (centerY + halfHeight) / centerZ; float screenRight = (centerX + halfWidth) / centerZ; - float screenBottom = (centerY - halfWidth) / centerZ; + float screenBottom = (centerY - halfHeight) / centerZ; // Compare the two sets of tan-angles and take the value closer to zero on each side. result[0] = Math.Max(fovLeft, screenLeft); result[1] = Math.Min(fovTop, screenTop); @@ -313,6 +366,8 @@ public void GetLeftEyeNoLensTanAngles(ref float[] result) { result[3] = Math.Max(fovBottom, screenBottom); } + /// Calculates the screen rectangle visible from the left eye for the + /// current device and screen parameters. public Rect GetLeftEyeVisibleScreenRect(float[] undistortedFrustum) { float dist = device.lenses.screenDistance; float eyeX = (screen.width - device.lenses.separation) / 2; @@ -324,6 +379,12 @@ public Rect GetLeftEyeVisibleScreenRect(float[] undistortedFrustum) { return new Rect(left, bottom, right - left, top - bottom); } + public static float GetMaxRadius(float[] tanAngleRect) { + float x = Mathf.Max(Mathf.Abs(tanAngleRect[0]), Mathf.Abs(tanAngleRect[2])); + float y = Mathf.Max(Mathf.Abs(tanAngleRect[1]), Mathf.Abs(tanAngleRect[3])); + return Mathf.Sqrt(x * x + y * y); + } + // Solves a least-squares matrix equation. Given the equation A * x = y, calculate the // least-square fit x = inverse(A * transpose(A)) * transpose(A) * y. The way this works // is that, while A is typically not a square matrix (and hence not invertible), A * transpose(A) @@ -390,11 +451,13 @@ private static double[] solveLeastSquares(double[,] matA, double[] vecY) { return vecX; } + /// Calculates an approximate inverse to the given radial distortion parameters. public static Distortion ApproximateInverse(float k1, float k2, float maxRadius = 1, int numSamples = 10) { return ApproximateInverse(new Distortion { k1=k1, k2=k2 }, maxRadius, numSamples); } + /// Calculates an approximate inverse to the given radial distortion parameters. public static Distortion ApproximateInverse(Distortion distort, float maxRadius = 1, int numSamples = 10) { const int numCoefficients = 2; diff --git a/Cardboard/Scripts/CardboardUILayer.cs b/Cardboard/Scripts/CardboardUILayer.cs deleted file mode 100644 index 9b9b2ffc..00000000 --- a/Cardboard/Scripts/CardboardUILayer.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using UnityEngine; - -/// @ingroup Scripts -public class CardboardUILayer { - // The gear has 6 identical sections, each spanning 60 degrees. - const float kAnglePerGearSection = 60; - - // Half-angle of the span of the outer rim. - const float kOuterRimEndAngle = 12; - - // Angle between the middle of the outer rim and the start of the inner rim. - const float kInnerRimBeginAngle = 20; - - // Distance from center to outer rim, normalized so that the entire model - // fits in a [-1, 1] x [-1, 1] square. - const float kOuterRadius = 1; - - // Distance from center to depressed rim, in model units. - const float kMiddleRadius = 0.75f; - - // Radius of the inner hollow circle, in model units. - const float kInnerRadius = 0.3125f; - - // Center line thickness in DP. - const float kCenterLineThicknessDp = 4; - - // Button width in DP. - const int kButtonWidthDp = 28; - - // Factor to scale the touch area that responds to the touch. - const float kTouchSlopFactor = 1.5f; - - static readonly float[] Angles = { - 0, kOuterRimEndAngle, kInnerRimBeginAngle, - kAnglePerGearSection - kInnerRimBeginAngle, kAnglePerGearSection - kOuterRimEndAngle - }; - - private Material material; - private float centerWidthPx; - private float buttonWidthPx; - private float xScale; - private float yScale; - private Matrix4x4 xfm; - - private void ComputeMatrix() { - centerWidthPx = kCenterLineThicknessDp / 160.0f * Screen.dpi / 2; - buttonWidthPx = kButtonWidthDp / 160.0f * Screen.dpi / 2; - xScale = buttonWidthPx / Screen.width; - yScale = buttonWidthPx / Screen.height; - xfm = Matrix4x4.TRS(new Vector3(0.5f, yScale, 0), Quaternion.identity, - new Vector3(xScale, yScale, 1)); - } - - public CardboardUILayer() { - material = new Material(Shader.Find("Cardboard/SolidColor")); - material.color = new Color(0.8f, 0.8f, 0.8f); - if (!Application.isEditor) { - ComputeMatrix(); - } - } - - public void Draw() { - if (Cardboard.SDK.NativeUILayerSupported) { - return; - } - GL.Clear(true, false, Color.black); - material.SetPass(0); - if (Application.isEditor) { - ComputeMatrix(); - } - if (Cardboard.SDK.EnableAlignmentMarker) { - int x = Screen.width / 2; - int w = (int)centerWidthPx; - int h = (int)(2 * kTouchSlopFactor * buttonWidthPx); - GL.PushMatrix(); - GL.LoadPixelMatrix(); - GL.Begin(GL.QUADS); - GL.Vertex3(x - w, h, 0); - GL.Vertex3(x - w, Screen.height - h, 0); - GL.Vertex3(x + w, Screen.height - h, 0); - GL.Vertex3(x + w, h, 0); - GL.End(); - GL.PopMatrix(); - } -#if UNITY_EDITOR - if (Cardboard.SDK.EnableSettingsButton) { - GL.PushMatrix(); - GL.LoadOrtho(); - GL.MultMatrix(xfm); - GL.Begin(GL.TRIANGLE_STRIP); - for (int i = 0, n = Angles.Length * 6; i <= n; i++) { - float theta = (i / Angles.Length) * kAnglePerGearSection + Angles[i % Angles.Length]; - float angle = (90 - theta) * Mathf.Deg2Rad; - float x = Mathf.Cos(angle); - float y = Mathf.Sin(angle); - float mod = Mathf.PingPong(theta, kAnglePerGearSection / 2); - float lerp = (mod - kOuterRimEndAngle) / (kInnerRimBeginAngle - kOuterRimEndAngle); - float r = Mathf.Lerp(kOuterRadius, kMiddleRadius, lerp); - GL.Vertex3(kInnerRadius * x, kInnerRadius * y, 0); - GL.Vertex3(r * x, r * y, 0); - } - GL.End(); - GL.PopMatrix(); - } -#endif - } -} diff --git a/Cardboard/Scripts/GazeInputModule.cs b/Cardboard/Scripts/GazeInputModule.cs index 7e9ded39..571e5fd9 100644 --- a/Cardboard/Scripts/GazeInputModule.cs +++ b/Cardboard/Scripts/GazeInputModule.cs @@ -35,9 +35,8 @@ /// PhysicsRaycaster to the gazing camera, and add a component that implements one of the Event /// interfaces (EventTrigger will work nicely). The objects must have colliders too. /// -/// GazeInputModule emits the following events: _Enter_, _Exit_, _Down_, _Up_, -/// _Click_, _Select_, _Deselect_, and _UpdateSelected_. Scroll, drag and drop, -/// move, and submit/cancel events are not emitted. +/// GazeInputModule emits the following events: _Enter_, _Exit_, _Down_, _Up_, _Click_, _Select_, +/// _Deselect_, and _UpdateSelected_. Scroll, move, and submit/cancel events are not emitted. public class GazeInputModule : BaseInputModule { /// Determines whether gaze input is active in VR Mode only (`true`), or all of the /// time (`false`). Set to false if you plan to use direct screen taps or other @@ -52,6 +51,13 @@ public class GazeInputModule : BaseInputModule { "Be sure it is on a layer that raycasts will ignore.")] public GameObject cursor; + /// If cursor is not null, whether to show the cursor when a raycast occurs. + public bool showCursor = true; + + /// If cursor is to be shown, whether to scale its size in order to appear the same size visually + /// regardless of its distance. + public bool scaleCursorSize = true; + /// Time in seconds between the pointer down and up events sent by a magnet click. /// Allows time for the UI elements to make their state transitions. [HideInInspector] @@ -63,7 +69,9 @@ public class GazeInputModule : BaseInputModule { public Vector2 hotspot = new Vector2(0.5f, 0.5f); private PointerEventData pointerData; + private Vector2 lastHeadPose; + /// @cond HIDDEN public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return false; @@ -92,19 +100,38 @@ public override void Process() { CastRayFromGaze(); UpdateCurrentObject(); PlaceCursor(); - HandlePendingClick(); - HandleTrigger(); + + if (!Cardboard.SDK.TapIsTrigger && !Input.GetMouseButtonDown(0) && Input.GetMouseButton(0)) { + // Drag is only supported if TapIsTrigger is false. + HandleDrag(); + } else if (Time.unscaledTime - pointerData.clickTime < clickTime) { + // Delay new events until clickTime has passed. + } else if (!pointerData.eligibleForClick && + (Cardboard.SDK.Triggered || !Cardboard.SDK.TapIsTrigger && Input.GetMouseButtonDown(0))) { + // New trigger action. + HandleTrigger(); + } else if (!Cardboard.SDK.Triggered && !Input.GetMouseButton(0)) { + // Check if there is a pending click to handle. + HandlePendingClick(); + } } + /// @endcond private void CastRayFromGaze() { + Vector2 headPose = NormalizedCartesianToSpherical(Cardboard.SDK.HeadPose.Orientation * Vector3.forward); + if (pointerData == null) { pointerData = new PointerEventData(eventSystem); + lastHeadPose = headPose; } + pointerData.Reset(); pointerData.position = new Vector2(hotspot.x * Screen.width, hotspot.y * Screen.height); eventSystem.RaycastAll(pointerData, m_RaycastResultCache); pointerData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache); m_RaycastResultCache.Clear(); + pointerData.delta = headPose - lastHeadPose; + lastHeadPose = headPose; } private void UpdateCurrentObject() { @@ -123,62 +150,106 @@ private void UpdateCurrentObject() { } private void PlaceCursor() { - if (cursor == null) + if (cursor == null) { return; + } var go = pointerData.pointerCurrentRaycast.gameObject; - cursor.SetActive(go != null); + Camera cam = pointerData.enterEventCamera; // Will be null for overlay hits. + cursor.SetActive(go != null && cam != null && showCursor); if (cursor.activeInHierarchy) { - Camera cam = pointerData.enterEventCamera; // Note: rays through screen start at near clipping plane. float dist = pointerData.pointerCurrentRaycast.distance + cam.nearClipPlane; cursor.transform.position = cam.transform.position + cam.transform.forward * dist; + if (scaleCursorSize) { + cursor.transform.localScale = Vector3.one * dist; + } } } - private void HandlePendingClick() { - if (!pointerData.eligibleForClick) { - return; + private void HandleDrag() { + bool moving = pointerData.IsPointerMoving(); + + if (moving && pointerData.pointerDrag != null && !pointerData.dragging) { + ExecuteEvents.Execute(pointerData.pointerDrag, pointerData, ExecuteEvents.beginDragHandler); + pointerData.dragging = true; } - bool triggerStillDown = !Cardboard.SDK.Triggered - && Time.unscaledTime - pointerData.clickTime < clickTime; - if (!Cardboard.SDK.TapIsTrigger) { - // Screen touch also counts, as long as it didn't start on this frame. - triggerStillDown |= !Input.GetMouseButtonDown(0) && Input.GetMouseButton(0); + + // Drag notification + if (pointerData.dragging && moving && pointerData.pointerDrag != null) { + // Before doing drag we should cancel any pointer down state + // And clear selection! + if (pointerData.pointerPress != pointerData.pointerDrag) { + ExecuteEvents.Execute(pointerData.pointerPress, pointerData, ExecuteEvents.pointerUpHandler); + + pointerData.eligibleForClick = false; + pointerData.pointerPress = null; + pointerData.rawPointerPress = null; + } + ExecuteEvents.Execute(pointerData.pointerDrag, pointerData, ExecuteEvents.dragHandler); } - if (triggerStillDown) { + } + + private void HandlePendingClick() { + if (!pointerData.eligibleForClick) { return; } + var go = pointerData.pointerCurrentRaycast.gameObject; // Send pointer up and click events. ExecuteEvents.Execute(pointerData.pointerPress, pointerData, ExecuteEvents.pointerUpHandler); ExecuteEvents.Execute(pointerData.pointerPress, pointerData, ExecuteEvents.pointerClickHandler); + if (pointerData.pointerDrag != null) { + ExecuteEvents.ExecuteHierarchy(go, pointerData, ExecuteEvents.dropHandler); + } + + if (pointerData.pointerDrag != null && pointerData.dragging) { + ExecuteEvents.Execute(pointerData.pointerDrag, pointerData, ExecuteEvents.endDragHandler); + } + // Clear the click state. pointerData.pointerPress = null; pointerData.rawPointerPress = null; pointerData.eligibleForClick = false; pointerData.clickCount = 0; + pointerData.pointerDrag = null; + pointerData.dragging = false; } private void HandleTrigger() { - bool triggered = Cardboard.SDK.Triggered - || !Cardboard.SDK.TapIsTrigger && Input.GetMouseButtonDown(0); - if (!triggered) { - return; - } var go = pointerData.pointerCurrentRaycast.gameObject; // Send pointer down event. pointerData.pressPosition = pointerData.position; pointerData.pointerPressRaycast = pointerData.pointerCurrentRaycast; pointerData.pointerPress = - ExecuteEvents.ExecuteHierarchy(go, pointerData, ExecuteEvents.pointerDownHandler) + ExecuteEvents.ExecuteHierarchy(go, pointerData, ExecuteEvents.pointerDownHandler) ?? ExecuteEvents.GetEventHandler(go); + // Save the drag handler as well + pointerData.pointerDrag = ExecuteEvents.GetEventHandler(go); + if (pointerData.pointerDrag != null && !Cardboard.SDK.TapIsTrigger) { + ExecuteEvents.Execute(pointerData.pointerDrag, pointerData, ExecuteEvents.initializePotentialDrag); + } + // Save the pending click state. pointerData.rawPointerPress = go; pointerData.eligibleForClick = true; + pointerData.delta = Vector2.zero; + pointerData.dragging = false; + pointerData.useDragThreshold = true; pointerData.clickCount = 1; pointerData.clickTime = Time.unscaledTime; } + + private Vector2 NormalizedCartesianToSpherical(Vector3 cartCoords) { + cartCoords.Normalize(); + if (cartCoords.x == 0) + cartCoords.x = Mathf.Epsilon; + float outPolar = Mathf.Atan(cartCoords.z / cartCoords.x); + if (cartCoords.x < 0) + outPolar += Mathf.PI; + float outElevation = Mathf.Asin(cartCoords.y); + return new Vector2(outPolar, outElevation); + } } diff --git a/Cardboard/Scripts/Pose3D.cs b/Cardboard/Scripts/Pose3D.cs index fee25b29..511eada2 100644 --- a/Cardboard/Scripts/Pose3D.cs +++ b/Cardboard/Scripts/Pose3D.cs @@ -15,7 +15,7 @@ /// @ingroup Scripts /// Encapsulates a rotation and a translation. This is a convenience class that allows -/// construction and value access either by Matrix4x4 or Quaternion+Vector3 types. +/// construction and value access either by Matrix4x4 or Quaternion + Vector3 types. public class Pose3D { /// Right-handed to left-handed matrix converter (and vice versa). protected static readonly Matrix4x4 flipZ = Matrix4x4.Scale(new Vector3(1, 1, -1)); @@ -36,16 +36,20 @@ public Matrix4x4 RightHandedMatrix { } } + /// Default constructor. + /// Initializes position to the origin and orientation to the identity rotation. public Pose3D() { Position = Vector3.zero; Orientation = Quaternion.identity; Matrix = Matrix4x4.identity; } + /// Constructor that takes a Vector3 and a Quaternion. public Pose3D(Vector3 position, Quaternion orientation) { Set(position, orientation); } + /// Constructor that takes a Matrix4x4. public Pose3D(Matrix4x4 matrix) { Set(matrix); } @@ -65,14 +69,17 @@ protected void Set(Matrix4x4 matrix) { /// Mutable version of Pose3D. public class MutablePose3D : Pose3D { + /// Sets the position and orientation from a Vector3 + Quaternion. public new void Set(Vector3 position, Quaternion orientation) { base.Set(position, orientation); } + /// Sets the position and orientation from a Matrix4x4. public new void Set(Matrix4x4 matrix) { base.Set(matrix); } + /// Sets the position and orientation from a right-handed Matrix4x4. public void SetRightHanded(Matrix4x4 matrix) { Set(flipZ * matrix * flipZ); } diff --git a/Cardboard/Scripts/RadialUndistortionEffect.cs b/Cardboard/Scripts/RadialUndistortionEffect.cs index 855424ab..e51613ba 100644 --- a/Cardboard/Scripts/RadialUndistortionEffect.cs +++ b/Cardboard/Scripts/RadialUndistortionEffect.cs @@ -27,16 +27,9 @@ [RequireComponent(typeof(Camera))] public class RadialUndistortionEffect : MonoBehaviour { -#if UNITY_EDITOR - private StereoController controller; -#endif private Material material; void Awake() { - if (!SystemInfo.supportsRenderTextures) { - Debug.Log("Radial Undistortion disabled: render textures not supported."); - return; - } Shader shader = Shader.Find("Cardboard/Radial Undistortion"); if (shader == null) { Debug.Log("Radial Undistortion disabled: shader not found."); @@ -45,29 +38,7 @@ void Awake() { material = new Material(shader); } -#if UNITY_EDITOR - void Start() { - var eye = GetComponent(); - if (eye != null) { - controller = eye.Controller; - } - } -#endif - void OnRenderImage(RenderTexture source, RenderTexture dest) { - // Check if we found our shader, and that native distortion correction is OFF (except maybe in - // the editor, since native is not available here). - bool disabled = material == null || !Cardboard.SDK.UseDistortionEffect; -#if UNITY_EDITOR - bool mainCamera = controller != null && controller.GetComponent().tag == "MainCamera"; - disabled |= !mainCamera; -#endif - if (disabled) { - // Pass through, no effect. - Graphics.Blit(source, dest); - } else { - // Undistort the image. - Graphics.Blit(source, dest, material); - } + Graphics.Blit(source, dest, material); } } diff --git a/Cardboard/Scripts/StereoController.cs b/Cardboard/Scripts/StereoController.cs index a72fa676..7158a31b 100644 --- a/Cardboard/Scripts/StereoController.cs +++ b/Cardboard/Scripts/StereoController.cs @@ -61,6 +61,16 @@ public class StereoController : MonoBehaviour { " Effects and Deferred Lighting may only work if set to false.")] public bool directRender = true; + /// When enabled, UpdateStereoValues() is called every frame to keep the stereo cameras + /// completely synchronized with both the mono camera and the device profile. When + /// disabled, you must call UpdateStereoValues() whenever you make a change to the mono + /// camera that should be mirrored to the stereo cameras. Changes to the device profile + /// are handled automatically. It is better for performance to leave this option disabled + /// whenever possible. Good use cases for enabling it are when animating values on the + /// mono camera (like background color), or during development to debug camera synchronization + /// issues. + public bool keepStereoUpdated = false; + /// Adjusts the level of stereopsis for this stereo rig. /// @note This parameter is not the virtual size of the head -- use a scale /// on the head game object for that. Instead, it is a control on eye vergence, @@ -133,6 +143,12 @@ public class StereoController : MonoBehaviour { [Tooltip("Adjust stereo level when COI gets too close or too far.")] public bool checkStereoComfort = true; + /// Smoothes the changes to the stereo camera FOV and position based on #centerOfInterest + /// and #checkStereoComfort. + [Tooltip("Smoothing factor to use when adjusting stereo for COI and comfort.")] + [Range(0,1)] + public float stereoAdjustSmoothing = 0.1f; + /// For picture-in-picture cameras that don't fill the entire screen, /// set the virtual depth of the window itself. A value of 0 means /// zero parallax, which is fairly close. A value of 1 means "full" @@ -167,6 +183,7 @@ public class StereoController : MonoBehaviour { #if !UNITY_EDITOR // Cache for speed, except in editor (don't want to get out of sync with the scene). private CardboardEye[] eyes; + private CardboardHead head; #endif /// Returns an array of stereo cameras that are controlled by this instance of @@ -187,55 +204,71 @@ public CardboardEye[] Eyes { } } - /// Clear the cached array of CardboardEye children. + /// Returns the nearest CardboardHead that affects our eyes. + public CardboardHead Head { + get { +#if UNITY_EDITOR + CardboardHead head = null; // Local variable rather than member, so as not to cache. +#endif + if (head == null) { + head = Eyes.Select(eye => eye.Head).FirstOrDefault(); + } + return head; + } + } + + /// Clear the cached array of CardboardEye children, as well as the CardboardHead that controls + /// their gaze. /// @note Be sure to call this if you programmatically change the set of CardboardEye children /// managed by this StereoController. public void InvalidateEyes() { #if !UNITY_EDITOR eyes = null; + head = null; #endif } - /// Returns the nearest CardboardHead that affects our eyes. - public CardboardHead Head { - get { - return Eyes.Select(eye => eye.Head).FirstOrDefault(); - } - } - - /// Returns the target texture that the eyes will render into. This is the mono - /// camera’s target texture, if it has one, or else Cardboard#StereoScreen. - public RenderTexture StereoScreen { - get { - return GetComponent().targetTexture ?? Cardboard.SDK.StereoScreen; + /// Updates the stereo cameras from the mono camera every frame. This includes all Camera + /// component values such as background color, culling mask, viewport rect, and so on. Also, + /// it includes updating the viewport rect and projection matrix for side-by-side stereo, plus + /// applying any adjustments for center of interest and stereo comfort. + public void UpdateStereoValues() { + CardboardEye[] eyes = Eyes; + for (int i = 0, n = eyes.Length; i < n; i++) { + eyes[i].UpdateStereoValues(); } } - // In the Unity editor, at the point we need it, the Screen.height oddly includes the tab bar - // at the top of the Game window. So subtract that out. - private int ScreenHeight { - get { - return Screen.height - (Application.isEditor && StereoScreen == null ? 36 : 0); - } - } +#if UNITY_5 + new public Camera camera { get; private set; } +#endif void Awake() { AddStereoRig(); +#if UNITY_5 + camera = GetComponent(); +#endif } /// Helper routine for creation of a stereo rig. Used by the /// custom editor for this class, or to build the rig at runtime. public void AddStereoRig() { - if (Eyes.Length > 0) { // Simplistic test if rig already exists. + // Simplistic test if rig already exists. + // Note: Do not use Eyes property, because it caches the result before we have created the rig. + var eyes = GetComponentsInChildren(true).Where(eye => eye.Controller == this); + if (eyes.Any()) { return; } CreateEye(Cardboard.Eye.Left); CreateEye(Cardboard.Eye.Right); if (Head == null) { - gameObject.AddComponent(); + var head = gameObject.AddComponent(); + // Don't track position for dynamically added Head components, or else + // you may unexpectedly find your camera pinned to the origin. + head.trackPosition = false; } #if !UNITY_5 - if (GetComponent().tag == "MainCamera" && GetComponent() == null) { + if (camera.tag == "MainCamera" && GetComponent() == null) { gameObject.AddComponent(); } #endif @@ -248,9 +281,6 @@ private void CreateEye(Cardboard.Eye eye) { go.transform.parent = transform; go.AddComponent().enabled = false; #if !UNITY_5 - if (GetComponent() != null) { - go.AddComponent(); - } if (GetComponent("FlareLayer") != null) { go.AddComponent("FlareLayer"); } @@ -260,23 +290,19 @@ private void CreateEye(Cardboard.Eye eye) { cardboardEye.CopyCameraAndMakeSideBySide(this); } - /// Given information about a specific camera (usually one of the stereo eyes), - /// computes an adjustment to the stereo settings for both FOV matching and - /// stereo comfort. The input is the [1,1] entry of the camera's projection - /// matrix, representing the vertical field of view, and the overall scale - /// being applied to the Z axis. The output is a multiplier of the IPD to - /// use for offseting the eyes laterally, and an offset in the eye's Z direction - /// to account for the FOV difference. The eye offset is in local coordinates. - public void ComputeStereoAdjustment(float proj11, float zScale, - out float ipdScale, out float eyeOffset) { - ipdScale = stereoMultiplier; - eyeOffset = 0; + /// Compute the position of one of the stereo eye cameras. Accounts for both + /// FOV matching and stereo comfort, if those features are enabled. The input is + /// the [1,1] entry of the eye camera's projection matrix, representing the vertical + /// field of view, and the overall scale being applied to the Z axis. Returns the + /// position of the stereo eye camera in local coordinates. + public Vector3 ComputeStereoEyePosition(Cardboard.Eye eye, float proj11, float zScale) { if (centerOfInterest == null || !centerOfInterest.gameObject.activeInHierarchy) { - return; + return Cardboard.SDK.EyePose(eye).Position * stereoMultiplier; } // Distance of COI relative to head. - float distance = (centerOfInterest.position - transform.position).magnitude; + float distance = centerOfInterest != null ? + (centerOfInterest.position - transform.position).magnitude : 0; // Size of the COI, clamped to [0..distance] for mathematical sanity in following equations. float radius = Mathf.Clamp(radiusOfInterest, 0, distance); @@ -284,13 +310,14 @@ public void ComputeStereoAdjustment(float proj11, float zScale, // Move the eye so that COI has about the same size onscreen as in the mono camera FOV. // The radius affects the horizon location, which is where the screen-size matching has to // occur. - float scale = proj11 / GetComponent().projectionMatrix[1, 1]; // vertical FOV + float scale = proj11 / camera.projectionMatrix[1, 1]; // vertical FOV float offset = Mathf.Sqrt(radius * radius + (distance * distance - radius * radius) * scale * scale); - eyeOffset = (distance - offset) * Mathf.Clamp01(matchMonoFOV) / zScale; + float eyeOffset = (distance - offset) * Mathf.Clamp01(matchMonoFOV) / zScale; - // Manage IPD scale based on the distance to the COI. + float ipdScale = stereoMultiplier; if (checkStereoComfort) { + // Manage IPD scale based on the distance to the COI. float minComfort = Cardboard.SDK.ComfortableViewingRange.x; float maxComfort = Cardboard.SDK.ComfortableViewingRange.y; if (minComfort < maxComfort) { // Sanity check. @@ -301,6 +328,8 @@ public void ComputeStereoAdjustment(float proj11, float zScale, ipdScale *= minDistance / Mathf.Clamp(minDistance, minComfort, maxComfort); } } + + return ipdScale * Cardboard.SDK.EyePose(eye).Position + eyeOffset * Vector3.forward; } void OnEnable() { @@ -312,33 +341,31 @@ void OnDisable() { } void OnPreCull() { - if (!Cardboard.SDK.VRModeEnabled) { - // Nothing to do. - return; - } - - Cardboard.SDK.UpdateState(); - - // Turn off the mono camera so it doesn't waste time rendering. - // @note mono camera is left on from beginning of frame till now - // in order that other game logic (e.g. Camera.main) continues - // to work as expected. - GetComponent().enabled = false; - - // Render the eyes under our control. - foreach (var eye in Eyes) { - eye.Render(); + if (Cardboard.SDK.VRModeEnabled) { + // Activate the eyes under our control. + CardboardEye[] eyes = Eyes; + for (int i = 0, n = eyes.Length; i < n; i++) { + eyes[i].camera.enabled = true; + } + // Turn off the mono camera so it doesn't waste time rendering. Remember to reenable. + // @note The mono camera is left on from beginning of frame till now in order that other game + // logic (e.g. referring to Camera.main) continues to work as expected. + camera.enabled = false; + renderedStereo = true; + } else { + Cardboard.SDK.UpdateState(); + // Make sure any vertex-distorting shaders don't break completely. + Shader.SetGlobalMatrix("_RealProjection", camera.projectionMatrix); + Shader.SetGlobalMatrix("_FixProjection", camera.cameraToWorldMatrix); + Shader.SetGlobalFloat("_NearClip", camera.nearClipPlane); } - - // Remember to reenable. - renderedStereo = true; } IEnumerator EndOfFrame() { while (true) { // If *we* turned off the mono cam, turn it back on for next frame. if (renderedStereo) { - GetComponent().enabled = true; + camera.enabled = true; renderedStereo = false; } yield return new WaitForEndOfFrame(); diff --git a/Cardboard/Scripts/StereoRenderEffect.cs b/Cardboard/Scripts/StereoRenderEffect.cs new file mode 100644 index 00000000..254f693d --- /dev/null +++ b/Cardboard/Scripts/StereoRenderEffect.cs @@ -0,0 +1,48 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnityEngine; + +[RequireComponent(typeof(Camera))] +public class StereoRenderEffect : MonoBehaviour { + private Material material; + +#if UNITY_5 + private new Camera camera; + + void Awake() { + camera = GetComponent(); + } +#endif + + void Start() { + material = new Material(Shader.Find("Cardboard/SkyboxMesh")); + } + + void OnRenderImage(RenderTexture source, RenderTexture dest) { + GL.PushMatrix(); + int width = dest ? dest.width : Screen.width; + int height = dest ? dest.height : Screen.height; + GL.LoadPixelMatrix(0, width, height, 0); + // Camera rects are in screen coordinates (bottom left is origin), but DrawTexture takes a + // rect in GUI coordinates (top left is origin). + Rect blitRect = camera.pixelRect; + blitRect.y = height - blitRect.height - blitRect.y; + RenderTexture oldActive = RenderTexture.active; + RenderTexture.active = dest; + Graphics.DrawTexture(blitRect, source, material); + RenderTexture.active = oldActive; + GL.PopMatrix(); + } +} diff --git a/Cardboard/Scripts/VRDevices/BaseAndroidDevice.cs b/Cardboard/Scripts/VRDevices/BaseAndroidDevice.cs index 6c76f244..95d83a22 100644 --- a/Cardboard/Scripts/VRDevices/BaseAndroidDevice.cs +++ b/Cardboard/Scripts/VRDevices/BaseAndroidDevice.cs @@ -46,6 +46,15 @@ protected virtual void ConnectToActivity() { } } + protected AndroidJavaClass GetClass(string className) { + try { + return new AndroidJavaClass(className); + } catch (AndroidJavaException e) { + Debug.LogError("Exception getting class " + className + ": " + e); + return null; + } + } + protected AndroidJavaObject Create(string className, params object[] args) { try { return new AndroidJavaObject(className, args); @@ -55,6 +64,20 @@ protected AndroidJavaObject Create(string className, params object[] args) { } } + protected static bool CallStaticMethod(AndroidJavaObject jo, string name, params object[] args) { + if (jo == null) { + Debug.LogError("Object is null when calling static method " + name); + return false; + } + try { + jo.CallStatic(name, args); + return true; + } catch (AndroidJavaException e) { + Debug.LogError("Exception calling static method " + name + ": " + e); + return false; + } + } + protected static bool CallObjectMethod(AndroidJavaObject jo, string name, params object[] args) { if (jo == null) { Debug.LogError("Object is null when calling method " + name); @@ -69,6 +92,21 @@ protected static bool CallObjectMethod(AndroidJavaObject jo, string name, params } } + protected static bool CallStaticMethod(ref T result, AndroidJavaObject jo, string name, + params object[] args) { + if (jo == null) { + Debug.LogError("Object is null when calling static method " + name); + return false; + } + try { + result = jo.CallStatic(name, args); + return true; + } catch (AndroidJavaException e) { + Debug.LogError("Exception calling static method " + name + ": " + e); + return false; + } + } + protected static bool CallObjectMethod(ref T result, AndroidJavaObject jo, string name, params object[] args) { if (jo == null) { diff --git a/Cardboard/Scripts/VRDevices/BaseCardboardDevice.cs b/Cardboard/Scripts/VRDevices/BaseCardboardDevice.cs index dc471d63..68af8006 100644 --- a/Cardboard/Scripts/VRDevices/BaseCardboardDevice.cs +++ b/Cardboard/Scripts/VRDevices/BaseCardboardDevice.cs @@ -25,14 +25,17 @@ public abstract class BaseCardboardDevice : BaseVRDevice #endif { + // A relatively unique id to use when calling our C++ native render plugin. + private const int kCardboardRenderEvent = 0x47554342; + // Event IDs sent up from native layer. private const int kTriggered = 1; private const int kTilted = 2; private const int kProfileChanged = 3; - private const int kLaunchSettingsDialog = 4; + private const int kVRBackButton = 4; private float[] headData = new float[16]; - private float[] viewData = new float[16 * 6 + 8]; + private float[] viewData = new float[16 * 6 + 10]; private float[] profileData = new float[13]; private Matrix4x4 headView = new Matrix4x4(); @@ -54,23 +57,10 @@ public override bool SupportsNativeDistortionCorrection(List diagnostics return supported; } - public override bool SupportsNativeUILayer(List diagnostics) { - bool supported = base.SupportsNativeUILayer(diagnostics); - if (debugDisableNativeUILayer) { - supported = false; - diagnostics.Add("Debug override"); - } - return supported; - } - public override void SetDistortionCorrectionEnabled(bool enabled) { EnableDistortionCorrection(enabled); } - public override void SetAlignmentMarkerEnabled(bool enabled) { - EnableAlignmentMarker(enabled); - } - public override void SetNeckModelScale(float scale) { SetNeckModelFactor(scale); } @@ -79,25 +69,37 @@ public override void SetAutoDriftCorrectionEnabled(bool enabled) { EnableAutoDriftCorrection(enabled); } - public void SetElectronicDisplayStabilizationEnabled(bool enabled) { + public override void SetElectronicDisplayStabilizationEnabled(bool enabled) { EnableElectronicDisplayStabilization(enabled); } + public override bool SetDefaultDeviceProfile(System.Uri uri) { + byte[] profile = System.Text.Encoding.UTF8.GetBytes(uri.ToString()); + return SetDefaultProfile(profile, profile.Length); + } + public override void Init() { - // Get landscape dimensions, even if app starts in portrait. - int width = Mathf.Max(Screen.width, Screen.height); - int height = Mathf.Min(Screen.height, Screen.width); + DisplayMetrics dm = GetDisplayMetrics(); + Start(dm.width, dm.height, dm.xdpi, dm.ydpi); + + byte[] version = System.Text.Encoding.UTF8.GetBytes(Application.unityVersion); + SetUnityVersion(version, version.Length); - Start(width, height, Screen.dpi, Screen.dpi); SetEventCallback(OnVREvent); } public override void SetStereoScreen(RenderTexture stereoScreen) { +#if UNITY_5 || !UNITY_IOS + SetTextureId(stereoScreen != null ? (int)stereoScreen.GetNativeTexturePtr() : 0); +#else + // Using old API for Unity 4.x and iOS because Metal crashes on GetNativeTexturePtr() SetTextureId(stereoScreen != null ? stereoScreen.GetNativeTextureID() : 0); +#endif } public override void UpdateState() { - GetHeadPose(headData, Time.smoothDeltaTime); + ProcessEvents(); + GetHeadPose(headData); ExtractMatrix(ref headView, headData); headPose.SetRightHanded(headView.inverse); } @@ -109,18 +111,23 @@ public override void UpdateScreenData() { } else { UpdateView(); } + profileChanged = true; } public override void Recenter() { ResetHeadTracker(); } - public override void PostRender(bool vrMode) { - if (vrMode) { - GL.IssuePluginEvent(0); - GL.InvalidateState(); + public override void PostRender() { + GL.IssuePluginEvent(kCardboardRenderEvent); + } + + public override void OnPause(bool pause) { + if (pause) { + Pause(); + } else { + Resume(); } - ProcessEvents(); } public override void OnApplicationQuit() { @@ -149,6 +156,9 @@ private void UpdateView() { rightEyeUndistortedViewport.Set(viewData[j], viewData[j+1], viewData[j+2], viewData[j+3]); rightEyeDistortedViewport = rightEyeUndistortedViewport; j += 4; + + recommendedTextureSize = new Vector2(viewData[j], viewData[j+1]); + j += 2; } private void UpdateProfile() { @@ -183,21 +193,23 @@ private static int ExtractMatrix(ref Matrix4x4 mat, float[] data, int i = 0) { return i; } + private int[] events = new int[4]; + protected virtual void ProcessEvents() { - int[] events = null; + int num = 0; lock (eventQueue) { - int num = eventQueue.Count; - if (num > 0) { + num = eventQueue.Count; + if (num == 0) { + return; + } + if (num > events.Length) { events = new int[num]; - eventQueue.CopyTo(events, 0); - eventQueue.Clear(); } + eventQueue.CopyTo(events, 0); + eventQueue.Clear(); } - if (events == null) { - return; - } - foreach (int eventID in events) { - switch (eventID) { + for (int i = 0; i < num; i++) { + switch (events[i]) { case kTriggered: triggered = true; break; @@ -207,6 +219,9 @@ protected virtual void ProcessEvents() { case kProfileChanged: UpdateScreenData(); break; + case kVRBackButton: + backButtonPressed = true; + break; } } } @@ -215,7 +230,7 @@ protected virtual void ProcessEvents() { private static void OnVREvent(int eventID) { BaseCardboardDevice device = GetDevice() as BaseCardboardDevice; // This function is called back from random native code threads. - lock(device.eventQueue) { + lock (device.eventQueue) { device.eventQueue.Enqueue(eventID); } } @@ -238,10 +253,13 @@ private static void OnVREvent(int eventID) { private static extern void SetTextureId(int id); [DllImport(dllName)] - private static extern void EnableDistortionCorrection(bool enable); + private static extern bool SetDefaultProfile(byte[] uri, int size); + + [DllImport(dllName)] + private static extern void SetUnityVersion(byte[] version_str, int version_length); [DllImport(dllName)] - private static extern void EnableAlignmentMarker(bool enable); + private static extern void EnableDistortionCorrection(bool enable); [DllImport(dllName)] private static extern void EnableAutoDriftCorrection(bool enable); @@ -259,11 +277,17 @@ private static void OnVREvent(int eventID) { private static extern void GetProfile(float[] profile); [DllImport(dllName)] - private static extern void GetHeadPose(float[] pose, float fps); + private static extern void GetHeadPose(float[] pose); [DllImport(dllName)] private static extern void GetViewParameters(float[] viewParams); + [DllImport(dllName)] + private static extern void Pause(); + + [DllImport(dllName)] + private static extern void Resume(); + [DllImport(dllName)] private static extern void Stop(); } diff --git a/Cardboard/Scripts/VRDevices/BaseVRDevice.cs b/Cardboard/Scripts/VRDevices/BaseVRDevice.cs index b1216c64..c55ce801 100644 --- a/Cardboard/Scripts/VRDevices/BaseVRDevice.cs +++ b/Cardboard/Scripts/VRDevices/BaseVRDevice.cs @@ -28,6 +28,11 @@ // Represents a vr device that this plugin interacts with. // Please do not interact with this class directly, instead use the interface in Cardboard.cs. public abstract class BaseVRDevice { + public struct DisplayMetrics { + public int width, height; + public float xdpi, ydpi; + } + private static BaseVRDevice device = null; protected BaseVRDevice() { @@ -38,14 +43,27 @@ protected BaseVRDevice() { public abstract void Init(); - public abstract void SetDistortionCorrectionEnabled(bool enabled); public abstract void SetVRModeEnabled(bool enabled); - public abstract void SetAlignmentMarkerEnabled(bool enabled); + public abstract void SetDistortionCorrectionEnabled(bool enabled); + public abstract void SetStereoScreen(RenderTexture stereoScreen); + public abstract void SetSettingsButtonEnabled(bool enabled); + public abstract void SetAlignmentMarkerEnabled(bool enabled); + public abstract void SetVRBackButtonEnabled(bool enabled); + public abstract void SetShowVrBackButtonOnlyInVR(bool only); + public abstract void SetTapIsTrigger(bool enabled); public abstract void SetNeckModelScale(float scale); public abstract void SetAutoDriftCorrectionEnabled(bool enabled); - public abstract void SetStereoScreen(RenderTexture stereoScreen); + public abstract void SetElectronicDisplayStabilizationEnabled(bool enabled); + + // Returns landscape orientation display metrics. + public virtual DisplayMetrics GetDisplayMetrics() { + // Always return landscape orientation. + int width = Mathf.Max(Screen.width, Screen.height); + int height = Mathf.Min(Screen.width, Screen.height); + return new DisplayMetrics { width = width, height = height, xdpi = Screen.dpi, ydpi = Screen.dpi }; + } public virtual bool SupportsNativeDistortionCorrection(List diagnostics) { bool support = true; @@ -61,12 +79,7 @@ public virtual bool SupportsNativeDistortionCorrection(List diagnostics) } public virtual bool SupportsNativeUILayer(List diagnostics) { - bool support = true; - if (!SupportsUnityRenderEvent()) { - diagnostics.Add("Unity 4.5+ is needed for UnityRenderEvent"); - support = false; - } - return support; + return true; } public bool SupportsUnityRenderEvent() { @@ -85,10 +98,19 @@ public bool SupportsUnityRenderEvent() { } public virtual RenderTexture CreateStereoScreen() { - Debug.Log("Creating new default cardboard screen texture."); - return new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.RGB565); + float scale = Cardboard.SDK.StereoScreenScale; + int width = Mathf.RoundToInt(recommendedTextureSize.x * scale); + int height = Mathf.RoundToInt(recommendedTextureSize.y * scale); + Debug.Log("Creating new default cardboard screen texture " + + width+ "x" + height + "."); + var rt = new RenderTexture(width, height, 24, RenderTextureFormat.Default); + rt.anisoLevel = 0; + rt.antiAliasing = Mathf.Max(QualitySettings.antiAliasing, 1); + return rt; } + // Returns true if the URI was set as the device profile, else false. A default URI + // is only accepted if the user has not scanned a QR code already. public virtual bool SetDefaultDeviceProfile(Uri uri) { return false; } @@ -151,8 +173,12 @@ public Rect GetViewport(Cardboard.Eye eye, protected Rect leftEyeUndistortedViewport; protected Rect rightEyeUndistortedViewport; + protected Vector2 recommendedTextureSize; + public bool triggered; public bool tilted; + public bool profileChanged; + public bool backButtonPressed; public abstract void UpdateState(); @@ -160,7 +186,7 @@ public Rect GetViewport(Cardboard.Eye eye, public abstract void Recenter(); - public abstract void PostRender(bool vrMode); + public abstract void PostRender(); public virtual void SetTouchCoordinates(int x, int y) { // Do nothing @@ -176,8 +202,8 @@ public virtual void OnFocus(bool focus) { // Do nothing. } - public virtual void Reset() { - Recenter(); + public virtual void OnLevelLoaded(int level) { + // Do nothing. } public virtual void OnApplicationQuit() { @@ -198,9 +224,9 @@ protected void ComputeEyesFromProfile() { leftEyePose.Set(leftEyeView); float[] rect = new float[4]; - Profile.GetLeftEyeVisibleTanAngles(ref rect); + Profile.GetLeftEyeVisibleTanAngles(rect); leftEyeDistortedProjection = MakeProjection(rect[0], rect[1], rect[2], rect[3], 1, 1000); - Profile.GetLeftEyeNoLensTanAngles(ref rect); + Profile.GetLeftEyeNoLensTanAngles(rect); leftEyeUndistortedProjection = MakeProjection(rect[0], rect[1], rect[2], rect[3], 1, 1000); leftEyeUndistortedViewport = Profile.GetLeftEyeVisibleScreenRect(rect); @@ -219,6 +245,11 @@ protected void ComputeEyesFromProfile() { rightEyeUndistortedViewport = leftEyeUndistortedViewport; rightEyeUndistortedViewport.x = 1 - rightEyeUndistortedViewport.xMax; rightEyeDistortedViewport = rightEyeUndistortedViewport; + + float width = Screen.width * (leftEyeUndistortedViewport.width+rightEyeDistortedViewport.width); + float height = Screen.height * Mathf.Max(leftEyeUndistortedViewport.height, + rightEyeUndistortedViewport.height); + recommendedTextureSize = new Vector2(width, height); } private static Matrix4x4 MakeProjection(float l, float t, float r, float b, float n, float f) { diff --git a/Cardboard/Scripts/VRDevices/CardboardAndroidDevice.cs b/Cardboard/Scripts/VRDevices/CardboardAndroidDevice.cs index 7e76f82d..cad5c795 100644 --- a/Cardboard/Scripts/VRDevices/CardboardAndroidDevice.cs +++ b/Cardboard/Scripts/VRDevices/CardboardAndroidDevice.cs @@ -16,9 +16,13 @@ using UnityEngine; public class CardboardAndroidDevice : BaseCardboardDevice { + private const string ActivityListenerClass = + "com.google.vr.platform.unity.UnityVrActivityListener"; + private static AndroidJavaObject activityListener; public override void Init() { + SetApplicationState(); base.Init(); ConnectToActivity(); } @@ -26,9 +30,28 @@ public override void Init() { protected override void ConnectToActivity() { base.ConnectToActivity(); if (androidActivity != null && activityListener == null) { - TextAsset button = Resources.Load("CardboardSettingsButton.png"); - activityListener = Create("com.google.vr.platform.unity.UnityVrActivityListener", - button.bytes); + activityListener = Create(ActivityListenerClass); + } + } + + // Returns landscape orientation display metrics. + public override DisplayMetrics GetDisplayMetrics() { + using (var listenerClass = GetClass(ActivityListenerClass)) { + // Sadly some Android devices still don't report accurate values. If this + // doesn't work correctly on your device, comment out this function to try + // the Unity implementation. + float[] metrics = listenerClass.CallStatic("getDisplayMetrics"); + // Always return landscape orientation. + int width, height; + if (metrics[0] > metrics[1]) { + width = (int)metrics[0]; + height = (int)metrics[1]; + } else { + width = (int)metrics[1]; + height = (int)metrics[0]; + } + // DPI-x (metrics[2]) on Android appears to refer to the narrow dimension of the screen. + return new DisplayMetrics { width = width, height = height, xdpi = metrics[3], ydpi = metrics[2] }; } } @@ -40,6 +63,18 @@ public override void SetSettingsButtonEnabled(bool enabled) { CallObjectMethod(activityListener, "setSettingsButtonEnabled", enabled); } + public override void SetAlignmentMarkerEnabled(bool enabled) { + CallObjectMethod(activityListener, "setAlignmentMarkerEnabled", enabled); + } + + public override void SetVRBackButtonEnabled(bool enabled) { + CallObjectMethod(activityListener, "setVRBackButtonEnabled", enabled); + } + + public override void SetShowVrBackButtonOnlyInVR(bool only) { + CallObjectMethod(activityListener, "setShowVrBackButtonOnlyInVR", only); + } + public override void SetTapIsTrigger(bool enabled) { CallObjectMethod(activityListener, "setTapIsTrigger", enabled); } @@ -48,12 +83,6 @@ public override void SetTouchCoordinates(int x, int y) { CallObjectMethod(activityListener, "setTouchCoordinates", x, y); } - public override bool SetDefaultDeviceProfile(System.Uri uri) { - bool result = false; - CallObjectMethod(ref result, activityListener, "setDefaultDeviceProfile", uri.ToString()); - return result; - } - public override void ShowSettingsDialog() { CallObjectMethod(activityListener, "launchConfigureActivity"); } @@ -64,11 +93,24 @@ protected override void ProcessEvents() { if (triggered) { CallObjectMethod(activityListener, "injectSingleTap"); } - if (tilted) { + if (backButtonPressed) { CallObjectMethod(activityListener, "injectKeyPress", 111); // Escape key. } } } + + public override void OnPause(bool pause) { + base.OnPause(pause); + CallObjectMethod(activityListener, "onPause", pause); + } + + private void SetApplicationState() { + if (activityListener == null) { + using (var listenerClass = GetClass(ActivityListenerClass)) { + CallStaticMethod(listenerClass, "setUnityApplicationState"); + } + } + } } #endif diff --git a/Cardboard/Scripts/VRDevices/CardboardiOSDevice.cs b/Cardboard/Scripts/VRDevices/CardboardiOSDevice.cs index ce5608b0..b75178c5 100644 --- a/Cardboard/Scripts/VRDevices/CardboardiOSDevice.cs +++ b/Cardboard/Scripts/VRDevices/CardboardiOSDevice.cs @@ -15,22 +15,23 @@ using System.Runtime.InteropServices; using System.Collections.Generic; +using UnityEngine; public class CardboardiOSDevice : BaseCardboardDevice { // Native code libraries use OpenGL, but Unity picks Metal for iOS by default. bool isOpenGL = false; - public override bool SupportsNativeDistortionCorrection(List diagnostics) { - bool support = base.SupportsNativeDistortionCorrection(diagnostics); - if (!isOpenGL) { - diagnostics.Add("Requires OpenGL"); - support = false; - } - return support; + // Returns landscape orientation display metrics. + public override DisplayMetrics GetDisplayMetrics() { + // Always return landscape orientation. + int width = Mathf.Max(Screen.width, Screen.height); + int height = Mathf.Min(Screen.width, Screen.height); + float dpi = getScreenDPI(); + return new DisplayMetrics { width = width, height = height, xdpi = dpi, ydpi = dpi }; } - public override bool SupportsNativeUILayer(List diagnostics) { - bool support = base.SupportsNativeUILayer(diagnostics); + public override bool SupportsNativeDistortionCorrection(List diagnostics) { + bool support = base.SupportsNativeDistortionCorrection(diagnostics); if (!isOpenGL) { diagnostics.Add("Requires OpenGL"); support = false; @@ -46,9 +47,16 @@ public override void SetSettingsButtonEnabled(bool enabled) { setSettingsButtonEnabled(enabled); } - public override void SetAutoDriftCorrectionEnabled(bool enabled){ - // For iOS don't use Drift Correction. - base.SetAutoDriftCorrectionEnabled(false); + public override void SetAlignmentMarkerEnabled(bool enabled) { + setAlignmentMarkerEnabled(enabled); + } + + public override void SetVRBackButtonEnabled(bool enabled) { + setVRBackButtonEnabled(enabled); + } + + public override void SetShowVrBackButtonOnlyInVR(bool only) { + setShowVrBackButtonOnlyInVR(only); } public override void SetTapIsTrigger(bool enabled) { @@ -56,8 +64,11 @@ public override void SetTapIsTrigger(bool enabled) { } public override bool SetDefaultDeviceProfile(System.Uri uri) { - byte[] profile = System.Text.Encoding.UTF8.GetBytes(uri.ToString()); - return setDefaultDeviceProfile(profile, profile.Length); + bool result = base.SetDefaultDeviceProfile(uri); + if (result) { + setOnboardingDone(); + } + return result; } public override void Init() { @@ -68,11 +79,7 @@ public override void Init() { SetAutoDriftCorrectionEnabled(false); } - public override void PostRender(bool vrMode) { - // Do not call GL.IssuePluginEvent() unless OpenGL is the graphics API. - base.PostRender(vrMode && isOpenGL); - } - + // Set this to true to force an onboarding process. private bool debugOnboarding = false; public override void OnFocus(bool focus) { @@ -82,12 +89,6 @@ public override void OnFocus(bool focus) { } } - public override void OnPause(bool pause) { - if (!pause) { - readProfile(); - } - } - public override void ShowSettingsDialog() { launchSettingsDialog(); } @@ -98,17 +99,23 @@ public override void ShowSettingsDialog() { [DllImport("__Internal")] private static extern void setVRModeEnabled(bool enabled); + [DllImport("__Internal")] + private static extern void setShowVrBackButtonOnlyInVR(bool only); + [DllImport("__Internal")] private static extern void setSettingsButtonEnabled(bool enabled); [DllImport("__Internal")] - private static extern void setSyncWithCardboardEnabled(bool enabled); + private static extern void setAlignmentMarkerEnabled(bool enabled); [DllImport("__Internal")] - private static extern void readProfile(); + private static extern void setVRBackButtonEnabled(bool enabled); [DllImport("__Internal")] - private static extern bool setDefaultDeviceProfile(byte[] profileData, int size); + private static extern void setSyncWithCardboardEnabled(bool enabled); + + [DllImport("__Internal")] + private static extern void setOnboardingDone(); [DllImport("__Internal")] private static extern bool isOnboardingDone(); @@ -118,6 +125,9 @@ public override void ShowSettingsDialog() { [DllImport("__Internal")] private static extern void launchOnboardingDialog(); + + [DllImport("__Internal")] + private static extern float getScreenDPI(); } #endif diff --git a/Cardboard/Scripts/VRDevices/UnityEditorDevice.cs b/Cardboard/Scripts/VRDevices/UnityEditorDevice.cs index 39d5d13c..f9941bd5 100644 --- a/Cardboard/Scripts/VRDevices/UnityEditorDevice.cs +++ b/Cardboard/Scripts/VRDevices/UnityEditorDevice.cs @@ -14,12 +14,13 @@ #if UNITY_EDITOR using UnityEngine; +using UnityEditor; using System.Collections.Generic; // Sends simulated values for use when testing within the Unity Editor. public class UnityEditorDevice : BaseVRDevice { - // Simulated neck model. - private static readonly Vector3 neckOffset = new Vector3(0, 0.075f, -0.08f); + // Simulated neck model. Vector from the neck pivot point to the point between the eyes. + private static readonly Vector3 neckOffset = new Vector3(0, 0.075f, 0.08f); // Use mouse to emulate head in the editor. private float mouseX = 0; @@ -38,18 +39,19 @@ public override bool SupportsNativeUILayer(List diagnostics) { return false; // No need for diagnostic message. } - public override RenderTexture CreateStereoScreen() { - return null; // No need for it in the editor. - } - - public override void SetDistortionCorrectionEnabled(bool enabled) {} + // Since we can check all these settings by asking Cardboard.SDK, no need + // to keep a separate copy here. public override void SetVRModeEnabled(bool enabled) {} - public override void SetAlignmentMarkerEnabled(bool enabled) {} + public override void SetDistortionCorrectionEnabled(bool enabled) {} + public override void SetStereoScreen(RenderTexture stereoScreen) {} public override void SetSettingsButtonEnabled(bool enabled) {} + public override void SetAlignmentMarkerEnabled(bool enabled) {} + public override void SetVRBackButtonEnabled(bool enabled) {} + public override void SetShowVrBackButtonOnlyInVR(bool only) {} public override void SetNeckModelScale(float scale) {} public override void SetAutoDriftCorrectionEnabled(bool enabled) {} + public override void SetElectronicDisplayStabilizationEnabled(bool enabled) {} public override void SetTapIsTrigger(bool enabled) {} - public override void SetStereoScreen(RenderTexture stereoScreen) {} private Quaternion initialRotation = Quaternion.identity; @@ -57,7 +59,7 @@ public override void SetStereoScreen(RenderTexture stereoScreen) {} private bool RemoteCommunicating { get { if (!remoteCommunicating) { -#if UNITY5 +#if UNITY_5 remoteCommunicating = EditorApplication.isRemoteConnected; #else remoteCommunicating = Vector3.Dot(Input.gyro.rotationRate, Input.gyro.rotationRate) > 0.05; @@ -98,17 +100,18 @@ public override void UpdateState() { var neck = (rot * neckOffset - neckOffset.y * Vector3.up) * Cardboard.SDK.NeckModelScale; headPose.Set(neck, rot); - triggered = Input.GetMouseButtonUp(0); + triggered = Input.GetMouseButtonDown(0); tilted = Input.GetKeyUp(KeyCode.Escape); } - public override void PostRender(bool vrMode) { + public override void PostRender() { // Do nothing. } public override void UpdateScreenData() { Profile = CardboardProfile.GetKnownProfile(Cardboard.SDK.ScreenSize, Cardboard.SDK.DeviceType); ComputeEyesFromProfile(); + profileChanged = true; } public override void Recenter() { diff --git a/CardboardDemoForUnity.unitypackage b/CardboardDemoForUnity.unitypackage index 4581266f..aa55bac6 100644 Binary files a/CardboardDemoForUnity.unitypackage and b/CardboardDemoForUnity.unitypackage differ diff --git a/CardboardSDKForUnity.unitypackage b/CardboardSDKForUnity.unitypackage index 79d939fe..60dfb5e7 100644 Binary files a/CardboardSDKForUnity.unitypackage and b/CardboardSDKForUnity.unitypackage differ diff --git a/LICENSE b/LICENSE index 99545567..b5aaedab 100644 --- a/LICENSE +++ b/LICENSE @@ -235,6 +235,1946 @@ THE SOFTWARE. +################################# +Eigen3 +################################# +Eigen is primarily MPL2 licensed. See COPYING.MPL2 and these links: + http://www.mozilla.org/MPL/2.0/ + http://www.mozilla.org/MPL/2.0/FAQ.html + +Some files contain third-party code under BSD or LGPL licenses, whence +the other COPYING.* files here. + +All the LGPL code is either LGPL 2.1-only, or LGPL 2.1-or-later. +For this reason, the COPYING.LGPL file contains the LGPL 2.1 text. + +If you want to guarantee that the Eigen code that you are #including +is licensed under the MPL2 and possibly more permissive licenses (like +BSD), #define this preprocessor symbol: EIGEN_MPL2_ONLY +For example, with most compilers, you could add this to your project + CXXFLAGS: -DEIGEN_MPL2_ONLY +This will cause a compilation error to be generated if you #include +any code that is LGPL licensed. + +---------------------------------------------------------------------- +Following applies to: +./test/mapstaticmethods.cpp +./test/schur_real.cpp +./test/prec_inverse_4x4.cpp +./test/smallvectors.cpp +./test/redux.cpp +./test/special_numbers.cpp +./test/adjoint.cpp +./test/resize.cpp +./test/mixingtypes.cpp +./test/product_trmv.cpp +./test/sparse_solvers.cpp +./test/cholesky.cpp +./test/geo_quaternion.cpp +./test/miscmatrices.cpp +./test/stddeque.cpp +./test/integer_types.cpp +./test/product_large.cpp +./test/eigensolver_generic.cpp +./test/householder.cpp +./test/geo_orthomethods.cpp +./test/array_for_matrix.cpp +./test/sparseLM.cpp +./test/upperbidiagonalization.cpp +./test/nomalloc.cpp +./test/packetmath.cpp +./test/jacobisvd.cpp +./test/geo_transformations.cpp +./test/swap.cpp +./test/eigensolver_selfadjoint.cpp +./test/inverse.cpp +./test/product_selfadjoint.cpp +./test/product_trsolve.cpp +./test/product_extra.cpp +./test/sparse_solver.h +./test/mapstride.cpp +./test/mapped_matrix.cpp +./test/geo_eulerangles.cpp +./test/eigen2support.cpp +./test/denseLM.cpp +./test/stdvector.cpp +./test/nesting_ops.cpp +./test/sparse_permutations.cpp +./test/zerosized.cpp +./test/exceptions.cpp +./test/vectorwiseop.cpp +./test/cwiseop.cpp +./test/basicstuff.cpp +./test/product_trmm.cpp +./test/linearstructure.cpp +./test/sparse_product.cpp +./test/stdvector_overload.cpp +./test/stable_norm.cpp +./test/umeyama.cpp +./test/unalignedcount.cpp +./test/triangular.cpp +./test/product_mmtr.cpp +./test/sparse_basic.cpp +./test/sparse_vector.cpp +./test/meta.cpp +./test/real_qz.cpp +./test/ref.cpp +./test/eigensolver_complex.cpp +./test/cholmod_support.cpp +./test/conjugate_gradient.cpp +./test/sparse.h +./test/simplicial_cholesky.cpp +./test/bicgstab.cpp +./test/dynalloc.cpp +./test/product_notemporary.cpp +./test/geo_hyperplane.cpp +./test/lu.cpp +./test/qr.cpp +./test/hessenberg.cpp +./test/sizeof.cpp +./test/main.h +./test/selfadjoint.cpp +./test/permutationmatrices.cpp +./test/superlu_support.cpp +./test/qtvector.cpp +./test/geo_homogeneous.cpp +./test/determinant.cpp +./test/array_reverse.cpp +./test/unalignedassert.cpp +./test/stdlist.cpp +./test/product_symm.cpp +./test/corners.cpp +./test/dontalign.cpp +./test/visitor.cpp +./test/geo_alignedbox.cpp +./test/diagonalmatrices.cpp +./test/product_small.cpp +./test/eigensolver_generalized_real.cpp +./test/umfpack_support.cpp +./test/first_aligned.cpp +./test/qr_fullpivoting.cpp +./test/array_replicate.cpp +./test/geo_parametrizedline.cpp +./test/eigen2/eigen2_unalignedassert.cpp +./test/eigen2/eigen2_prec_inverse_4x4.cpp +./test/eigen2/eigen2_alignedbox.cpp +./test/eigen2/eigen2_sparse_product.cpp +./test/eigen2/eigen2_meta.cpp +./test/eigen2/eigen2_nomalloc.cpp +./test/eigen2/eigen2_visitor.cpp +./test/eigen2/eigen2_packetmath.cpp +./test/eigen2/eigen2_svd.cpp +./test/eigen2/eigen2_mixingtypes.cpp +./test/eigen2/eigen2_qr.cpp +./test/eigen2/eigen2_cwiseop.cpp +./test/eigen2/eigen2_geometry_with_eigen2_prefix.cpp +./test/eigen2/eigen2_smallvectors.cpp +./test/eigen2/eigen2_commainitializer.cpp +./test/eigen2/eigen2_sparse_solvers.cpp +./test/eigen2/eigen2_hyperplane.cpp +./test/eigen2/eigen2_eigensolver.cpp +./test/eigen2/eigen2_linearstructure.cpp +./test/eigen2/eigen2_sizeof.cpp +./test/eigen2/eigen2_parametrizedline.cpp +./test/eigen2/eigen2_lu.cpp +./test/eigen2/eigen2_adjoint.cpp +./test/eigen2/eigen2_geometry.cpp +./test/eigen2/eigen2_stdvector.cpp +./test/eigen2/eigen2_newstdvector.cpp +./test/eigen2/eigen2_submatrices.cpp +./test/eigen2/sparse.h +./test/eigen2/eigen2_swap.cpp +./test/eigen2/eigen2_triangular.cpp +./test/eigen2/eigen2_basicstuff.cpp +./test/eigen2/gsl_helper.h +./test/eigen2/eigen2_dynalloc.cpp +./test/eigen2/eigen2_array.cpp +./test/eigen2/eigen2_map.cpp +./test/eigen2/main.h +./test/eigen2/eigen2_miscmatrices.cpp +./test/eigen2/eigen2_product_large.cpp +./test/eigen2/eigen2_first_aligned.cpp +./test/eigen2/eigen2_cholesky.cpp +./test/eigen2/eigen2_determinant.cpp +./test/eigen2/eigen2_sum.cpp +./test/eigen2/eigen2_inverse.cpp +./test/eigen2/eigen2_regression.cpp +./test/eigen2/eigen2_product_small.cpp +./test/eigen2/eigen2_qtvector.cpp +./test/eigen2/eigen2_sparse_vector.cpp +./test/eigen2/product.h +./test/eigen2/eigen2_sparse_basic.cpp +./test/eigen2/eigen2_bug_132.cpp +./test/array.cpp +./test/product_syrk.cpp +./test/commainitializer.cpp +./test/conservative_resize.cpp +./test/qr_colpivoting.cpp +./test/nullary.cpp +./test/bandmatrix.cpp +./test/pastix_support.cpp +./test/product.h +./test/block.cpp +./test/vectorization_logic.cpp +./test/jacobi.cpp +./test/diagonal.cpp +./test/schur_complex.cpp +./test/sizeoverflow.cpp +./bench/BenchTimer.h +./bench/benchFFT.cpp +./bench/eig33.cpp +./bench/spbench/spbenchsolver.h +./bench/spbench/spbenchstyle.h +./lapack/complex_double.cpp +./lapack/cholesky.cpp +./lapack/lapack_common.h +./lapack/eigenvalues.cpp +./lapack/single.cpp +./lapack/lu.cpp +./lapack/complex_single.cpp +./lapack/double.cpp +./demos/mix_eigen_and_c/binary_library.cpp +./demos/mix_eigen_and_c/binary_library.h +./demos/mix_eigen_and_c/example.c +./demos/mandelbrot/mandelbrot.cpp +./demos/mandelbrot/mandelbrot.h +./demos/opengl/icosphere.cpp +./demos/opengl/icosphere.h +./demos/opengl/camera.cpp +./demos/opengl/quaternion_demo.h +./demos/opengl/camera.h +./demos/opengl/trackball.h +./demos/opengl/gpuhelper.h +./demos/opengl/trackball.cpp +./demos/opengl/gpuhelper.cpp +./demos/opengl/quaternion_demo.cpp +./debug/gdb/printers.py +./unsupported/test/minres.cpp +./unsupported/test/openglsupport.cpp +./unsupported/test/jacobisvd.cpp +./unsupported/test/dgmres.cpp +./unsupported/test/matrix_square_root.cpp +./unsupported/test/bdcsvd.cpp +./unsupported/test/matrix_exponential.cpp +./unsupported/test/forward_adolc.cpp +./unsupported/test/polynomialsolver.cpp +./unsupported/test/matrix_function.cpp +./unsupported/test/sparse_extra.cpp +./unsupported/test/matrix_functions.h +./unsupported/test/svd_common.h +./unsupported/test/FFTW.cpp +./unsupported/test/alignedvector3.cpp +./unsupported/test/autodiff.cpp +./unsupported/test/gmres.cpp +./unsupported/test/BVH.cpp +./unsupported/test/levenberg_marquardt.cpp +./unsupported/test/matrix_power.cpp +./unsupported/test/kronecker_product.cpp +./unsupported/test/splines.cpp +./unsupported/test/polynomialutils.cpp +./unsupported/bench/bench_svd.cpp +./unsupported/Eigen/IterativeSolvers +./unsupported/Eigen/src/IterativeSolvers/DGMRES.h +./unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h +./unsupported/Eigen/src/IterativeSolvers/GMRES.h +./unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h +./unsupported/Eigen/src/IterativeSolvers/Scaling.h +./unsupported/Eigen/src/IterativeSolvers/MINRES.h +./unsupported/Eigen/src/SparseExtra/RandomSetter.h +./unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h +./unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h +./unsupported/Eigen/src/SparseExtra/MarketIO.h +./unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h +./unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h +./unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h +./unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +./unsupported/Eigen/src/BVH/BVAlgorithms.h +./unsupported/Eigen/src/BVH/KdBVH.h +./unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +./unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h +./unsupported/Eigen/src/AutoDiff/AutoDiffVector.h +./unsupported/Eigen/src/Splines/Spline.h +./unsupported/Eigen/src/Splines/SplineFitting.h +./unsupported/Eigen/src/Splines/SplineFwd.h +./unsupported/Eigen/src/SVD/JacobiSVD.h +./unsupported/Eigen/src/SVD/BDCSVD.h +./unsupported/Eigen/src/SVD/SVDBase.h +./unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h +./unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h +./unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h +./unsupported/Eigen/src/MatrixFunctions/StemFunction.h +./unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +./unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +./unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h +./unsupported/Eigen/src/MoreVectorization/MathFunctions.h +./unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h +./unsupported/Eigen/src/FFT/ei_fftw_impl.h +./unsupported/Eigen/src/FFT/ei_kissfft_impl.h +./unsupported/Eigen/src/Polynomials/PolynomialSolver.h +./unsupported/Eigen/src/Polynomials/Companion.h +./unsupported/Eigen/src/Polynomials/PolynomialUtils.h +./unsupported/Eigen/src/NumericalDiff/NumericalDiff.h +./unsupported/Eigen/src/Skyline/SkylineProduct.h +./unsupported/Eigen/src/Skyline/SkylineMatrixBase.h +./unsupported/Eigen/src/Skyline/SkylineStorage.h +./unsupported/Eigen/src/Skyline/SkylineUtil.h +./unsupported/Eigen/src/Skyline/SkylineInplaceLU.h +./unsupported/Eigen/src/Skyline/SkylineMatrix.h +./unsupported/Eigen/SparseExtra +./unsupported/Eigen/AdolcForward +./unsupported/Eigen/KroneckerProduct +./unsupported/Eigen/NonLinearOptimization +./unsupported/Eigen/BVH +./unsupported/Eigen/OpenGLSupport +./unsupported/Eigen/ArpackSupport +./unsupported/Eigen/AutoDiff +./unsupported/Eigen/Splines +./unsupported/Eigen/MPRealSupport +./unsupported/Eigen/MatrixFunctions +./unsupported/Eigen/MoreVectorization +./unsupported/Eigen/LevenbergMarquardt +./unsupported/Eigen/AlignedVector3 +./unsupported/Eigen/FFT +./unsupported/Eigen/Polynomials +./unsupported/Eigen/NumericalDiff +./unsupported/Eigen/Skyline +./COPYING.README +./COPYING.README +./LICENSE +./LICENSE +./LICENSE +./Eigen/Eigen2Support +./Eigen/src/Eigen2Support/VectorBlock.h +./Eigen/src/Eigen2Support/Cwise.h +./Eigen/src/Eigen2Support/Minor.h +./Eigen/src/Eigen2Support/Lazy.h +./Eigen/src/Eigen2Support/Memory.h +./Eigen/src/Eigen2Support/MathFunctions.h +./Eigen/src/Eigen2Support/Geometry/AlignedBox.h +./Eigen/src/Eigen2Support/Geometry/Hyperplane.h +./Eigen/src/Eigen2Support/Geometry/Quaternion.h +./Eigen/src/Eigen2Support/Geometry/Rotation2D.h +./Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +./Eigen/src/Eigen2Support/Geometry/RotationBase.h +./Eigen/src/Eigen2Support/Geometry/Translation.h +./Eigen/src/Eigen2Support/Geometry/Scaling.h +./Eigen/src/Eigen2Support/Geometry/AngleAxis.h +./Eigen/src/Eigen2Support/Geometry/Transform.h +./Eigen/src/Eigen2Support/TriangularSolver.h +./Eigen/src/Eigen2Support/LU.h +./Eigen/src/Eigen2Support/QR.h +./Eigen/src/Eigen2Support/SVD.h +./Eigen/src/Eigen2Support/Meta.h +./Eigen/src/Eigen2Support/Block.h +./Eigen/src/Eigen2Support/Macros.h +./Eigen/src/Eigen2Support/LeastSquares.h +./Eigen/src/Eigen2Support/CwiseOperators.h +./Eigen/src/Jacobi/Jacobi.h +./Eigen/src/misc/Kernel.h +./Eigen/src/misc/SparseSolve.h +./Eigen/src/misc/Solve.h +./Eigen/src/misc/Image.h +./Eigen/src/SparseCore/SparseColEtree.h +./Eigen/src/SparseCore/SparseTranspose.h +./Eigen/src/SparseCore/SparseUtil.h +./Eigen/src/SparseCore/SparseCwiseBinaryOp.h +./Eigen/src/SparseCore/SparseDiagonalProduct.h +./Eigen/src/SparseCore/SparseProduct.h +./Eigen/src/SparseCore/SparseDot.h +./Eigen/src/SparseCore/SparseCwiseUnaryOp.h +./Eigen/src/SparseCore/SparseSparseProductWithPruning.h +./Eigen/src/SparseCore/SparseBlock.h +./Eigen/src/SparseCore/SparseDenseProduct.h +./Eigen/src/SparseCore/CompressedStorage.h +./Eigen/src/SparseCore/SparseMatrixBase.h +./Eigen/src/SparseCore/MappedSparseMatrix.h +./Eigen/src/SparseCore/SparseTriangularView.h +./Eigen/src/SparseCore/SparseView.h +./Eigen/src/SparseCore/SparseFuzzy.h +./Eigen/src/SparseCore/TriangularSolver.h +./Eigen/src/SparseCore/SparseSelfAdjointView.h +./Eigen/src/SparseCore/SparseMatrix.h +./Eigen/src/SparseCore/SparseVector.h +./Eigen/src/SparseCore/AmbiVector.h +./Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +./Eigen/src/SparseCore/SparseRedux.h +./Eigen/src/SparseCore/SparsePermutation.h +./Eigen/src/Eigenvalues/RealSchur.h +./Eigen/src/Eigenvalues/ComplexEigenSolver.h +./Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +./Eigen/src/Eigenvalues/ComplexSchur.h +./Eigen/src/Eigenvalues/RealQZ.h +./Eigen/src/Eigenvalues/EigenSolver.h +./Eigen/src/Eigenvalues/HessenbergDecomposition.h +./Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +./Eigen/src/Eigenvalues/Tridiagonalization.h +./Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +./Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +./Eigen/src/SuperLUSupport/SuperLUSupport.h +./Eigen/src/StlSupport/StdDeque.h +./Eigen/src/StlSupport/StdVector.h +./Eigen/src/StlSupport/StdList.h +./Eigen/src/StlSupport/details.h +./Eigen/src/SparseQR/SparseQR.h +./Eigen/src/LU/Inverse.h +./Eigen/src/LU/arch/Inverse_SSE.h +./Eigen/src/LU/Determinant.h +./Eigen/src/LU/PartialPivLU.h +./Eigen/src/LU/FullPivLU.h +./Eigen/src/UmfPackSupport/UmfPackSupport.h +./Eigen/src/OrderingMethods/Ordering.h +./Eigen/src/OrderingMethods/Eigen_Colamd.h +./Eigen/src/QR/HouseholderQR.h +./Eigen/src/QR/ColPivHouseholderQR.h +./Eigen/src/QR/FullPivHouseholderQR.h +./Eigen/src/SVD/JacobiSVD.h +./Eigen/src/SVD/UpperBidiagonalization.h +./Eigen/src/Geometry/OrthoMethods.h +./Eigen/src/Geometry/AlignedBox.h +./Eigen/src/Geometry/Hyperplane.h +./Eigen/src/Geometry/Quaternion.h +./Eigen/src/Geometry/EulerAngles.h +./Eigen/src/Geometry/Rotation2D.h +./Eigen/src/Geometry/ParametrizedLine.h +./Eigen/src/Geometry/RotationBase.h +./Eigen/src/Geometry/arch/Geometry_SSE.h +./Eigen/src/Geometry/Umeyama.h +./Eigen/src/Geometry/Homogeneous.h +./Eigen/src/Geometry/Translation.h +./Eigen/src/Geometry/Scaling.h +./Eigen/src/Geometry/AngleAxis.h +./Eigen/src/Geometry/Transform.h +./Eigen/src/plugins/BlockMethods.h +./Eigen/src/plugins/CommonCwiseUnaryOps.h +./Eigen/src/plugins/CommonCwiseBinaryOps.h +./Eigen/src/plugins/MatrixCwiseUnaryOps.h +./Eigen/src/plugins/MatrixCwiseBinaryOps.h +./Eigen/src/Householder/Householder.h +./Eigen/src/Householder/HouseholderSequence.h +./Eigen/src/Householder/BlockHouseholder.h +./Eigen/src/Core/VectorBlock.h +./Eigen/src/Core/Matrix.h +./Eigen/src/Core/Ref.h +./Eigen/src/Core/SelfAdjointView.h +./Eigen/src/Core/MathFunctions.h +./Eigen/src/Core/GlobalFunctions.h +./Eigen/src/Core/MapBase.h +./Eigen/src/Core/EigenBase.h +./Eigen/src/Core/GenericPacketMath.h +./Eigen/src/Core/NestByValue.h +./Eigen/src/Core/CwiseUnaryOp.h +./Eigen/src/Core/SolveTriangular.h +./Eigen/src/Core/Fuzzy.h +./Eigen/src/Core/Visitor.h +./Eigen/src/Core/Map.h +./Eigen/src/Core/NoAlias.h +./Eigen/src/Core/Diagonal.h +./Eigen/src/Core/StableNorm.h +./Eigen/src/Core/CoreIterators.h +./Eigen/src/Core/products/Parallelizer.h +./Eigen/src/Core/products/SelfadjointMatrixVector.h +./Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +./Eigen/src/Core/products/TriangularSolverMatrix.h +./Eigen/src/Core/products/GeneralMatrixMatrix.h +./Eigen/src/Core/products/SelfadjointProduct.h +./Eigen/src/Core/products/CoeffBasedProduct.h +./Eigen/src/Core/products/TriangularMatrixVector.h +./Eigen/src/Core/products/SelfadjointMatrixMatrix.h +./Eigen/src/Core/products/TriangularSolverVector.h +./Eigen/src/Core/products/SelfadjointRank2Update.h +./Eigen/src/Core/products/GeneralBlockPanelKernel.h +./Eigen/src/Core/products/GeneralMatrixVector.h +./Eigen/src/Core/products/TriangularMatrixMatrix.h +./Eigen/src/Core/Reverse.h +./Eigen/src/Core/BooleanRedux.h +./Eigen/src/Core/Replicate.h +./Eigen/src/Core/arch/AltiVec/PacketMath.h +./Eigen/src/Core/arch/AltiVec/Complex.h +./Eigen/src/Core/arch/SSE/PacketMath.h +./Eigen/src/Core/arch/SSE/Complex.h +./Eigen/src/Core/arch/SSE/MathFunctions.h +./Eigen/src/Core/arch/NEON/PacketMath.h +./Eigen/src/Core/arch/NEON/Complex.h +./Eigen/src/Core/arch/Default/Settings.h +./Eigen/src/Core/CwiseUnaryView.h +./Eigen/src/Core/Array.h +./Eigen/src/Core/ArrayWrapper.h +./Eigen/src/Core/Swap.h +./Eigen/src/Core/Transpositions.h +./Eigen/src/Core/Random.h +./Eigen/src/Core/IO.h +./Eigen/src/Core/SelfCwiseBinaryOp.h +./Eigen/src/Core/VectorwiseOp.h +./Eigen/src/Core/Select.h +./Eigen/src/Core/ArrayBase.h +./Eigen/src/Core/DenseCoeffsBase.h +./Eigen/src/Core/DiagonalProduct.h +./Eigen/src/Core/Assign.h +./Eigen/src/Core/Redux.h +./Eigen/src/Core/ForceAlignedAccess.h +./Eigen/src/Core/BandMatrix.h +./Eigen/src/Core/PlainObjectBase.h +./Eigen/src/Core/DenseBase.h +./Eigen/src/Core/Flagged.h +./Eigen/src/Core/CwiseBinaryOp.h +./Eigen/src/Core/ProductBase.h +./Eigen/src/Core/TriangularMatrix.h +./Eigen/src/Core/Transpose.h +./Eigen/src/Core/DiagonalMatrix.h +./Eigen/src/Core/Dot.h +./Eigen/src/Core/Functors.h +./Eigen/src/Core/PermutationMatrix.h +./Eigen/src/Core/NumTraits.h +./Eigen/src/Core/MatrixBase.h +./Eigen/src/Core/DenseStorage.h +./Eigen/src/Core/util/Memory.h +./Eigen/src/Core/util/StaticAssert.h +./Eigen/src/Core/util/BlasUtil.h +./Eigen/src/Core/util/MatrixMapper.h +./Eigen/src/Core/util/XprHelper.h +./Eigen/src/Core/util/ForwardDeclarations.h +./Eigen/src/Core/util/Meta.h +./Eigen/src/Core/util/Macros.h +./Eigen/src/Core/util/Constants.h +./Eigen/src/Core/CwiseNullaryOp.h +./Eigen/src/Core/Block.h +./Eigen/src/Core/GeneralProduct.h +./Eigen/src/Core/CommaInitializer.h +./Eigen/src/Core/ReturnByValue.h +./Eigen/src/Core/Stride.h +./Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +./Eigen/src/SparseLU/SparseLU_column_dfs.h +./Eigen/src/SparseLU/SparseLU_panel_dfs.h +./Eigen/src/SparseLU/SparseLU_relax_snode.h +./Eigen/src/SparseLU/SparseLU_panel_bmod.h +./Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +./Eigen/src/SparseLU/SparseLU_Utils.h +./Eigen/src/SparseLU/SparseLU_gemm_kernel.h +./Eigen/src/SparseLU/SparseLU_kernel_bmod.h +./Eigen/src/SparseLU/SparseLU_pivotL.h +./Eigen/src/SparseLU/SparseLU_Memory.h +./Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +./Eigen/src/SparseLU/SparseLUImpl.h +./Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +./Eigen/src/SparseLU/SparseLU_Structs.h +./Eigen/src/SparseLU/SparseLU.h +./Eigen/src/SparseLU/SparseLU_column_bmod.h +./Eigen/src/SparseLU/SparseLU_pruneL.h +./Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +./Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +./Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +./Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +./Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +./Eigen/src/SparseCholesky/SimplicialCholesky.h +./Eigen/src/Cholesky/LDLT.h +./Eigen/src/Cholesky/LLT.h +./Eigen/src/CholmodSupport/CholmodSupport.h +./Eigen/src/PaStiXSupport/PaStiXSupport.h +./Eigen/src/MetisSupport/MetisSupport.h +./Eigen/StdVector +./Eigen/Core +./Eigen/SparseLU +./Eigen/StdList +./Eigen/StdDeque +./Eigen/SparseCholesky +./scripts/relicense.py +./scripts/relicense.py +./blas/BandTriangularSolver.h +./blas/PackedTriangularMatrixVector.h +./blas/complex_double.cpp +./blas/level2_real_impl.h +./blas/level1_cplx_impl.h +./blas/level1_impl.h +./blas/level1_real_impl.h +./blas/level3_impl.h +./blas/single.cpp +./blas/level2_cplx_impl.h +./blas/PackedSelfadjointProduct.h +./blas/Rank2Update.h +./blas/complex_single.cpp +./blas/PackedTriangularSolverVector.h +./blas/double.cpp +./blas/common.h +./blas/level2_impl.h +./blas/GeneralRank1Update.h + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + +---------------------------------------------------------------------- +Following applies to: +./doc/UsingIntelMKL.dox +./doc/UsingIntelMKL.dox +./Eigen/src/Eigenvalues/ComplexSchur_MKL.h +./Eigen/src/Eigenvalues/ComplexSchur_MKL.h +./Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +./Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +./Eigen/src/Eigenvalues/RealSchur_MKL.h +./Eigen/src/Eigenvalues/RealSchur_MKL.h +./Eigen/src/LU/arch/Inverse_SSE.h +./Eigen/src/LU/arch/Inverse_SSE.h +./Eigen/src/LU/PartialPivLU_MKL.h +./Eigen/src/LU/PartialPivLU_MKL.h +./Eigen/src/QR/HouseholderQR_MKL.h +./Eigen/src/QR/HouseholderQR_MKL.h +./Eigen/src/QR/ColPivHouseholderQR_MKL.h +./Eigen/src/QR/ColPivHouseholderQR_MKL.h +./Eigen/src/SVD/JacobiSVD_MKL.h +./Eigen/src/SVD/JacobiSVD_MKL.h +./Eigen/src/PardisoSupport/PardisoSupport.h +./Eigen/src/PardisoSupport/PardisoSupport.h +./Eigen/src/Core/Assign_MKL.h +./Eigen/src/Core/Assign_MKL.h +./Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +./Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +./Eigen/src/Core/products/GeneralMatrixVector_MKL.h +./Eigen/src/Core/products/GeneralMatrixVector_MKL.h +./Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +./Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +./Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +./Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +./Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +./Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +./Eigen/src/Core/products/TriangularMatrixVector_MKL.h +./Eigen/src/Core/products/TriangularMatrixVector_MKL.h +./Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +./Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +./Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +./Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +./Eigen/src/Core/util/MKL_support.h +./Eigen/src/Core/util/MKL_support.h +./Eigen/src/Cholesky/LLT_MKL.h +./Eigen/src/Cholesky/LLT_MKL.h + +/* + Copyright (c) 2011, Intel Corporation. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. * + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. * Neither the name of Intel Corporation nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +---------------------------------------------------------------------- +Following applies to: + everything under ./bench/btl + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +"normally used" refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include +a requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material +you add to a covered work, you may (if authorized by the copyright +holders of that material) supplement the terms of this License with +terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement +or otherwise) that contradict the conditions of this License, they do +not excuse you from the conditions of this License. If you cannot +convey a covered work so as to satisfy simultaneously your obligations +under this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree +to terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES +AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR +DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF +THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) This program comes + with ABSOLUTELY NO WARRANTY; for details type `show w'. This is + free software, and you are welcome to redistribute it under + certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + + You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see . + + The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use +the GNU Lesser General Public License instead of this License. But +first, please read . + + +---------------------------------------------------------------------- +Following applies to: +./test/metis_support.cpp +./test/sparselu.cpp +./unsupported/test/mpreal/mpreal.h +./unsupported/Eigen/src/IterativeSolvers/IterationController.h +./unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h +./unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h +./Eigen/src/OrderingMethods/Amd.h +./Eigen/src/SparseCholesky/SimplicialCholesky_impl.h + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the +GNU General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this + license document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this + license document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of + this License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + +---------------------------------------------------------------------- +Following applies to: +./unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h +./unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h +./unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h +./unsupported/Eigen/src/LevenbergMarquardt/LMpar.h +./unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h + +Minpack Copyright Notice (1999) University of Chicago. All rights +reserved + +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the +following conditions are met: + +1. Redistributions of source code must retain the above +copyright notice, this list of conditions and the following +disclaimer. + +2. Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials +provided with the distribution. + +3. The end-user documentation included with the +redistribution, if any, must include the following +acknowledgment: + + "This product includes software developed by the + University of Chicago, as Operator of Argonne National + Laboratory. + +Alternately, this acknowledgment may appear in the software +itself, if and wherever such third-party acknowledgments +normally appear. + +4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" +WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE +UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND +THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE +OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY +OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR +USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF +THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) +DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION +UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL +BE CORRECTED. + +5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT +HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF +ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, +INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF +ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF +PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER +SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT +(INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, +EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE +POSSIBILITY OF SUCH LOSS OR DAMAGES. + ################################# FreeType #################################