├── .gitignore ├── LICENSE ├── Libs ├── LeapCSharp.NET3.5.dll ├── Unity 4.6 │ ├── UnityEngine.UI.dll │ └── UnityEngine.dll ├── Unity 5.3.4 │ ├── UnityEngine.UI.dll │ └── UnityEngine.dll └── WindowsInput.dll ├── README.md ├── VRGIN.sln └── VRGIN ├── Controls ├── Controller.cs ├── Handlers │ ├── BodyRumbleHandler.cs │ └── MenuHandler.cs ├── HelpText.cs ├── IShortcut.cs ├── KeyboardShortcut.cs ├── LeapMotion │ ├── LeapMenuHandler.cs │ ├── PinchController.cs │ └── WarpHandler.cs ├── LeftController.cs ├── RightController.cs ├── RumbleManager.cs ├── Speech │ ├── DictionaryReader.cs │ ├── SpeechManager.cs │ ├── VoiceCommand.cs │ └── VoiceShortcut.cs └── Tools │ ├── MenuTool.cs │ ├── Tool.cs │ └── WarpTool.cs ├── Core ├── DefaultActor.cs ├── DefaultActorBehaviour.cs ├── GameInterpreter.cs ├── IActor.cs ├── IVRManagerContext.cs ├── Logger.cs ├── PlayArea.cs ├── ProtectedBehaviour.cs ├── ScreenGrabber.cs ├── Throttler.cs ├── VRCamera.cs ├── VRGUI.cs ├── VRManager.cs └── VRSettings.cs ├── Helpers ├── Calculator.cs ├── CameraConsumer.cs ├── CameraMonitor.cs ├── Capture │ ├── CapturePanorama.cs │ └── Internals │ │ ├── Icosphere.cs │ │ ├── ImageEffectCopyCamera.cs │ │ ├── ReadPanoConfig.cs │ │ └── ScreenFadeControl.cs ├── DefaultContext.cs ├── GameObjectExtensions.cs ├── GuiScaler.cs ├── KeyStroke.cs ├── LookTargetController.cs ├── MeshExtension.cs ├── MessengerExtensions.cs ├── Profiler.cs ├── QuaternionExtensions.cs ├── RenderTextureExtensions.cs ├── ResourceManager.cs ├── RumbleSession.cs ├── SimpleJSON.cs ├── SteamVRDetector.cs ├── UnityHelper.cs └── VRCapturePanorama.cs ├── LeapMotion ├── Attachments │ ├── AttachmentController.cs │ ├── CameraFollower.cs │ ├── HandAttachments.cs │ └── Transition.cs ├── DetectionUtilities │ ├── Detector.cs │ ├── DetectorLogicGate.cs │ ├── ExtendedFingerDetector.cs │ ├── FingerDirectionDetector.cs │ ├── PalmDirectionDetector.cs │ ├── PinchDetector.cs │ └── ProximityDetector.cs ├── HandFactory.cs ├── HandPool.cs ├── HandProxy.cs ├── HandRepresentation.cs ├── Hands │ ├── CapsuleHand.cs │ ├── DebugHand.cs │ ├── FingerModel.cs │ ├── HandDrop.cs │ ├── HandEnableDisable.cs │ ├── HandFader.cs │ ├── HandModel.cs │ ├── HandTransitionBehavior.cs │ ├── IHandModel.cs │ ├── MinimalHand.cs │ ├── PolyFinger.cs │ ├── PolyHand.cs │ ├── RiggedFinger.cs │ ├── RiggedHand.cs │ ├── RigidFinger.cs │ ├── RigidHand.cs │ ├── SkeletalFinger.cs │ ├── SkeletalHand.cs │ └── TestHandFactory.cs ├── LeapDeviceInfo.cs ├── LeapHandController.cs ├── LeapImageRetriever.cs ├── LeapProvider.cs ├── LeapServiceProvider.cs ├── Utils │ ├── DisconnectionNotice.cs │ ├── EnableDepthBuffer.cs │ ├── ExecutionOrder.cs │ ├── FitHeightToScreen.cs │ ├── FrameRateControls.cs │ ├── KeyEnableBehaviors.cs │ ├── KeyEnableGameObjects.cs │ ├── LeapUnityExtensions.cs │ ├── SceneSettings.cs │ ├── SmoothedFloat.cs │ ├── SmoothedQuaternion.cs │ ├── SmoothedVector3.cs │ ├── StretchToScreen.cs │ └── Utils.cs └── VR │ ├── EyeType.cs │ ├── LeapVRCameraControl.cs │ ├── LeapVRTemporalWarping.cs │ ├── TemporalWarpingStatus.cs │ └── VRHeightOffset.cs ├── Libs ├── Data │ ├── Managed │ │ ├── System.Configuration.dll │ │ ├── System.Drawing.dll │ │ ├── System.Xml.Linq.dll │ │ ├── System.Xml.dll │ │ └── System.dll │ └── Plugins │ │ ├── x86 │ │ ├── LeapC.dll │ │ ├── OculusSpatializerPlugin.dll │ │ └── openvr_api.dll │ │ └── x86_64 │ │ ├── LeapC.dll │ │ ├── OculusSpatializerPlugin.dll │ │ └── openvr_api.dll ├── Plugins │ ├── Images │ │ ├── cursor.png │ │ ├── icon_play.png │ │ ├── icon_settings.png │ │ └── icon_warp.png │ └── VR │ │ ├── SpeechServer.exe │ │ └── SpeechTransport.dll └── dxgi.dll ├── Modes ├── ControlMode.cs ├── SeatedMode.cs └── StandingMode.cs ├── Native ├── MouseOperations.cs ├── WindowManager.cs └── WindowsInterop.cs ├── Properties └── AssemblyInfo.cs ├── Resource.Designer.cs ├── Resource.resx ├── Resources ├── hands_5_3 ├── vrgin_5_0 ├── vrgin_5_2 ├── vrgin_5_3 ├── vrgin_5_4 ├── vrgin_5_5 └── vrgin_5_6 ├── SteamVR ├── Prefabs │ ├── [CameraRig].prefab │ ├── [Status].prefab │ └── [SteamVR].prefab ├── Resources │ ├── SteamVR_AlphaOut.shader │ ├── SteamVR_Blit.shader │ ├── SteamVR_BlitFlip.shader │ ├── SteamVR_ClearAll.shader │ ├── SteamVR_ColorOut.shader │ ├── SteamVR_ExternalCamera.prefab │ ├── SteamVR_Fade.shader │ ├── SteamVR_HiddenArea.shader │ ├── SteamVR_Overlay.shader │ └── SteamVR_SphericalProjection.shader ├── Scripts │ ├── SteamVR.cs │ ├── SteamVR_Camera.cs │ ├── SteamVR_CameraFlip.cs │ ├── SteamVR_CameraMask.cs │ ├── SteamVR_Controller.cs │ ├── SteamVR_ControllerManager.cs │ ├── SteamVR_Ears.cs │ ├── SteamVR_ExternalCamera.cs │ ├── SteamVR_Fade.cs │ ├── SteamVR_Frustum.cs │ ├── SteamVR_GameView.cs │ ├── SteamVR_IK.cs │ ├── SteamVR_LoadLevel.cs │ ├── SteamVR_Menu.cs │ ├── SteamVR_Overlay.cs │ ├── SteamVR_PlayArea.cs │ ├── SteamVR_Render.cs │ ├── SteamVR_RenderModel.cs │ ├── SteamVR_Skybox.cs │ ├── SteamVR_SphericalProjection.cs │ ├── SteamVR_Stats.cs │ ├── SteamVR_Status.cs │ ├── SteamVR_StatusText.cs │ ├── SteamVR_TestController.cs │ ├── SteamVR_TrackedObject.cs │ ├── SteamVR_UpdatePoses.cs │ └── SteamVR_Utils.cs ├── Textures │ ├── arrow.png │ ├── background.png │ ├── logo.png │ ├── overlay.renderTexture │ └── workshop.png ├── openvr_api.cs └── upgrading.md ├── U46 ├── OSP │ ├── OSPAudioSource.cs │ ├── OSPManager.cs │ └── OSPReflectionZone.cs ├── Properties │ └── AssemblyInfo.cs ├── Resource.Designer.cs ├── Resource.resx ├── Resources │ ├── hands.unity3d │ └── steamvr.unity3d └── SteamVR │ ├── Materials │ └── portalworkshop.mat │ ├── Prefabs │ ├── [CameraRig].prefab │ ├── [Status].prefab │ └── [SteamVR].prefab │ ├── Resources │ ├── SteamVR_AlphaOut.shader │ ├── SteamVR_Blit.shader │ ├── SteamVR_BlitFlip.shader │ ├── SteamVR_ClearAll.shader │ ├── SteamVR_ColorOut.shader │ ├── SteamVR_ExternalCamera.prefab │ ├── SteamVR_Fade.shader │ ├── SteamVR_HiddenArea.shader │ └── SteamVR_Overlay.shader │ ├── Scripts │ ├── SteamVR.cs │ ├── SteamVR_Camera.cs │ ├── SteamVR_CameraFlip.cs │ ├── SteamVR_CameraMask.cs │ ├── SteamVR_Controller.cs │ ├── SteamVR_ControllerManager.cs │ ├── SteamVR_Ears.cs │ ├── SteamVR_ExternalCamera.cs │ ├── SteamVR_Fade.cs │ ├── SteamVR_Frustum.cs │ ├── SteamVR_GameView.cs │ ├── SteamVR_IK.cs │ ├── SteamVR_LoadLevel.cs │ ├── SteamVR_Menu.cs │ ├── SteamVR_Overlay.cs │ ├── SteamVR_PlayArea.cs │ ├── SteamVR_Render.cs │ ├── SteamVR_RenderModel.cs │ ├── SteamVR_Skybox.cs │ ├── SteamVR_Stats.cs │ ├── SteamVR_Status.cs │ ├── SteamVR_StatusText.cs │ ├── SteamVR_TestController.cs │ ├── SteamVR_TrackedObject.cs │ ├── SteamVR_UpdatePoses.cs │ └── SteamVR_Utils.cs │ ├── Textures │ ├── arrow.png │ ├── background.png │ ├── logo.png │ ├── overlay.renderTexture │ └── portalworkshop.png │ └── openvr_api.cs ├── VRGIN.U46.csproj ├── VRGIN.csproj └── Visuals ├── ArcRenderer.cs ├── DefaultMaterialPalette.cs ├── GUIMonitor.cs ├── GUIQuad.cs ├── IMaterialPalette.cs ├── PlayAreaVisualization.cs ├── PlayerCamera.cs ├── ProceduralPlane.cs └── SimulatedCursor.cs /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Eusth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Libs/LeapCSharp.NET3.5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/LeapCSharp.NET3.5.dll -------------------------------------------------------------------------------- /Libs/Unity 4.6/UnityEngine.UI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/Unity 4.6/UnityEngine.UI.dll -------------------------------------------------------------------------------- /Libs/Unity 4.6/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/Unity 4.6/UnityEngine.dll -------------------------------------------------------------------------------- /Libs/Unity 5.3.4/UnityEngine.UI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/Unity 5.3.4/UnityEngine.UI.dll -------------------------------------------------------------------------------- /Libs/Unity 5.3.4/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/Unity 5.3.4/UnityEngine.dll -------------------------------------------------------------------------------- /Libs/WindowsInput.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/Libs/WindowsInput.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VRGIN 2 | VR injection framework for Unity -- helps you integrate VR into games that don't natively support it. 3 | 4 | ## What it does 5 | - It takes care of the cameras and the GUI 6 | - It gives you a frame to work with (Controllers, Modes, etc.) 7 | - It comes with presets for standing and seated mode, plus a set of tools for your controllers 8 | - There is a bunch of helper classes, e.g. for shortcuts and for rumble 9 | 10 | ## What it doesn't do 11 | - It does not take care of the injection into the DLL itself -- use a DLL injection library for this, e.g. the [Illusion Plugin Architecture](https://github.com/Eusth/IPA) or Rei Patcher. Refer to [the template](https://github.com/Eusth/VRGIN.Template) for a project that's ready to build and use. 12 | 13 | ## Current state 14 | 15 | | Unity Version | Compatibility | 16 | | --------------|---------------| 17 | | < 4.6 | Unsupported (VRGIN makes use of `UnityEngine.UI.dll`. | 18 | | 4.6, 4.7 | Somewhat supported, but does not work out of the box with the current master branch. See [PlayClubVR](https://github.com/Eusth/PlayClubVR) for a functional example that uses an older version of this framework. | 19 | | 5.0 - 5.6 | Supported. However, note that this does not currently leverage Unity's native OpenVR implementation (although you could relatively easily switch to it.) | 20 | 21 | 22 | ## How to use it 23 | 24 | Use [the template](https://github.com/Eusth/VRGIN.Template) to get started. For some (somewhat outdated) insight behind the scenes, see [Hacking VR into a Unity game](https://github.com/Eusth/VRGIN/wiki/Hacking-VR-into-a-Unity-game). For examples, take a look at my VR mods. 25 | -------------------------------------------------------------------------------- /VRGIN.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VRGIN", "VRGIN\VRGIN.csproj", "{22788A2C-7695-4A6A-A9F0-115AB9A05FD4}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VRGIN.U46", "VRGIN\VRGIN.U46.csproj", "{8FE87229-42A4-4CB0-846A-7A2726569B17}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {22788A2C-7695-4A6A-A9F0-115AB9A05FD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {22788A2C-7695-4A6A-A9F0-115AB9A05FD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {22788A2C-7695-4A6A-A9F0-115AB9A05FD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {22788A2C-7695-4A6A-A9F0-115AB9A05FD4}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {8FE87229-42A4-4CB0-846A-7A2726569B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {8FE87229-42A4-4CB0-846A-7A2726569B17}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {8FE87229-42A4-4CB0-846A-7A2726569B17}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {8FE87229-42A4-4CB0-846A-7A2726569B17}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /VRGIN/Controls/Handlers/BodyRumbleHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | using VRGIN.Helpers; 8 | 9 | namespace VRGIN.Controls.Handlers 10 | { 11 | public class BodyRumbleHandler : ProtectedBehaviour 12 | { 13 | private Controller _Controller; 14 | private int _TouchCounter = 0; 15 | private VelocityRumble _Rumble; 16 | 17 | protected override void OnStart() 18 | { 19 | base.OnStart(); 20 | 21 | _Controller = GetComponent(); 22 | _Rumble = new VelocityRumble( 23 | SteamVR_Controller.Input((int)_Controller.Tracking.index), 24 | 30, 10, 3f, 1500, 10); 25 | } 26 | 27 | protected override void OnLevel(int level) 28 | { 29 | base.OnLevel(level); 30 | OnStop(); 31 | 32 | } 33 | 34 | protected void OnDisable() 35 | { 36 | OnStop(); 37 | 38 | } 39 | 40 | protected override void OnUpdate() 41 | { 42 | base.OnUpdate(); 43 | _Rumble.Device = SteamVR_Controller.Input((int)_Controller.Tracking.index); 44 | } 45 | 46 | protected void OnTriggerEnter(Collider collider) 47 | { 48 | if (VR.Interpreter.IsBody(collider)) 49 | { 50 | _TouchCounter++; 51 | 52 | _Controller.StartRumble(_Rumble); 53 | if (_TouchCounter == 1) 54 | { 55 | _Controller.StartRumble(new RumbleImpulse(1000)); 56 | } 57 | } 58 | } 59 | 60 | protected void OnTriggerExit(Collider collider) 61 | { 62 | if (VR.Interpreter.IsBody(collider)) 63 | { 64 | _TouchCounter--; 65 | 66 | if (_TouchCounter == 0) 67 | { 68 | _Controller.StopRumble(_Rumble); 69 | } 70 | } 71 | } 72 | 73 | protected void OnStop() 74 | { 75 | _TouchCounter = 0; 76 | if (_Controller) 77 | { 78 | _Controller.StopRumble(_Rumble); 79 | } 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /VRGIN/Controls/IShortcut.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace VRGIN.Controls 7 | { 8 | public interface IShortcut : IDisposable 9 | { 10 | void Evaluate(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /VRGIN/Controls/KeyboardShortcut.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | using VRGIN.Helpers; 8 | 9 | namespace VRGIN.Controls 10 | { 11 | public class KeyboardShortcut : IShortcut 12 | { 13 | public KeyStroke KeyStroke { get; private set; } 14 | public Action Action { get; private set; } 15 | public KeyMode CheckMode { get; private set; } 16 | 17 | public KeyboardShortcut(KeyStroke keyStroke, Action action, KeyMode checkMode = KeyMode.PressUp) 18 | { 19 | KeyStroke = keyStroke; 20 | Action = action; 21 | CheckMode = checkMode; 22 | } 23 | 24 | public KeyboardShortcut(XmlKeyStroke keyStroke, Action action) 25 | { 26 | KeyStroke = keyStroke.GetKeyStrokes().FirstOrDefault(); 27 | Action = action; 28 | CheckMode = keyStroke.CheckMode; 29 | } 30 | 31 | public void Evaluate() 32 | { 33 | if(KeyStroke.Check(CheckMode)) 34 | { 35 | Action(); 36 | } 37 | } 38 | 39 | public void Dispose() 40 | { 41 | } 42 | } 43 | 44 | public class MultiKeyboardShortcut : IShortcut 45 | { 46 | private const float WAIT_TIME = 0.5f; 47 | 48 | public KeyStroke[] KeyStrokes { get; private set; } 49 | public Action Action { get; private set; } 50 | public KeyMode CheckMode { get; private set; } 51 | 52 | int _Index = 0; 53 | float _Time = 0f; 54 | 55 | public MultiKeyboardShortcut(KeyStroke[] keyStrokes, Action action, KeyMode checkMode = KeyMode.PressUp) 56 | { 57 | KeyStrokes = keyStrokes; 58 | Action = action; 59 | CheckMode = checkMode; 60 | } 61 | public MultiKeyboardShortcut(KeyStroke keyStroke1, KeyStroke keyStroke2, Action action, KeyMode checkMode = KeyMode.PressUp) 62 | { 63 | KeyStrokes = new KeyStroke[] { keyStroke1, keyStroke2 }; 64 | Action = action; 65 | CheckMode = checkMode; 66 | } 67 | 68 | public MultiKeyboardShortcut(XmlKeyStroke stroke, Action action) 69 | { 70 | KeyStrokes = stroke.GetKeyStrokes(); 71 | Action = action; 72 | CheckMode = stroke.CheckMode; 73 | } 74 | 75 | public void Evaluate() 76 | { 77 | if(Time.time - _Time > WAIT_TIME) 78 | { 79 | _Index = 0; 80 | } 81 | 82 | bool isLast = _Index == KeyStrokes.Length - 1; 83 | var mode = isLast 84 | ? CheckMode 85 | : KeyMode.PressUp; 86 | 87 | if (KeyStrokes[_Index].Check(mode)) 88 | { 89 | if (isLast) 90 | { 91 | Action(); 92 | } else 93 | { 94 | _Index++; 95 | _Time = Time.unscaledTime; 96 | } 97 | } 98 | } 99 | 100 | public void Dispose() 101 | { 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /VRGIN/Controls/LeapMotion/PinchController.cs: -------------------------------------------------------------------------------- 1 | using Leap; 2 | using Leap.Unity; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using UnityEngine; 8 | using UnityEngine.Events; 9 | using VRGIN.Core; 10 | using VRGIN.Helpers; 11 | using VRGIN.U46.Helpers; 12 | using VRGIN.Visuals; 13 | 14 | namespace VRGIN.U46.Controls.Leap 15 | { 16 | public class PinchController : ProtectedBehaviour 17 | { 18 | PinchDetector _Left; 19 | PinchDetector _Right; 20 | 21 | ProximityDetector _Proximity; 22 | 23 | DetectorLogicGate _StartDetector; 24 | DetectorLogicGate _Detector; 25 | 26 | bool _Pinching = false; 27 | 28 | GUIQuad _Current; 29 | GuiScaler _Scaler; 30 | private const float MIN_SCALE =0.3f; 31 | 32 | protected override void OnStart() 33 | { 34 | base.OnStart(); 35 | SetUpDetectors(); 36 | } 37 | 38 | void SetUpDetectors() 39 | { 40 | _Left = UnityHelper.CreateGameObjectAsChild("Pinch Detector", transform).gameObject.AddComponent(); 41 | _Right = UnityHelper.CreateGameObjectAsChild("Pinch Detector", transform).gameObject.AddComponent(); 42 | _Proximity = VR.Mode.LeftHand.PinchPoint.gameObject.AddComponent(); 43 | _Proximity.TargetObjects = new GameObject[] { VR.Mode.RightHand.PinchPoint.gameObject }; 44 | _Proximity.OnDistance = 0.1f; 45 | _Proximity.OffDistance = 0.11f; 46 | _Detector = gameObject.AddComponent(); 47 | _StartDetector = gameObject.AddComponent(); 48 | 49 | _Left._handModel = VR.Mode.LeftHand; 50 | _Right._handModel = VR.Mode.RightHand; 51 | 52 | _StartDetector.AddDetector(_Left); 53 | _StartDetector.AddDetector(_Right); 54 | _StartDetector.AddDetector(_Proximity); 55 | 56 | _Detector.AddDetector(_Left); 57 | _Detector.AddDetector(_Right); 58 | 59 | _StartDetector.OnActivate.AddListener(OnStartPinch); 60 | _Detector.OnDeactivate.AddListener(OnStopPinch); 61 | } 62 | 63 | private void OnStartPinch() 64 | { 65 | _Pinching = true; 66 | 67 | if(_Current) 68 | { 69 | DestroyImmediate(_Current.gameObject); 70 | } 71 | _Current = GUIQuad.Create(); 72 | _Current.transform.SetParent(VR.Camera.Origin, false); 73 | DontDestroyOnLoad(_Current); 74 | _Current.transform.position = Vector3.Lerp(VR.Mode.LeftHand.PinchPoint.position, VR.Mode.RightHand.PinchPoint.position, 0.5f); 75 | _Current.transform.rotation = Quaternion.Slerp(VR.Mode.LeftHand.PinchPoint.rotation, VR.Mode.RightHand.PinchPoint.rotation, 0.5f) * Quaternion.Euler(0, 0, 90); 76 | _Current.transform.localScale *= Vector3.Distance(VR.Mode.LeftHand.PinchPoint.position, VR.Mode.RightHand.PinchPoint.position); 77 | 78 | _Scaler = new GuiScaler(_Current, VR.Mode.LeftHand.PinchPoint, VR.Mode.RightHand.PinchPoint); 79 | } 80 | 81 | private void OnStopPinch() 82 | { 83 | if (!_Pinching) return; 84 | 85 | _Pinching = false; 86 | 87 | if (_Current && _Current.transform.localScale.magnitude < MIN_SCALE) 88 | { 89 | DestroyImmediate(_Current.gameObject); 90 | } 91 | } 92 | 93 | protected override void OnUpdate() 94 | { 95 | base.OnUpdate(); 96 | if(_Pinching) 97 | { 98 | _Scaler.Update(); 99 | } 100 | } 101 | 102 | 103 | 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /VRGIN/Controls/LeftController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace VRGIN.Controls 4 | { 5 | 6 | public class LeftController : Controller 7 | { 8 | public static LeftController Create() 9 | { 10 | var leftHand = new GameObject("Left Controller").AddComponent(); 11 | 12 | return leftHand; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /VRGIN/Controls/RightController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Controls 8 | { 9 | public class RightController : Controller 10 | { 11 | public static RightController Create() 12 | { 13 | var rightHand = new GameObject("Right Controller").AddComponent(); 14 | rightHand.ToolIndex = 1; // Start with tool 2 15 | return rightHand; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /VRGIN/Controls/RumbleManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | using VRGIN.Helpers; 8 | 9 | namespace VRGIN.Controls 10 | { 11 | /// 12 | /// Takes care of the rumble functionality. 13 | /// 14 | public class RumbleManager : ProtectedBehaviour 15 | { 16 | const float MILLI_TO_SECONDS = 1f / 1000f; 17 | public const float MIN_INTERVAL = 5 * MILLI_TO_SECONDS; 18 | private HashSet _RumbleSessions = new HashSet(); 19 | private float _LastImpulse; 20 | private Controller _Controller; 21 | 22 | protected override void OnStart() 23 | { 24 | base.OnStart(); 25 | 26 | _Controller = GetComponent(); 27 | } 28 | 29 | protected virtual void OnDisable() 30 | { 31 | _RumbleSessions.Clear(); 32 | } 33 | 34 | 35 | protected override void OnUpdate() 36 | { 37 | base.OnUpdate(); 38 | if (_RumbleSessions.Count > 0) 39 | { 40 | var session = _RumbleSessions.Max(); 41 | float timeSinceLastImpulse = Time.unscaledTime - _LastImpulse; 42 | 43 | if (_Controller.Tracking.isValid && timeSinceLastImpulse >= session.MilliInterval * MILLI_TO_SECONDS && timeSinceLastImpulse > MIN_INTERVAL) 44 | { 45 | 46 | if (session.IsOver) 47 | { 48 | _RumbleSessions.Remove(session); 49 | } 50 | else 51 | { 52 | if (VR.Settings.Rumble) 53 | { 54 | SteamVR_Controller.Input((int)_Controller.Tracking.index).TriggerHapticPulse(session.MicroDuration); 55 | } 56 | _LastImpulse = Time.unscaledTime; 57 | session.Consume(); 58 | } 59 | } 60 | } 61 | } 62 | 63 | public void StartRumble(IRumbleSession session) 64 | { 65 | _RumbleSessions.Add(session); 66 | } 67 | 68 | internal void StopRumble(IRumbleSession session) 69 | { 70 | _RumbleSessions.Remove(session); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /VRGIN/Controls/Speech/VoiceCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace VRGIN.Controls.Speech 7 | { 8 | public class VoiceCommand 9 | { 10 | public static readonly VoiceCommand ToggleMenu = new VoiceCommand("toggle menu"); 11 | public static readonly VoiceCommand Impersonate = new VoiceCommand("impersonate"); 12 | public static readonly VoiceCommand SaveSettings = new VoiceCommand("save settings"); 13 | public static readonly VoiceCommand LoadSettings = new VoiceCommand("load settings"); 14 | public static readonly VoiceCommand ResetSettings = new VoiceCommand("reset settings"); 15 | public static readonly VoiceCommand IncreaseScale = new VoiceCommand("increase scale", "larger", "bigger"); 16 | public static readonly VoiceCommand DecreaseScale = new VoiceCommand("decrease scale", "smaller"); 17 | 18 | public List Texts; 19 | 20 | protected VoiceCommand(params string[] texts) 21 | { 22 | Texts = texts.ToList(); 23 | } 24 | 25 | /// 26 | /// Determines if the given text belongs to this command. 27 | /// 28 | /// 29 | /// 30 | public bool Matches(string text) 31 | { 32 | return Texts.Contains(text); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /VRGIN/Controls/Speech/VoiceShortcut.cs: -------------------------------------------------------------------------------- 1 | using SpeechTransport; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Controls.Speech 9 | { 10 | public class VoiceShortcut : IShortcut 11 | { 12 | SpeechResult? _LastResult; 13 | int _MinID = 0; 14 | 15 | Action _Action; 16 | VoiceCommand _Command; 17 | 18 | public VoiceShortcut(VoiceCommand command, Action action) 19 | { 20 | _Action = action; 21 | _Command = command; 22 | 23 | if (VR.Speech) 24 | { 25 | VR.Speech.SpeechRecognized += OnRecognized; 26 | } 27 | } 28 | 29 | private void OnRecognized(object sender, SpeechRecognizedEventArgs e) 30 | { 31 | if (e.Result.ID >= _MinID) 32 | { 33 | _LastResult = e.Result; 34 | } 35 | } 36 | 37 | public void Dispose() 38 | { 39 | // Unregister handler 40 | if (VR.Speech) 41 | { 42 | VR.Speech.SpeechRecognized -= OnRecognized; 43 | } 44 | } 45 | 46 | public void Evaluate() 47 | { 48 | if(_LastResult.HasValue) 49 | { 50 | if(_Command.Matches(_LastResult.Value.Text)) 51 | { 52 | if (_LastResult.Value.Confidence > 0.2f || _LastResult.Value.Final) 53 | { 54 | VRLog.Info(_Command); 55 | _Action(); 56 | _MinID = _LastResult.Value.ID + 1; 57 | } 58 | } 59 | } 60 | 61 | _LastResult = null; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /VRGIN/Controls/Tools/Tool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | using VRGIN.Core; 8 | 9 | namespace VRGIN.Controls.Tools 10 | { 11 | 12 | /// 13 | /// A tool that can be used with a Vive controller. 14 | /// 15 | public abstract class Tool : ProtectedBehaviour 16 | { 17 | 18 | protected SteamVR_TrackedObject Tracking; 19 | protected Controller Owner; 20 | protected Controller Neighbor; 21 | 22 | 23 | public abstract Texture2D Image 24 | { 25 | get; 26 | } 27 | 28 | public GameObject Icon 29 | { 30 | get; set; 31 | } 32 | 33 | protected override void OnStart() 34 | { 35 | base.OnStart(); 36 | 37 | Tracking = GetComponent(); 38 | Owner = GetComponent(); 39 | Neighbor = VR.Mode.Left == Owner ? VR.Mode.Right : VR.Mode.Left; 40 | VRLog.Info(Neighbor ? "Got my neighbor!" : "No neighbor"); 41 | } 42 | 43 | protected abstract void OnDestroy(); 44 | 45 | 46 | /// 47 | /// Gets whether or not the attached controlller is tracking. 48 | /// 49 | protected bool IsTracking 50 | { 51 | get 52 | { 53 | return Tracking && Tracking.isValid; 54 | } 55 | } 56 | 57 | /// 58 | /// Gets the attached controller input object. 59 | /// 60 | protected SteamVR_Controller.Device Controller 61 | { 62 | get 63 | { 64 | return SteamVR_Controller.Input((int)Tracking.index); 65 | } 66 | } 67 | 68 | /// 69 | /// Gets the attached controller input object. 70 | /// 71 | protected Controller OtherController 72 | { 73 | get 74 | { 75 | return Neighbor; 76 | } 77 | } 78 | 79 | 80 | protected virtual void OnEnable() 81 | { 82 | VRLog.Info("On Enable: {0}", GetType().Name); 83 | if (Icon) 84 | { 85 | Icon.SetActive(true); 86 | } 87 | else 88 | { 89 | VRLog.Info("But no icon..."); 90 | 91 | } 92 | } 93 | 94 | protected virtual void OnDisable() 95 | { 96 | VRLog.Info("On Disable: {0}", GetType().Name); 97 | if (Icon) 98 | { 99 | Icon.SetActive(false); 100 | } 101 | else 102 | { 103 | VRLog.Info("But no icon..."); 104 | } 105 | } 106 | 107 | public virtual List GetHelpTexts() 108 | { 109 | return new List(); 110 | } 111 | 112 | protected Transform FindAttachPosition(params string[] names) 113 | { 114 | return Owner.FindAttachPosition(names); 115 | } 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /VRGIN/Core/DefaultActor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | public class Marker : MonoBehaviour 10 | { 11 | } 12 | /// 13 | /// Default actor that is defined by a Unity behaviour. 14 | /// 15 | /// Type of the MonoBehaviour 16 | public abstract class DefaultActor : IActor where T : MonoBehaviour 17 | { 18 | 19 | 20 | public T Actor { get; protected set; } 21 | 22 | public DefaultActor(T nativeActor) 23 | { 24 | Actor = nativeActor; 25 | 26 | this.Initialize(nativeActor); 27 | } 28 | 29 | public virtual bool IsValid 30 | { 31 | get 32 | { 33 | return Actor; 34 | } 35 | } 36 | 37 | public abstract Transform Eyes 38 | { 39 | get; 40 | } 41 | 42 | 43 | public abstract bool HasHead 44 | { 45 | get; 46 | set; 47 | } 48 | 49 | protected virtual void Initialize(T actor) 50 | { 51 | Actor.gameObject.AddComponent(); 52 | } 53 | 54 | public static bool IsAlreadyMapped(T nativeActor) 55 | { 56 | return nativeActor.GetComponent(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /VRGIN/Core/DefaultActorBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | public abstract class DefaultActorBehaviour : ProtectedBehaviour, IActor where T : MonoBehaviour 10 | { 11 | public T Actor { get; protected set; } 12 | 13 | public static A Create(T nativeActor) where A : DefaultActorBehaviour 14 | { 15 | var actor = nativeActor.GetComponent(); 16 | if(!actor) 17 | { 18 | actor = nativeActor.gameObject.AddComponent(); 19 | actor.Initialize(nativeActor); 20 | } 21 | return actor; 22 | } 23 | 24 | public virtual bool IsValid 25 | { 26 | get 27 | { 28 | return Actor; 29 | } 30 | } 31 | 32 | public abstract Transform Eyes 33 | { 34 | get; 35 | } 36 | 37 | 38 | public abstract bool HasHead 39 | { 40 | get; 41 | set; 42 | } 43 | 44 | protected virtual void Initialize(T actor) 45 | { 46 | this.Actor = actor; 47 | VRLog.Info("Creating character {0}", actor.name); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /VRGIN/Core/IActor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | /// 10 | /// Represents an actor that takes part in the game. 11 | /// 12 | public interface IActor 13 | { 14 | /// 15 | /// Gets whether or not this object is still valid. 16 | /// 17 | bool IsValid { get; } 18 | 19 | /// 20 | /// Gets the transform used for the eyes. 21 | /// z+ = forward 22 | /// y+ = up 23 | /// 24 | Transform Eyes { get; } 25 | 26 | /// 27 | /// Gets or sets whether or not this actor still has his head. 28 | /// 29 | bool HasHead 30 | { 31 | get; 32 | set; 33 | } 34 | 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /VRGIN/Core/PlayArea.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | public class PlayArea 10 | { 11 | public float Scale { get; set; } 12 | public Vector3 Position { get; set; } 13 | public float Rotation { get; set; } 14 | public float Height 15 | { 16 | get 17 | { 18 | return Position.y; 19 | } 20 | set 21 | { 22 | Position = new Vector3(Position.x, value, Position.z); 23 | } 24 | } 25 | 26 | public PlayArea() 27 | { 28 | Scale = 1; 29 | } 30 | 31 | public void Apply() 32 | { 33 | var rotOffset = Quaternion.Euler(0, Rotation, 0); 34 | var steamCam = VR.Camera.SteamCam; 35 | 36 | steamCam.origin.position = Position 37 | - rotOffset * new Vector3(steamCam.head.transform.localPosition.x, 0, steamCam.head.transform.localPosition.z) * Scale; 38 | steamCam.origin.rotation = rotOffset; 39 | 40 | VR.Settings.IPDScale = Scale; 41 | } 42 | 43 | public void Reset() 44 | { 45 | Position = new Vector3(VR.Camera.Head.position.x, VR.Camera.Origin.position.y, VR.Camera.Head.position.z); 46 | Scale = VR.Settings.IPDScale; 47 | Rotation = VR.Camera.Origin.rotation.eulerAngles.y; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /VRGIN/Core/ProtectedBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using UnityEngine; 9 | 10 | namespace VRGIN.Core 11 | { 12 | /// 13 | /// Behaviour that wraps a few of Unity's methods in try/catch blocks. 14 | /// 15 | public class ProtectedBehaviour : MonoBehaviour 16 | { 17 | private static IDictionary PerformanceTable = new Dictionary(); 18 | 19 | private string GetKey(string method) 20 | { 21 | return String.Format("{0}#{1}",GetType().FullName,method); 22 | } 23 | protected void Start() 24 | { 25 | SafelyCall(OnStart); 26 | } 27 | 28 | protected void Awake() 29 | { 30 | SafelyCall(OnAwake); 31 | } 32 | 33 | protected void Update() 34 | { 35 | SafelyCall(OnUpdate); 36 | } 37 | 38 | protected void LateUpdate() 39 | { 40 | SafelyCall(OnLateUpdate); 41 | } 42 | 43 | protected void FixedUpdate() 44 | { 45 | SafelyCall(OnFixedUpdate); 46 | } 47 | 48 | protected void OnLevelWasLoaded(int level) 49 | { 50 | SafelyCall(delegate { OnLevel(level); }); 51 | } 52 | 53 | protected virtual void OnStart() { } 54 | protected virtual void OnUpdate() { } 55 | protected virtual void OnLateUpdate() { } 56 | protected virtual void OnFixedUpdate() { } 57 | protected virtual void OnAwake() { } 58 | protected virtual void OnLevel(int level) { } 59 | 60 | 61 | private void SafelyCall(Action action) 62 | { 63 | try 64 | { 65 | //StackFrame frame = new StackFrame(1); 66 | //var method = frame.GetMethod(); 67 | //var key = GetKey(method.Name); 68 | 69 | //var stopWatch = Stopwatch.StartNew(); 70 | 71 | action(); 72 | 73 | //stopWatch.Stop(); 74 | //if (!PerformanceTable.ContainsKey(key)) 75 | //{ 76 | // PerformanceTable[key] = 0L; 77 | //} 78 | //PerformanceTable[key] += stopWatch.Elapsed.TotalMilliseconds; 79 | } 80 | catch (Exception ex) 81 | { 82 | Logger.Error(ex); 83 | } 84 | } 85 | 86 | public static void DumpTable() 87 | { 88 | Logger.Info("DUMP"); 89 | var builder = new StringBuilder(); 90 | 91 | var enumerator = PerformanceTable.GetEnumerator(); 92 | while(enumerator.MoveNext()) 93 | { 94 | builder.AppendFormat("{1}ms: {0}\n", enumerator.Current.Key, enumerator.Current.Value / Time.realtimeSinceStartup); 95 | } 96 | 97 | File.WriteAllText("performance.txt", builder.ToString()); 98 | } 99 | 100 | public void Invoke(Action action, float delayInSeconds) 101 | { 102 | StartCoroutine(_Invoke(action, delayInSeconds)); 103 | } 104 | 105 | private IEnumerator _Invoke(Action action, float delay) 106 | { 107 | yield return new WaitForSeconds(delay); 108 | try 109 | { 110 | action(); 111 | } catch(Exception e) 112 | { 113 | VRLog.Error(e); 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /VRGIN/Core/ScreenGrabber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | 10 | public interface IScreenGrabber 11 | { 12 | bool Check(Camera camera); 13 | IEnumerable GetTextures(); 14 | void OnAssign(Camera camera); 15 | } 16 | 17 | public class ScreenGrabber : IScreenGrabber 18 | { 19 | public delegate bool JudgingMethod(Camera camera); 20 | 21 | // Predefined functions 22 | public static JudgingMethod FromList(IEnumerable allowedCameras) => (Camera camera) => allowedCameras.Contains(camera); 23 | public static JudgingMethod FromList(params String[] allowedCameraNames) => (Camera camera) => allowedCameraNames.Contains(camera.name); 24 | 25 | 26 | private IList _Cameras = new List(); 27 | private HashSet _CheckedCameras = new HashSet(); 28 | public RenderTexture Texture { get; private set; } 29 | 30 | public int Height { get; private set; } 31 | public int Width { get; private set; } 32 | 33 | private JudgingMethod _Judge; 34 | 35 | public ScreenGrabber(int width, int height, JudgingMethod method) 36 | { 37 | Texture = new RenderTexture(width, height, 24, RenderTextureFormat.Default); 38 | Width = width; 39 | Height = height; 40 | 41 | _Judge = method; 42 | } 43 | 44 | public bool Check(Camera camera) 45 | { 46 | return _Judge(camera); 47 | } 48 | 49 | public IEnumerable GetTextures() 50 | { 51 | yield return Texture; 52 | } 53 | 54 | public void OnAssign(Camera camera) 55 | { 56 | } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /VRGIN/Core/Throttler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Core 8 | { 9 | /// 10 | /// Keeps all Behaviours on a GameObject disabled except for Transform. 11 | /// 12 | class WhitelistThrottler : ProtectedBehaviour 13 | { 14 | /// 15 | /// Components that should not be disabled. 16 | /// 17 | public HashSet Exceptions = new HashSet(); 18 | 19 | protected override void OnStart() 20 | { 21 | Exceptions.Add(typeof(Transform)); 22 | Exceptions.Add(typeof(ProtectedBehaviour)); 23 | base.OnStart(); 24 | } 25 | 26 | protected override void OnUpdate() 27 | { 28 | foreach (var behaviour in GetComponents().Where(c => !Exceptions.Contains(c.GetType()))) 29 | { 30 | behaviour.enabled = false; 31 | } 32 | base.OnUpdate(); 33 | } 34 | } 35 | 36 | class BlacklistThrottler : ProtectedBehaviour 37 | { 38 | /// 39 | /// Components that should be disabled. 40 | /// 41 | public HashSet Targets = new HashSet(); 42 | 43 | protected override void OnStart() 44 | { 45 | Targets.Add(typeof(Camera)); 46 | base.OnStart(); 47 | } 48 | 49 | protected override void OnUpdate() 50 | { 51 | foreach (var behaviour in GetComponents().Where(c => Targets.Contains(c.GetType()))) 52 | { 53 | behaviour.enabled = false; 54 | } 55 | base.OnUpdate(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /VRGIN/Helpers/Calculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Helpers 9 | { 10 | public static class Calculator 11 | { 12 | /// 13 | /// Turns a world distance into an invariant meter value. 14 | /// 15 | /// 16 | /// 17 | public static float Distance(float worldValue) 18 | { 19 | return worldValue / VR.Settings.IPDScale * VR.Context.UnitToMeter; 20 | } 21 | 22 | 23 | /// 24 | /// Gets the signed angle between two vectors 25 | /// 26 | /// 27 | public static float Angle(Vector3 v1, Vector3 v2) 28 | { 29 | var angleA = Mathf.Atan2(v1.x, v1.z) * Mathf.Rad2Deg; 30 | var angleB = Mathf.Atan2(v2.x, v2.z) * Mathf.Rad2Deg; 31 | return Mathf.DeltaAngle(angleA, angleB); 32 | } 33 | 34 | /// 35 | /// Gets the "strongest" forward vector on the Y plane. 36 | /// This might be a little roundabout, but it seems to work... 37 | /// 38 | /// 39 | /// 40 | public static Vector3 GetForwardVector(Quaternion rotation) 41 | { 42 | var rotatedForward = rotation * Vector3.forward; 43 | return new Vector3[] { 44 | Vector3.ProjectOnPlane(rotatedForward, Vector3.up), 45 | Vector3.ProjectOnPlane(rotation * (rotatedForward.y > 0f ? Vector3.down : Vector3.up), Vector3.up) 46 | }.OrderByDescending(v => v.sqrMagnitude).First().normalized; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /VRGIN/Helpers/CameraConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Helpers 9 | { 10 | public class CameraConsumer : IScreenGrabber 11 | { 12 | private RenderTexture _Texture; 13 | private bool _SpareMainCamera; 14 | private bool _SoftMode; 15 | 16 | public bool Check(Camera camera) 17 | { 18 | return !camera.GetComponent("UICamera") && !camera.name.Contains("VR") && camera.targetTexture == null && (!camera.CompareTag("MainCamera") || !_SpareMainCamera); 19 | } 20 | 21 | public IEnumerable GetTextures() 22 | { 23 | yield return _Texture; 24 | } 25 | 26 | public void OnAssign(Camera camera) 27 | { 28 | if (_SoftMode) 29 | { 30 | camera.cullingMask = 0; 31 | camera.nearClipPlane = 1; 32 | camera.farClipPlane = 1; 33 | } 34 | else 35 | { 36 | camera.enabled = false; 37 | } 38 | } 39 | 40 | public CameraConsumer(bool spareMainCamera = false, bool softMode = false) 41 | { 42 | _SoftMode = softMode; 43 | _SpareMainCamera = spareMainCamera; 44 | _Texture = new RenderTexture(1, 1, 0); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /VRGIN/Helpers/CameraMonitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Helpers 9 | { 10 | public class CameraMonitor : ProtectedBehaviour 11 | { 12 | Stopwatch _Stopwatch = new Stopwatch(); 13 | 14 | public void OnPreCull() 15 | { 16 | _Stopwatch.Reset(); 17 | _Stopwatch.Start(); 18 | } 19 | 20 | public void OnPreRender() 21 | { 22 | _Stopwatch.Stop(); 23 | VRLog.Info("{0}: Cull {1}ms", gameObject.name, _Stopwatch.Elapsed.TotalMilliseconds); 24 | _Stopwatch.Reset(); 25 | _Stopwatch.Start(); 26 | } 27 | 28 | public void OnPostRender() 29 | { 30 | _Stopwatch.Stop(); 31 | VRLog.Info("{0}: Render {1}ms", gameObject.name, _Stopwatch.Elapsed.TotalMilliseconds); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /VRGIN/Helpers/Capture/Internals/Icosphere.cs: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | // For more information, please refer to 3 | 4 | using System; 5 | using UnityEngine; 6 | 7 | // Based on http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html 8 | // Currently unused but planned for use with future features like seam-free mono capture. 9 | namespace CapturePanorama 10 | { 11 | public static class Icosphere 12 | { 13 | 14 | // Use this for initialization 15 | public static Mesh BuildIcosphere(float radius, int iterations) 16 | { 17 | Mesh result = BuildIcosahedron(radius); 18 | for (int i = 0; i < iterations; i++) 19 | Refine(result); 20 | return result; 21 | } 22 | 23 | public static Mesh BuildIcosahedron(float radius) // radius is distance to each vertex from origin 24 | { 25 | Mesh result = new Mesh(); 26 | 27 | // create 12 vertices of a icosahedron 28 | float t = (float)((1.0 + Math.Sqrt(5.0)) / 2.0); 29 | 30 | Vector3[] vertices = new Vector3[] 31 | { 32 | new Vector3(-1.0f, t, 0.0f), 33 | new Vector3( 1.0f, t, 0.0f), 34 | new Vector3(-1.0f, -t, 0.0f), 35 | new Vector3( 1.0f, -t, 0.0f), 36 | 37 | new Vector3( 0.0f, -1.0f, t), 38 | new Vector3( 0.0f, 1.0f, t), 39 | new Vector3( 0.0f, -1.0f, -t), 40 | new Vector3( 0.0f, 1.0f, -t), 41 | 42 | new Vector3( t, 0.0f, -1.0f), 43 | new Vector3( t, 0.0f, 1.0f), 44 | new Vector3( -t, 0.0f, -1.0f), 45 | new Vector3( -t, 0.0f, 1.0f), 46 | }; 47 | 48 | float scale = radius / new Vector3(1.0f, t, 0.0f).magnitude; 49 | for (int i = 0; i < vertices.Length; i++) 50 | vertices[i] *= scale; 51 | 52 | result.vertices = vertices; 53 | 54 | result.triangles = new int[] 55 | { 56 | // 5 faces around point 0 57 | 0, 11, 5, 58 | 0, 5, 1, 59 | 0, 1, 7, 60 | 0, 7, 10, 61 | 0, 10, 11, 62 | 63 | // 5 adjacent faces 64 | 1, 5, 9, 65 | 5, 11, 4, 66 | 11, 10, 2, 67 | 10, 7, 6, 68 | 7, 1, 8, 69 | 70 | // 5 faces around point 3 71 | 3, 9, 4, 72 | 3, 4, 2, 73 | 3, 2, 6, 74 | 3, 6, 8, 75 | 3, 8, 9, 76 | 77 | // 5 adjacent faces 78 | 4, 9, 5, 79 | 2, 4, 11, 80 | 6, 2, 10, 81 | 8, 6, 7, 82 | 9, 8, 1, 83 | }; 84 | 85 | return result; 86 | } 87 | 88 | private static void Refine(Mesh m) 89 | { 90 | throw new Exception("TODO"); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /VRGIN/Helpers/Capture/Internals/ImageEffectCopyCamera.cs: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | // For more information, please refer to 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Reflection; 7 | using UnityEngine; 8 | 9 | namespace CapturePanorama.Internals 10 | { 11 | class ImageEffectCopyCamera : MonoBehaviour 12 | { 13 | public struct InstanceMethodPair { 14 | public object Instance; 15 | public MethodInfo Method; 16 | } 17 | public List onRenderImageMethods = new List(); 18 | 19 | public static List GenerateMethodList(Camera camToCopy) 20 | { 21 | var result = new List(); 22 | foreach (var script in camToCopy.gameObject.GetComponents()) 23 | { 24 | if (script.enabled) 25 | { 26 | Type scriptType = script.GetType(); 27 | MethodInfo m = scriptType.GetMethod("OnRenderImage", 28 | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, 29 | new Type[] { typeof(RenderTexture), typeof(RenderTexture) }, null); 30 | if (m != null) 31 | { 32 | InstanceMethodPair pair = new InstanceMethodPair(); 33 | pair.Instance = script; 34 | pair.Method = m; 35 | result.Add(pair); 36 | } 37 | } 38 | } 39 | return result; 40 | } 41 | 42 | RenderTexture[] temp = new RenderTexture[] { null, null }; 43 | 44 | void OnDestroy() 45 | { 46 | for (int i = 0; i < temp.Length; i++) 47 | { 48 | if (temp[i] != null) 49 | Destroy(temp[i]); 50 | temp[i] = null; 51 | } 52 | } 53 | 54 | void OnRenderImage(RenderTexture src, RenderTexture dest) 55 | { 56 | int desiredDepth = Math.Max(src.depth, dest.depth); 57 | 58 | for (int i = 0; i < temp.Length; i++) 59 | { 60 | if (onRenderImageMethods.Count > i + 1) 61 | { 62 | if (temp[i] != null && 63 | (temp[i].width != dest.width || temp[i].height != dest.height || temp[i].depth != desiredDepth || temp[i].format != dest.format)) 64 | { 65 | Destroy(temp[i]); 66 | temp[i] = null; 67 | } 68 | if (temp[i] == null) 69 | temp[i] = new RenderTexture(dest.width, dest.height, desiredDepth, dest.format); 70 | } 71 | } 72 | 73 | var sequence = new List(); 74 | sequence.Add(src); 75 | for (int i = 0; i < onRenderImageMethods.Count - 1; i++) 76 | sequence.Add(i % 2 == 0 ? temp[0] : temp[1]); 77 | sequence.Add(dest); 78 | 79 | for (int i = 0; i < onRenderImageMethods.Count; i++) 80 | onRenderImageMethods[i].Method.Invoke(onRenderImageMethods[i].Instance, new object[] { sequence[i], sequence[i + 1] }); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /VRGIN/Helpers/Capture/Internals/ScreenFadeControl.cs: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | // For more information, please refer to 3 | 4 | using UnityEngine; 5 | 6 | namespace CapturePanorama.Internals 7 | { 8 | public class ScreenFadeControl : MonoBehaviour 9 | { 10 | public Material fadeMaterial = null; 11 | 12 | // Based on OVRScreenFade 13 | #if UNITY_ANDROID && !UNITY_EDITOR 14 | void OnCustomPostRender() 15 | #else 16 | void OnPostRender() 17 | #endif 18 | { 19 | fadeMaterial.SetPass(0); 20 | GL.PushMatrix(); 21 | GL.LoadOrtho(); 22 | GL.Color(fadeMaterial.color); 23 | GL.Begin(GL.QUADS); 24 | GL.Vertex3(0f, 0f, -12f); 25 | GL.Vertex3(0f, 1f, -12f); 26 | GL.Vertex3(1f, 1f, -12f); 27 | GL.Vertex3(1f, 0f, -12f); 28 | GL.End(); 29 | GL.PopMatrix(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /VRGIN/Helpers/LookTargetController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Helpers 9 | { 10 | /** 11 | * Manages the eye target for a single actor. 12 | */ 13 | public class LookTargetController : ProtectedBehaviour 14 | { 15 | /// 16 | /// Gets the target for the gaze. 17 | /// 18 | public Transform Target { get; private set; } 19 | 20 | private Transform _RootNode; 21 | 22 | /// 23 | /// Gets or sets the offset in meters from the camera (shifts the eye focus) 24 | /// 25 | public float Offset = 0.5f; 26 | 27 | public static LookTargetController AttachTo(IActor actor, GameObject gameObject) 28 | { 29 | var controller = gameObject.AddComponent(); 30 | controller._RootNode = actor.Eyes; 31 | 32 | return controller; 33 | } 34 | 35 | protected override void OnAwake() 36 | { 37 | base.OnAwake(); 38 | CreateTarget(); 39 | } 40 | 41 | private void CreateTarget() 42 | { 43 | Target = new GameObject("VRGIN_LookTarget").transform; 44 | DontDestroyOnLoad(Target.gameObject); 45 | } 46 | 47 | protected override void OnUpdate() 48 | { 49 | base.OnUpdate(); 50 | if (_RootNode && VR.Camera.SteamCam.head.transform) 51 | { 52 | var camera = VR.Camera.SteamCam.head.transform; 53 | var dir = (camera.position - _RootNode.position).normalized; 54 | 55 | Target.transform.position = camera.position + dir * Offset; 56 | } 57 | } 58 | 59 | void OnDestroy() 60 | { 61 | // Character was destroyed, so destroy the created target! 62 | Destroy(Target.gameObject); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /VRGIN/Helpers/MeshExtension.cs: -------------------------------------------------------------------------------- 1 | // C# 2 | using UnityEngine; 3 | using System.Collections.Generic; 4 | 5 | namespace VRGIN.Helpers 6 | { 7 | public static class MeshExtension 8 | { 9 | public static Vector3 GetBarycentric(Vector2 v1, Vector2 v2, Vector2 v3, Vector2 p) 10 | { 11 | Vector3 B = new Vector3(); 12 | B.x = ((v2.y - v3.y) * (p.x - v3.x) + (v3.x - v2.x) * (p.y - v3.y)) / 13 | ((v2.y - v3.y) * (v1.x - v3.x) + (v3.x - v2.x) * (v1.y - v3.y)); 14 | B.y = ((v3.y - v1.y) * (p.x - v3.x) + (v1.x - v3.x) * (p.y - v3.y)) / 15 | ((v3.y - v1.y) * (v2.x - v3.x) + (v1.x - v3.x) * (v2.y - v3.y)); 16 | B.z = 1 - B.x - B.y; 17 | return B; 18 | } 19 | 20 | public static bool InTriangle(Vector3 barycentric) 21 | { 22 | return (barycentric.x >= 0.0f) && (barycentric.x <= 1.0f) 23 | && (barycentric.y >= 0.0f) && (barycentric.y <= 1.0f) 24 | && (barycentric.z >= 0.0f); //(barycentric.z <= 1.0f) 25 | } 26 | 27 | public static Vector3[] GetMappedPoints(this Mesh aMesh, Vector2 aUVPos) 28 | { 29 | List result = new List(); 30 | Vector3[] verts = aMesh.vertices; 31 | Vector2[] uvs = aMesh.uv; 32 | int[] indices = aMesh.triangles; 33 | for (int i = 0; i < indices.Length; i += 3) 34 | { 35 | int i1 = indices[i]; 36 | int i2 = indices[i + 1]; 37 | int i3 = indices[i + 2]; 38 | Vector3 bary = GetBarycentric(uvs[i1], uvs[i2], uvs[i3], aUVPos); 39 | if (InTriangle(bary)) 40 | { 41 | Vector3 localP = bary.x * verts[i1] + bary.y * verts[i2] + bary.z * verts[i3]; 42 | result.Add(localP); 43 | } 44 | } 45 | return result.ToArray(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /VRGIN/Helpers/QuaternionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Helpers 8 | { 9 | public static class QuaternionExtensions 10 | { 11 | public static Vector3 ToPitchYawRollRad(this Quaternion rotation) 12 | { 13 | float roll = Mathf.Atan2(2 * rotation.y * rotation.w - 2 * rotation.x * rotation.z, 1 - 2 * rotation.y * rotation.y - 2 * rotation.z * rotation.z); 14 | float pitch = Mathf.Atan2(2 * rotation.x * rotation.w - 2 * rotation.y * rotation.z, 1 - 2 * rotation.x * rotation.x - 2 * rotation.z * rotation.z); 15 | float yaw = Mathf.Asin(2 * rotation.x * rotation.y + 2 * rotation.z * rotation.w); 16 | 17 | return new Vector3(pitch, yaw, roll); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /VRGIN/Helpers/RenderTextureExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Helpers 8 | { 9 | public static class RenderTextureExtensions 10 | { 11 | public static void SaveToFile(this RenderTexture renderTexture, string name) 12 | { 13 | RenderTexture currentActiveRT = RenderTexture.active; 14 | RenderTexture.active = renderTexture; 15 | Texture2D tex = new Texture2D(renderTexture.width, renderTexture.height); 16 | tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0); 17 | var bytes = tex.EncodeToPNG(); 18 | System.IO.File.WriteAllBytes(name, bytes); 19 | UnityEngine.Object.Destroy(tex); 20 | RenderTexture.active = currentActiveRT; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /VRGIN/Helpers/ResourceManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Helpers 9 | { 10 | /// 11 | /// Asset bundle compatibility: 12 | /// 13 | /// # 5.0 14 | /// 5.0 15 | /// 16 | /// # 5.2 17 | /// 5.1, 5.2, 5.3? 18 | /// 19 | /// # 5.3 20 | /// 5.3 21 | /// 22 | /// # 5.4 23 | /// 5.4, 5.5? 24 | /// 25 | public static class ResourceManager 26 | { 27 | private static readonly string VERSION = string.Join(".", Application.unityVersion.Split('.').Take(2).ToArray()); 28 | 29 | public static byte[] SteamVR 30 | { 31 | get 32 | { 33 | if(VERSION.CompareTo("5.0") <= 0) 34 | { 35 | return Resource.vrgin_5_0; 36 | } 37 | if(VERSION.CompareTo("5.2") <= 0) 38 | { 39 | return Resource.vrgin_5_2; 40 | } 41 | if(VERSION.CompareTo("5.3") <= 0) 42 | { 43 | return Resource.vrgin_5_3; 44 | } 45 | if(VERSION.CompareTo("5.4") <= 0) 46 | { 47 | return Resource.vrgin_5_4; 48 | } 49 | if (VERSION.CompareTo("5.5") <= 0) 50 | { 51 | return Resource.vrgin_5_5; 52 | } 53 | 54 | return Resource.vrgin_5_6; 55 | } 56 | } 57 | 58 | public static byte[] Capture 59 | { 60 | get 61 | { 62 | return SteamVR; 63 | } 64 | } 65 | 66 | public static byte[] Hands 67 | { 68 | get 69 | { 70 | return Resource.hands_5_3; 71 | } 72 | } 73 | 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /VRGIN/Helpers/SteamVRDetector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace VRGIN.Helpers 8 | { 9 | public static class SteamVRDetector 10 | { 11 | private static bool FilterInvalidProcesses(Process p) 12 | { 13 | try 14 | { 15 | return p.ProcessName != null; 16 | } 17 | catch 18 | { 19 | return false; 20 | } 21 | } 22 | 23 | public static bool IsRunning 24 | { 25 | get 26 | { 27 | return Process.GetProcesses().Where(FilterInvalidProcesses).Any(process => process.ProcessName == "vrcompositor"); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Attachments/AttachmentController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using System.Collections; 4 | 5 | namespace Leap.Unity { 6 | 7 | /** 8 | * Controls activation and deactivation of child game objects, optionally using a transition. 9 | * 10 | * Call Activate() to enable all child objects. If an InTransition is specified, it is applied 11 | * after enabling the children. 12 | * 13 | * Call Deactivate() to disable all child objects. If an OutTransition is specified, it is applied 14 | * before the children are deactivated. 15 | * 16 | * You can override ChangeChildState() for more sophisticated behavior. 17 | * 18 | * Use with Detectors and a DetectorAndGate to turn on and off hand attachments based 19 | * on hand pose or other factors for which a detector class exists. 20 | * 21 | * @since 4.1.1 22 | */ 23 | public class AttachmentController : MonoBehaviour { 24 | 25 | /** 26 | * Reports whether this attachment is in an activated state or not. 27 | * @since 4.1.1 28 | */ 29 | public bool IsActive = false; 30 | /** 31 | * A Transition played when the attachment is activated. 32 | * @since 4.1.1 33 | */ 34 | public Transition InTransition; 35 | /** 36 | * A Transition played when the attachment is deactivated. 37 | * @since 4.1.1 38 | */ 39 | public Transition OutTransition; 40 | 41 | /** 42 | * Activates the attachment's child object. 43 | * Plays the InTransition, if one is specified. 44 | * @since 4.1.1 45 | */ 46 | public virtual void Activate(bool doTransition = true){ 47 | IsActive = true; 48 | ChangeChildState(); 49 | if(InTransition != null && doTransition){ 50 | InTransition.OnComplete.AddListener(ChangeChildState); 51 | InTransition.TransitionIn(); 52 | } 53 | } 54 | 55 | /** 56 | * Deactivates the attachment's child object. 57 | * Plays the OutTransition, if one is specified. 58 | * @since 4.1.1 59 | */ 60 | public virtual void Deactivate(bool doTransition = true) { 61 | IsActive = false; 62 | if(OutTransition != null && doTransition){ 63 | OutTransition.OnComplete.AddListener(ChangeChildState); 64 | OutTransition.TransitionOut(); 65 | } else { 66 | ChangeChildState(); 67 | } 68 | } 69 | 70 | /** 71 | * Toggles child state. 72 | * @since 4.1.1 73 | */ 74 | protected virtual void ChangeChildState(){ 75 | if(InTransition != null){ 76 | InTransition.OnComplete.RemoveListener(ChangeChildState); 77 | } 78 | if(OutTransition != null){ 79 | OutTransition.OnComplete.RemoveListener(ChangeChildState); 80 | } 81 | Transform[] children = GetComponentsInChildren(true); 82 | for(int g = 0; g < children.Length; g++){ 83 | if ( children[g].gameObject.GetInstanceID() != gameObject.GetInstanceID() ) { 84 | children[g].gameObject.SetActive(IsActive); 85 | } 86 | } 87 | } 88 | 89 | private void OnDisable(){ 90 | Deactivate(false); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Attachments/CameraFollower.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity{ 5 | 6 | public class CameraFollower : MonoBehaviour { 7 | 8 | public Vector3 objectForward = Vector3.forward; 9 | public AnimationCurve Ease = AnimationCurve.EaseInOut(0, 0, 1, 1); 10 | [Range(1, 20)] 11 | public float Speed = 10; 12 | public bool FreezeX = false; 13 | public bool FreezeY = false; 14 | public bool FreezeZ = false; 15 | 16 | private Quaternion offset; 17 | private Quaternion startingLocalRotation; 18 | 19 | void Awake(){ 20 | offset = Quaternion.Inverse(Quaternion.LookRotation(objectForward)); 21 | startingLocalRotation = transform.localRotation; 22 | } 23 | 24 | void Update () { 25 | Vector3 cameraDirection = (Camera.main.transform.position - transform.position).normalized; 26 | Vector3 objectFacing = transform.TransformDirection(objectForward); 27 | float deltaAngle = Vector3.Angle(objectFacing, cameraDirection); 28 | float easing = Ease.Evaluate(Speed * deltaAngle / 360); 29 | Quaternion towardCamera = Quaternion.LookRotation(cameraDirection); 30 | towardCamera *= offset; 31 | transform.rotation = Quaternion.Slerp(transform.rotation, towardCamera, easing); 32 | Vector3 startingEulers = startingLocalRotation.eulerAngles; 33 | Vector3 targetEulers = transform.localEulerAngles; 34 | float angleX, angleY, angleZ; 35 | if(FreezeX){ 36 | angleX = startingEulers.x; 37 | } else { 38 | angleX = targetEulers.x; 39 | } 40 | if(FreezeY){ 41 | angleY = startingEulers.y; 42 | } else { 43 | angleY = targetEulers.y; 44 | } 45 | if(FreezeZ){ 46 | angleZ = startingEulers.z; 47 | } else { 48 | angleZ = targetEulers.z; 49 | } 50 | transform.localEulerAngles = new Vector3(angleX, angleY, angleZ); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/DetectionUtilities/Detector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using System.Collections; 4 | using Leap; 5 | 6 | namespace Leap.Unity { 7 | 8 | /** 9 | * Base class for detectors. 10 | * 11 | * A Detector is an object that observes some aspect of a scene and reports true 12 | * when the specified conditions are met. Typically these conditions involve hand 13 | * information, but this is not required. 14 | * 15 | * Detector implementations must call Activate() when their conditions are met and 16 | * Deactivate() when those conditions are no longer met. Implementations should 17 | * also call Deactivate() when they, or the object they are a component of become disabled. 18 | * Implementations can call Activate() and Deactivate() more often than is strictly necessary. 19 | * This Detector base class keeps track of the IsActive status and only dispatches events 20 | * when the status changes. 21 | * 22 | * @since 4.1.2 23 | */ 24 | public class Detector : MonoBehaviour { 25 | /** The current detector state. 26 | * @since 4.1.2 27 | */ 28 | public bool IsActive{ get{ return _isActive;}} 29 | private bool _isActive = false; 30 | /** Whether to draw the detector's Gizmos for debugging. (Not every detector provides gizmos.) 31 | * @since 4.1.2 32 | */ 33 | [Tooltip("Draw this detector's Gizmos, if any. (Gizmos must be on in Unity edtor, too.)")] 34 | public bool ShowGizmos = true; 35 | /** Dispatched when the detector activates (becomes true). 36 | * @since 4.1.2 37 | */ 38 | [Tooltip("Dispatched when condition is detected.")] 39 | public UnityEvent OnActivate = new UnityEvent(); 40 | /** Dispatched when the detector deactivates (becomes false). 41 | * @since 4.1.2 42 | */ 43 | [Tooltip("Dispatched when condition is no longer detected.")] 44 | public UnityEvent OnDeactivate = new UnityEvent(); 45 | 46 | /** 47 | * Invoked when this detector activates. 48 | * Subclasses must call this function when the detector's conditions become true. 49 | * @since 4.1.2 50 | */ 51 | public virtual void Activate(){ 52 | if (!IsActive) { 53 | _isActive = true; 54 | OnActivate.Invoke(); 55 | } 56 | } 57 | 58 | /** 59 | * Invoked when this detector deactivates. 60 | * Subclasses must call this function when the detector's conditions change from true to false. 61 | * @since 4.1.2 62 | */ 63 | public virtual void Deactivate(){ 64 | if (IsActive) { 65 | _isActive = false; 66 | OnDeactivate.Invoke(); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/HandFactory.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using Leap; 4 | 5 | namespace Leap.Unity { 6 | public abstract class HandFactory : MonoBehaviour { 7 | 8 | /** Creates a hand representation object that can receive updates from LeapHandController 9 | * @param hand The hand for which a representation is to be generated. 10 | * @returns hand representation for the given hand 11 | */ 12 | public abstract HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/HandProxy.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using Leap; 5 | 6 | namespace Leap.Unity { 7 | /** 8 | * HandProxy is a concrete example of HandRepresentation 9 | * @param parent The HandPool which creates HandRepresentations 10 | * @param handModel the IHandModel to be paired with Leap Hand data. 11 | * @param hand The Leap Hand data to paired with an IHandModel 12 | */ 13 | public class HandProxy: 14 | HandRepresentation 15 | { 16 | HandPool parent; 17 | public List handModels; 18 | 19 | public HandProxy(HandPool parent, Hand hand, Chirality repChirality, ModelType repType) : 20 | base(hand.Id, hand, repChirality, repType) 21 | { 22 | this.parent = parent; 23 | this.RepChirality = repChirality; 24 | this.RepType = repType; 25 | this.MostRecentHand = hand; 26 | } 27 | 28 | /** To be called if the HandRepresentation no longer has a Leap Hand. */ 29 | public override void Finish() { 30 | if (handModels != null) { 31 | for (int i = 0; i < handModels.Count; i++) { 32 | handModels[i].FinishHand(); 33 | parent.ReturnToPool(handModels[i]); 34 | handModels[i] = null; 35 | } 36 | } 37 | parent.RemoveHandRepresentation(this); 38 | } 39 | 40 | public override void AddModel(IHandModel model) { 41 | if (handModels == null) { 42 | handModels = new List(); 43 | } 44 | handModels.Add(model); 45 | if (model.GetLeapHand() == null) { 46 | model.SetLeapHand(MostRecentHand); 47 | model.InitHand(); 48 | model.BeginHand(); 49 | model.UpdateHand(); 50 | } 51 | else { 52 | model.SetLeapHand(MostRecentHand); 53 | model.BeginHand(); 54 | 55 | } 56 | } 57 | 58 | public override void RemoveModel(IHandModel model) { 59 | if (handModels != null) { 60 | model.FinishHand(); 61 | handModels.Remove(model); 62 | } 63 | } 64 | 65 | /** Calls Updates in IHandModels that are part of this HandRepresentation */ 66 | public override void UpdateRepresentation(Hand hand) 67 | { 68 | base.UpdateRepresentation(hand); 69 | if (handModels != null) { 70 | for (int i = 0; i < handModels.Count; i++) { 71 | handModels[i].SetLeapHand(hand); 72 | handModels[i].UpdateHand(); 73 | } 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/HandRepresentation.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using Leap; 7 | 8 | namespace Leap.Unity { 9 | public abstract class HandRepresentation 10 | { 11 | public int HandID { get; private set; } 12 | public int LastUpdatedTime { get; set; } 13 | public bool IsMarked { get; set; } 14 | public Chirality RepChirality { get; protected set;} 15 | public ModelType RepType { get; protected set;} 16 | public Hand MostRecentHand { get; protected set; } 17 | 18 | public HandRepresentation(int handID, Hand hand, Chirality chirality, ModelType modelType) { 19 | HandID = handID; 20 | this.MostRecentHand = hand; 21 | this.RepChirality = chirality; 22 | this.RepType = modelType; 23 | 24 | } 25 | 26 | /** 27 | * Notifies the representation that a hand information update is available 28 | * @param hand The current Leap.Hand. 29 | * @param modelType Filters for a type of hand model, for example, physics or graphics hands. 30 | */ 31 | public virtual void UpdateRepresentation(Hand hand) { 32 | MostRecentHand = hand; 33 | } 34 | 35 | /** 36 | * Called when a hand representation is no longer needed 37 | */ 38 | public abstract void Finish(); 39 | public abstract void AddModel(IHandModel model); 40 | public abstract void RemoveModel(IHandModel model); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/HandDrop.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity { 5 | /** Simple implementation HandTransitionBehavior to lerp hand models back to their starting position and orientation with tracking ends*/ 6 | public class HandDrop : HandTransitionBehavior { 7 | private Vector3 startingPalmPosition; 8 | private Quaternion startingOrientation; 9 | private Transform palm; 10 | 11 | // Use this for initialization 12 | protected override void Awake() { 13 | base.Awake(); 14 | palm = GetComponent().palm; 15 | startingPalmPosition = palm.localPosition; 16 | startingOrientation = palm.localRotation; 17 | } 18 | 19 | protected override void HandFinish() { 20 | StartCoroutine(LerpToStart()); 21 | } 22 | protected override void HandReset() { 23 | StopAllCoroutines(); 24 | } 25 | 26 | private IEnumerator LerpToStart() { 27 | Vector3 droppedPosition = palm.localPosition; 28 | Quaternion droppedOrientation = palm.localRotation; 29 | float duration = 1.0f; 30 | float startTime = Time.time; 31 | float endTime = startTime + duration; 32 | 33 | while (Time.time <= endTime) { 34 | float t = (Time.time - startTime) / duration; 35 | palm.localPosition = Vector3.Lerp(droppedPosition, startingPalmPosition, t); 36 | palm.localRotation = Quaternion.Lerp(droppedOrientation, startingOrientation, t); 37 | yield return null; 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/HandEnableDisable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using Leap; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace Leap.Unity{ 7 | 8 | [Guid("8bcd03e0-0992-e084-c8be-61565d44b8bd")] 9 | public class HandEnableDisable : HandTransitionBehavior { 10 | protected override void Awake() { 11 | base.Awake(); 12 | gameObject.SetActive(false); 13 | } 14 | 15 | protected override void HandReset() { 16 | gameObject.SetActive(true); 17 | } 18 | 19 | protected override void HandFinish () { 20 | gameObject.SetActive(false); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/HandFader.cs: -------------------------------------------------------------------------------- 1 | using Leap; 2 | using UnityEngine; 3 | using System.Collections; 4 | 5 | namespace Leap.Unity{ 6 | public class HandFader : MonoBehaviour { 7 | public float confidenceSmoothing = 10.0f; 8 | public AnimationCurve confidenceCurve; 9 | 10 | protected HandModel _handModel; 11 | protected float _smoothedConfidence = 0.0f; 12 | protected Renderer _renderer; 13 | 14 | protected MaterialPropertyBlock _fadePropertyBlock; 15 | 16 | private const float EPISLON = 0.005f; 17 | 18 | protected virtual float GetUnsmoothedConfidence() { 19 | return _handModel.GetLeapHand().Confidence; 20 | } 21 | 22 | protected virtual void Awake() { 23 | _handModel = GetComponent(); 24 | _renderer = GetComponentInChildren(); 25 | 26 | _fadePropertyBlock = new MaterialPropertyBlock(); 27 | _renderer.GetPropertyBlock(_fadePropertyBlock); 28 | _fadePropertyBlock.SetFloat("_Fade", 0); 29 | _renderer.SetPropertyBlock(_fadePropertyBlock); 30 | } 31 | 32 | protected virtual void Update() { 33 | float unsmoothedConfidence = GetUnsmoothedConfidence(); 34 | _smoothedConfidence += (unsmoothedConfidence - _smoothedConfidence) / confidenceSmoothing; 35 | float fade = confidenceCurve.Evaluate(_smoothedConfidence); 36 | _renderer.enabled = (fade > EPISLON); 37 | 38 | _renderer.GetPropertyBlock(_fadePropertyBlock); 39 | _fadePropertyBlock.SetFloat("_Fade", confidenceCurve.Evaluate(_smoothedConfidence)); 40 | _renderer.SetPropertyBlock(_fadePropertyBlock); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/HandTransitionBehavior.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity { 5 | /**A Component to be attached to an IHandModel to handle starting and ending of tracking */ 6 | public abstract class HandTransitionBehavior : MonoBehaviour { 7 | 8 | protected abstract void HandReset(); 9 | protected abstract void HandFinish(); 10 | protected IHandModel iHandModel; 11 | protected virtual void Awake(){ 12 | iHandModel = GetComponent(); 13 | if (iHandModel == null) { 14 | Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject"); 15 | return; 16 | } 17 | iHandModel.OnBegin += HandReset; 18 | iHandModel.OnFinish += HandFinish; 19 | } 20 | protected virtual void OnDestroy() { 21 | IHandModel iHandModel = GetComponent(); 22 | if (iHandModel == null) { 23 | Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject"); 24 | return; 25 | } 26 | iHandModel.OnBegin -= HandReset; 27 | iHandModel.OnFinish -= HandFinish; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/IHandModel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | /** IHandModel defines abstract methods as a template for building Leap hand models*/ 8 | namespace Leap.Unity { 9 | public enum Chirality { Left, Right, Either }; 10 | public enum ModelType { Graphics, Physics }; 11 | 12 | [ExecuteInEditMode] 13 | public abstract class IHandModel : MonoBehaviour { 14 | public event Action OnBegin; 15 | public event Action OnFinish; 16 | private bool isTracked = false; 17 | public bool IsTracked { 18 | get { return isTracked; } 19 | } 20 | 21 | public abstract Chirality Handedness { get; } 22 | public abstract ModelType HandModelType { get; } 23 | public virtual void InitHand() { 24 | } 25 | 26 | public virtual void BeginHand() { 27 | if (OnBegin != null) { 28 | OnBegin(); 29 | } 30 | isTracked = true; 31 | } 32 | public abstract void UpdateHand(); 33 | public virtual void FinishHand() { 34 | if (OnFinish != null) { 35 | OnFinish(); 36 | } 37 | isTracked = false; 38 | } 39 | public abstract Hand GetLeapHand(); 40 | public abstract void SetLeapHand(Hand hand); 41 | 42 | /// 43 | /// Returns whether or not this hand model supports editor persistence. This is false by default and must be 44 | /// opt-in by a developer making their own hand model script if they want editor persistence. 45 | /// 46 | public virtual bool SupportsEditorPersistence() { 47 | return false; 48 | } 49 | 50 | #if UNITY_EDITOR 51 | void Update() { 52 | if (!EditorApplication.isPlaying && SupportsEditorPersistence()) { 53 | Hand hand = TestHandFactory.MakeTestHand(0, 0, Handedness == Chirality.Left).TransformedCopy(UnityMatrixExtension.GetLeapMatrix(transform)); 54 | if (GetLeapHand() == null) { 55 | SetLeapHand(hand); 56 | InitHand(); 57 | BeginHand(); 58 | UpdateHand(); 59 | } else { 60 | SetLeapHand(hand); 61 | UpdateHand(); 62 | } 63 | } 64 | } 65 | #endif 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/MinimalHand.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | using Leap; 5 | 6 | namespace Leap.Unity{ 7 | public class MinimalHand : IHandModel { 8 | public override bool SupportsEditorPersistence() { 9 | return true; 10 | } 11 | [SerializeField] 12 | private Mesh _palmMesh; 13 | 14 | [SerializeField] 15 | private float _palmScale = 0.02f; 16 | 17 | [SerializeField] 18 | private Material _palmMat; 19 | 20 | [SerializeField] 21 | private Mesh _jointMesh; 22 | 23 | [SerializeField] 24 | private float _jointScale = 0.01f; 25 | 26 | [SerializeField] 27 | private Material _jointMat; 28 | 29 | private Hand _hand; 30 | private Transform _palm; 31 | private Transform[] _joints; 32 | 33 | public override Chirality Handedness { 34 | get { 35 | return Chirality.Either; 36 | } 37 | } 38 | 39 | public override ModelType HandModelType { 40 | get { 41 | return ModelType.Graphics; 42 | } 43 | } 44 | 45 | public override void SetLeapHand(Hand hand) { 46 | _hand = hand; 47 | } 48 | 49 | public override Hand GetLeapHand() { 50 | return _hand; 51 | } 52 | 53 | public override void InitHand() { 54 | _joints = new Transform[5 * 4]; 55 | for (int i = 0; i < 20; i++) { 56 | _joints[i] = createRenderer("Joint", _jointMesh, _jointScale, _jointMat); 57 | } 58 | 59 | _palm = createRenderer("Palm", _palmMesh, _palmScale, _palmMat); 60 | } 61 | 62 | public override void UpdateHand() { 63 | var list = _hand.Fingers; 64 | int index = 0; 65 | for (int i = 0; i < 5; i++) { 66 | Finger finger = list[i]; 67 | for (int j = 0; j < 4; j++) { 68 | _joints[index++].position = finger.Bone((Bone.BoneType)j).NextJoint.ToVector3(); 69 | } 70 | } 71 | 72 | _palm.position = _hand.PalmPosition.ToVector3(); 73 | } 74 | 75 | private Transform createRenderer(string name, Mesh mesh, float scale, Material mat) { 76 | GameObject obj = new GameObject(name); 77 | obj.AddComponent().mesh = mesh; 78 | obj.AddComponent().sharedMaterial = mat; 79 | obj.transform.parent = transform; 80 | obj.transform.localScale = Vector3.one * scale; 81 | return obj.transform; 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/PolyHand.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2014. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity { 12 | /** 13 | * A deforming, very low poly count hand. 14 | * 15 | * All the graphics for this hand are drawn by the fingers. There is no representation 16 | * for the palm or the arm. 17 | */ 18 | public class PolyHand : HandModel { 19 | public override ModelType HandModelType { 20 | get { 21 | return ModelType.Graphics; 22 | } 23 | } 24 | public override bool SupportsEditorPersistence() { 25 | return true; 26 | } 27 | /** Initializes the hand and calls the finger initializers. */ 28 | public override void InitHand() { 29 | SetPalmOrientation(); 30 | 31 | for (int f = 0; f < fingers.Length; ++f) { 32 | if (fingers[f] != null) { 33 | fingers[f].fingerType = (Finger.FingerType)f; 34 | fingers[f].InitFinger(); 35 | } 36 | } 37 | } 38 | 39 | /** Updates the hand and calls the finger update functions. */ 40 | public override void UpdateHand() { 41 | SetPalmOrientation(); 42 | 43 | for (int f = 0; f < fingers.Length; ++f) { 44 | if (fingers[f] != null) { 45 | fingers[f].UpdateFinger(); 46 | } 47 | } 48 | } 49 | 50 | /** Sets the palm transform. */ 51 | protected void SetPalmOrientation() { 52 | if (palm != null) { 53 | palm.position = GetPalmPosition(); 54 | palm.rotation = GetPalmRotation(); 55 | } 56 | } 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/RiggedFinger.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2014. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | using System.Runtime.InteropServices; 11 | 12 | namespace Leap.Unity { 13 | /** 14 | * Manages the orientation of the bones in a model rigged for skeletal animation. 15 | * 16 | * The class expects that the graphics model bones corresponding to bones in the Leap Motion 17 | * hand model are in the same order in the bones array. 18 | */ 19 | [Guid("a77b65c1-ae87-b436-881a-a63bc80f4894")] 20 | public class RiggedFinger : FingerModel { 21 | 22 | /** Allows the mesh to be stretched to align with finger joint positions 23 | * Only set to true when mesh is not visible 24 | */ 25 | public bool deformPosition = false; 26 | 27 | public Vector3 modelFingerPointing = Vector3.forward; 28 | public Vector3 modelPalmFacing = -Vector3.up; 29 | 30 | public Quaternion Reorientation() { 31 | return Quaternion.Inverse(Quaternion.LookRotation(modelFingerPointing, -modelPalmFacing)); 32 | } 33 | 34 | private RiggedHand riggedHand; 35 | 36 | /** Updates the bone rotations. */ 37 | public override void UpdateFinger() { 38 | for (int i = 0; i < bones.Length; ++i) { 39 | if (bones[i] != null) { 40 | bones[i].rotation = GetBoneRotation(i) * Reorientation(); 41 | if (deformPosition) { 42 | bones[i].position = GetJointPosition(i); 43 | } 44 | } 45 | } 46 | } 47 | public void SetupRiggedFinger (bool useMetaCarpals) { 48 | findBoneTransforms(useMetaCarpals); 49 | modelFingerPointing = calulateModelFingerPointing(); 50 | } 51 | 52 | private void findBoneTransforms(bool useMetaCarpals) { 53 | if (!useMetaCarpals || fingerType == Finger.FingerType.TYPE_THUMB) { 54 | bones[1] = transform; 55 | bones[2] = transform.GetChild(0).transform; 56 | bones[3] = transform.GetChild(0).transform.GetChild(0).transform; 57 | } 58 | else { 59 | bones[0] = transform; 60 | bones[1] = transform.GetChild(0).transform; 61 | bones[2] = transform.GetChild(0).transform.GetChild(0).transform; 62 | bones[3] = transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform; 63 | 64 | } 65 | } 66 | private Vector3 calulateModelFingerPointing() { 67 | Vector3 distance = transform.InverseTransformPoint(transform.position) - transform.InverseTransformPoint(transform.GetChild(0).transform.position); 68 | Vector3 zeroed = RiggedHand.CalculateZeroedVector(distance); 69 | return zeroed; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/RigidFinger.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity{ 12 | /** A physics finger model for our rigid hand made out of various cube Unity Colliders. */ 13 | public class RigidFinger : SkeletalFinger { 14 | 15 | public float filtering = 0.5f; 16 | 17 | void Start() { 18 | for (int i = 0; i < bones.Length; ++i) { 19 | if (bones[i] != null) { 20 | bones[i].GetComponent().maxAngularVelocity = Mathf.Infinity; 21 | } 22 | } 23 | } 24 | 25 | public override void UpdateFinger() { 26 | for (int i = 0; i < bones.Length; ++i) { 27 | if (bones[i] != null) { 28 | // Set bone dimensions. 29 | CapsuleCollider capsule = bones[i].GetComponent(); 30 | if (capsule != null) { 31 | // Initialization 32 | capsule.direction = 2; 33 | bones[i].localScale = new Vector3(1f/transform.lossyScale.x, 1f/transform.lossyScale.y, 1f/transform.lossyScale.z); 34 | 35 | // Update 36 | capsule.radius = GetBoneWidth(i) / 2f; 37 | capsule.height = GetBoneLength(i) + GetBoneWidth(i); 38 | } 39 | 40 | Rigidbody boneBody = bones[i].GetComponent(); 41 | if (boneBody) { 42 | boneBody.MovePosition(GetBoneCenter(i)); 43 | boneBody.MoveRotation(GetBoneRotation(i)); 44 | } else { 45 | bones[i].position = GetBoneCenter(i); 46 | bones[i].rotation = GetBoneRotation(i); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/RigidHand.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity { 12 | /** A physics model for our rigid hand made out of various Unity Collider. */ 13 | public class RigidHand : SkeletalHand { 14 | public override ModelType HandModelType { 15 | get { 16 | return ModelType.Physics; 17 | } 18 | } 19 | public float filtering = 0.5f; 20 | 21 | public override bool SupportsEditorPersistence() { 22 | return true; 23 | } 24 | 25 | public override void InitHand() { 26 | base.InitHand(); 27 | } 28 | 29 | public override void UpdateHand() { 30 | 31 | for (int f = 0; f < fingers.Length; ++f) { 32 | if (fingers[f] != null) { 33 | fingers[f].UpdateFinger(); 34 | } 35 | } 36 | 37 | if (palm != null) { 38 | Rigidbody palmBody = palm.GetComponent(); 39 | if (palmBody) { 40 | palmBody.MovePosition(GetPalmCenter()); 41 | palmBody.MoveRotation(GetPalmRotation()); 42 | } else { 43 | palm.position = GetPalmCenter(); 44 | palm.rotation = GetPalmRotation(); 45 | } 46 | } 47 | 48 | if (forearm != null) { 49 | // Set arm dimensions. 50 | CapsuleCollider capsule = forearm.GetComponent(); 51 | if (capsule != null) { 52 | // Initialization 53 | capsule.direction = 2; 54 | forearm.localScale = new Vector3(1f / transform.lossyScale.x, 1f / transform.lossyScale.y, 1f / transform.lossyScale.z); 55 | 56 | // Update 57 | capsule.radius = GetArmWidth() / 2f; 58 | capsule.height = GetArmLength() + GetArmWidth(); 59 | } 60 | 61 | Rigidbody forearmBody = forearm.GetComponent(); 62 | if (forearmBody) { 63 | forearmBody.MovePosition(GetArmCenter()); 64 | forearmBody.MoveRotation(GetArmRotation()); 65 | } else { 66 | forearm.position = GetArmCenter(); 67 | forearm.rotation = GetArmRotation(); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/SkeletalFinger.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity{ 12 | /** 13 | * A finger object consisting of discrete, component parts for each bone. 14 | * 15 | * The graphic objects can include both bones and joints, but both are optional. 16 | */ 17 | public class SkeletalFinger : FingerModel { 18 | 19 | /** Initializes the finger bones and joints by setting their positions and rotations. */ 20 | public override void InitFinger() { 21 | SetPositions(); 22 | } 23 | 24 | /** Updates the finger bones and joints by setting their positions and rotations. */ 25 | public override void UpdateFinger() { 26 | Debug.Log("SkeletalFinger.SetPositions()"); 27 | 28 | SetPositions(); 29 | } 30 | 31 | protected void SetPositions() { 32 | for (int i = 0; i < bones.Length; ++i) { 33 | if (bones[i] != null) { 34 | bones[i].transform.position = GetBoneCenter(i); 35 | bones[i].transform.rotation = GetBoneRotation(i); 36 | } 37 | } 38 | 39 | for (int i = 0; i < joints.Length; ++i) { 40 | if (joints[i] != null) { 41 | joints[i].transform.position = GetJointPosition(i + 1); 42 | joints[i].transform.rotation = GetBoneRotation(i + 1); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Hands/SkeletalHand.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity{ 12 | /** 13 | * A hand object consisting of discrete, component parts. 14 | * 15 | * The hand can have game objects for the palm, wrist and forearm, as well as fingers. 16 | */ 17 | public class SkeletalHand : HandModel { 18 | public override ModelType HandModelType { 19 | get { 20 | return ModelType.Graphics; 21 | } 22 | } 23 | protected const float PALM_CENTER_OFFSET = 0.015f; 24 | 25 | void Start() { 26 | // Ignore collisions with self. 27 | Leap.Unity.Utils.IgnoreCollisions(gameObject, gameObject); 28 | 29 | for (int i = 0; i < fingers.Length; ++i) { 30 | if (fingers[i] != null) { 31 | fingers[i].fingerType = (Finger.FingerType)i; 32 | } 33 | } 34 | } 35 | 36 | /** Updates the hand and its component parts by setting their positions and rotations. */ 37 | public override void UpdateHand() { 38 | SetPositions(); 39 | } 40 | 41 | protected Vector3 GetPalmCenter() { 42 | Vector3 offset = PALM_CENTER_OFFSET * Vector3.Scale(GetPalmDirection(), transform.lossyScale); 43 | return GetPalmPosition() - offset; 44 | } 45 | 46 | protected void SetPositions() { 47 | Debug.Log("SkeletalHand.SetPositions()"); 48 | 49 | for (int f = 0; f < fingers.Length; ++f) { 50 | if (fingers[f] != null) { 51 | fingers[f].UpdateFinger(); 52 | } 53 | } 54 | 55 | if (palm != null) { 56 | palm.position = GetPalmCenter(); 57 | palm.rotation = GetPalmRotation(); 58 | } 59 | 60 | if (wristJoint != null) { 61 | wristJoint.position = GetWristPosition(); 62 | wristJoint.rotation = GetPalmRotation(); 63 | } 64 | 65 | if (forearm != null) { 66 | forearm.position = GetArmCenter(); 67 | forearm.rotation = GetArmRotation(); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/LeapDeviceInfo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity{ 5 | public enum LeapDeviceType { 6 | Invalid, 7 | Peripheral, 8 | Dragonfly 9 | } 10 | 11 | /// 12 | /// Leap device info struct. 13 | /// 14 | /// 15 | /// Default values are for Leap peripheral. 16 | /// 17 | public struct LeapDeviceInfo { 18 | public LeapDeviceType type; 19 | public bool isEmbedded; 20 | // TODO: Is head mounted 21 | public float baseline; //(meters) Distance between focal points of cameras 22 | public float focalPlaneOffset; //(meters) Distance from mount center to focal plane of cameras 23 | public float horizontalViewAngle; //(degrees) Field of view angle in parallel to baseline axis 24 | public float verticalViewAngle; //(degrees) Field of view angle perpendicular to baseline axis 25 | public float trackingRange; //(degrees) Maximum radius for reliable tracking 26 | public string serialID; //Device alphanumeric unique hardware ID 27 | 28 | public LeapDeviceInfo(LeapDeviceType initialization = LeapDeviceType.Invalid) { 29 | type = initialization; 30 | switch (type) { 31 | case LeapDeviceType.Peripheral: 32 | isEmbedded = false; 33 | baseline = 0.04f; 34 | focalPlaneOffset = 0.07f; 35 | horizontalViewAngle = 2.303835f * Mathf.Rad2Deg; 36 | verticalViewAngle = 2.007129f * Mathf.Rad2Deg; 37 | trackingRange = 470f / 1000f; 38 | serialID = ""; 39 | break; 40 | case LeapDeviceType.Dragonfly: 41 | isEmbedded = false; 42 | baseline = 0.064f; 43 | focalPlaneOffset = 0.08f; 44 | horizontalViewAngle = 2.303835f * Mathf.Rad2Deg; 45 | verticalViewAngle = 2.007129f * Mathf.Rad2Deg; 46 | trackingRange = 470f / 1000f; 47 | serialID = ""; 48 | break; 49 | default: 50 | isEmbedded = false; 51 | baseline = 0f; 52 | focalPlaneOffset = 0f; 53 | horizontalViewAngle = 0f; 54 | verticalViewAngle = 0f; 55 | trackingRange = 0f; 56 | serialID = ""; 57 | break; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/LeapProvider.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity { 5 | /**LeapProvider's supply images and Leap Hands */ 6 | public abstract class LeapProvider : MonoBehaviour { 7 | public abstract Frame CurrentFrame { get; } 8 | public abstract Frame CurrentFixedFrame { get; } 9 | public abstract Image CurrentImage { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/DisconnectionNotice.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Leap; 10 | 11 | namespace Leap.Unity{ 12 | /** 13 | * Tracks the connection state of the Leap Motion hardware. If the device is unplugged 14 | * or otherwise not detected, the script fades in a GUITexture object which should communicate 15 | * the problem to the user. 16 | */ 17 | public class DisconnectionNotice : MonoBehaviour { 18 | 19 | /** The speed to fade the object alpha from 0 to 1. */ 20 | public float fadeInTime = 1.0f; 21 | /** The speed to fade the object alpha from 1 to 0. */ 22 | public float fadeOutTime = 1.0f; 23 | /** The easing curve. */ 24 | public AnimationCurve fade; 25 | /** A delay before beginning the fade-in effect. */ 26 | public int waitFrames = 10; 27 | /** An alternative image to use when the hardware is embedded in a keyboard or laptop. */ 28 | public Sprite embeddedReplacementImage; 29 | /** The fully on texture tint color. */ 30 | public Color onColor = Color.white; 31 | 32 | private Controller leap_controller_; 33 | private float fadedIn = 0.0f; 34 | private int frames_disconnected_ = 0; 35 | 36 | void Start() { 37 | leap_controller_ = new Controller(); 38 | SetAlpha(0.0f); 39 | } 40 | 41 | void SetAlpha(float alpha) { 42 | GetComponent().color = Color.Lerp(Color.clear, onColor, alpha); 43 | } 44 | 45 | /** The connection state of the controller. */ 46 | bool IsConnected() { 47 | return leap_controller_.IsConnected; 48 | } 49 | 50 | /** Whether the controller is embedded in a keyboard or laptop.*/ 51 | bool IsEmbedded() { 52 | DeviceList devices = leap_controller_.Devices; 53 | if (devices.Count == 0) 54 | return false; 55 | return devices[0].IsEmbedded; 56 | } 57 | 58 | void Update() { 59 | if (embeddedReplacementImage != null && IsEmbedded()) { 60 | GetComponent().sprite = embeddedReplacementImage; 61 | } 62 | 63 | if (IsConnected()) 64 | frames_disconnected_ = 0; 65 | else 66 | frames_disconnected_++; 67 | 68 | if (frames_disconnected_ < waitFrames) 69 | fadedIn -= Time.deltaTime / fadeOutTime; 70 | else 71 | fadedIn += Time.deltaTime / fadeInTime; 72 | fadedIn = Mathf.Clamp(fadedIn, 0.0f, 1.0f); 73 | 74 | SetAlpha(fade.Evaluate(fadedIn)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/EnableDepthBuffer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity{ 5 | [ExecuteInEditMode] 6 | public class EnableDepthBuffer : MonoBehaviour { 7 | public const string DEPTH_TEXTURE_VARIANT_NAME = "USE_DEPTH_TEXTURE"; 8 | 9 | [SerializeField] 10 | private DepthTextureMode _depthTextureMode = DepthTextureMode.Depth; 11 | 12 | void Awake() { 13 | GetComponent().depthTextureMode = _depthTextureMode; 14 | 15 | if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth) && 16 | _depthTextureMode != DepthTextureMode.None) { 17 | Shader.EnableKeyword(DEPTH_TEXTURE_VARIANT_NAME); 18 | } else { 19 | Shader.DisableKeyword(DEPTH_TEXTURE_VARIANT_NAME); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/FitHeightToScreen.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | 10 | namespace Leap.Unity{ 11 | public class FitHeightToScreen : MonoBehaviour { 12 | 13 | void Awake() { 14 | float width_height_ratio = GetComponent().texture.width / GetComponent().texture.height; 15 | float width = width_height_ratio * Screen.height; 16 | float x_offset = (Screen.width - width) / 2.0f; 17 | GetComponent().pixelInset = new Rect(x_offset, 0.0f, width, Screen.height); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/FrameRateControls.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Leap.Unity{ 5 | /// 6 | /// Provides control of target frame rate. 7 | /// 8 | /// 9 | /// This utility is useful for verifying frame-rate independence of behaviors. 10 | /// 11 | public class FrameRateControls : MonoBehaviour { 12 | public int targetRenderRate = 60; // must be > 0 13 | public int targetRenderRateStep = 1; 14 | public int fixedPhysicsRate = 50; // must be > 0 15 | public int fixedPhysicsRateStep = 1; 16 | public KeyCode unlockRender = KeyCode.RightShift; 17 | public KeyCode unlockPhysics = KeyCode.LeftShift; 18 | public KeyCode decrease = KeyCode.DownArrow; 19 | public KeyCode increase = KeyCode.UpArrow; 20 | public KeyCode resetRate = KeyCode.Backspace; 21 | 22 | // Use this for initialization 23 | void Awake () { 24 | if (QualitySettings.vSyncCount != 0) { 25 | Debug.LogWarning ("vSync will override target frame rate. vSyncCount = " + QualitySettings.vSyncCount); 26 | } 27 | 28 | Application.targetFrameRate = targetRenderRate; 29 | Time.fixedDeltaTime = 1f/((float)fixedPhysicsRate); 30 | } 31 | 32 | // Update is called once per frame 33 | void Update () { 34 | if (Input.GetKey (unlockRender)) { 35 | if (Input.GetKeyDown (decrease)) { 36 | if (targetRenderRate > targetRenderRateStep) { 37 | targetRenderRate -= targetRenderRateStep; 38 | Application.targetFrameRate = targetRenderRate; 39 | } 40 | } 41 | if (Input.GetKeyDown (increase)) { 42 | targetRenderRate += targetRenderRateStep; 43 | Application.targetFrameRate = targetRenderRate; 44 | } 45 | if (Input.GetKeyDown (resetRate)) { 46 | ResetRender(); 47 | } 48 | } 49 | if (Input.GetKey (unlockPhysics)) { 50 | if (Input.GetKeyDown (decrease)) { 51 | if (fixedPhysicsRate > fixedPhysicsRateStep) { 52 | fixedPhysicsRate -= fixedPhysicsRateStep; 53 | Time.fixedDeltaTime = 1f/((float)fixedPhysicsRate); 54 | } 55 | } 56 | if (Input.GetKeyDown (increase)) { 57 | fixedPhysicsRate += fixedPhysicsRateStep; 58 | Time.fixedDeltaTime = 1f/((float)fixedPhysicsRate); 59 | } 60 | if (Input.GetKeyDown (resetRate)) { 61 | ResetPhysics(); 62 | } 63 | } 64 | } 65 | 66 | public void ResetRender() { 67 | targetRenderRate = 60; 68 | Application.targetFrameRate = -1; 69 | } 70 | 71 | public void ResetPhysics() { 72 | fixedPhysicsRate = 50; 73 | Time.fixedDeltaTime = 0.02f; 74 | } 75 | 76 | public void ResetAll() { 77 | ResetRender (); 78 | ResetPhysics (); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/KeyEnableBehaviors.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Leap.Unity{ 6 | public class KeyEnableBehaviors : MonoBehaviour { 7 | public List targets; 8 | [Header("Controls")] 9 | public KeyCode unlockHold = KeyCode.None; 10 | public KeyCode toggle = KeyCode.Space; 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | if (unlockHold != KeyCode.None && 15 | !Input.GetKey (unlockHold)) { 16 | return; 17 | } 18 | if (Input.GetKeyDown (toggle)) { 19 | foreach (MonoBehaviour target in targets) { 20 | target.enabled = !target.enabled; 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/KeyEnableGameObjects.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Leap.Unity{ 6 | public class KeyEnableGameObjects : MonoBehaviour { 7 | public List targets; 8 | [Header("Controls")] 9 | public KeyCode unlockHold = KeyCode.RightShift; 10 | public KeyCode toggle = KeyCode.T; 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | if (unlockHold != KeyCode.None && 15 | !Input.GetKey (unlockHold)) { 16 | return; 17 | } 18 | if (Input.GetKeyDown (toggle)) { 19 | foreach (GameObject target in targets) { 20 | target.SetActive(!target.activeSelf); 21 | } 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/SceneSettings.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | 4 | namespace Leap.Unity { 5 | 6 | public class SceneSettings : MonoBehaviour { 7 | 8 | public class ToggleValue { 9 | public bool Override; 10 | public T Value; 11 | } 12 | 13 | [Serializable] 14 | public class ToggleFloat : ToggleValue { } 15 | 16 | [Serializable] 17 | public class ToggleVector3 : ToggleValue { } 18 | 19 | [SerializeField] 20 | private ToggleFloat _shadowDistance = new ToggleFloat(); 21 | 22 | [SerializeField] 23 | private ToggleVector3 _gravity = new ToggleVector3(); 24 | 25 | void Reset() { 26 | _shadowDistance.Value = QualitySettings.shadowDistance; 27 | _gravity.Value = Physics.gravity; 28 | } 29 | 30 | void Awake() { 31 | if (_shadowDistance.Override) { 32 | QualitySettings.shadowDistance = _shadowDistance.Value; 33 | } 34 | 35 | if (_gravity.Override) { 36 | Physics.gravity = _gravity.Value; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/SmoothedFloat.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Leap.Unity{ 4 | /// 5 | /// Time-step independent exponential smoothing. 6 | /// 7 | /// 8 | /// When moving at a constant speed: speed * delay = Value - SmoothedFloat.value. 9 | /// 10 | [System.Serializable] 11 | public class SmoothedFloat { 12 | public float value = 0f; // Filtered value 13 | public float delay = 0f; // Mean delay 14 | public bool reset = true; // Reset on Next Update 15 | 16 | public float average_dt = 0f; 17 | 18 | public void SetBlend(float blend, float deltaTime = 1f) 19 | { 20 | delay = deltaTime * blend / (1f - blend); 21 | } 22 | 23 | public float Update(float input, float deltaTime = 1f) 24 | { 25 | if (deltaTime > 0f && 26 | !reset) { 27 | float alpha = delay / deltaTime; 28 | float blend = alpha / (1f + alpha); 29 | // NOTE: If delay -> 0 then blend -> 0, 30 | // reducing the filter to this.value = value. 31 | // NOTE: If deltaTime -> 0 blend -> 1, 32 | // so the change in the filtered value will be suppressed 33 | var newValue = Mathf.Lerp(this.value, input, 1f - blend); 34 | 35 | var new_dt = Mathf.Abs(newValue - value); 36 | if (average_dt * 10 < newValue - value) 37 | Debug.Log("Average dt was excessive!"); 38 | 39 | average_dt = Mathf.Lerp(average_dt, new_dt, 1f - blend); 40 | value = newValue; 41 | } else { 42 | value = input; 43 | reset = false; 44 | } 45 | return value; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/SmoothedQuaternion.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Leap.Unity{ 4 | /// 5 | /// Time-step independent exponential smoothing. 6 | /// 7 | /// 8 | /// When moving at a constant speed: speed * delay = Value - ExponentialSmoothing.value. 9 | /// 10 | [System.Serializable] 11 | public class SmoothedQuaternion { 12 | public Quaternion value = Quaternion.identity; // Filtered value 13 | public float delay = 0f; // Mean delay 14 | public bool reset = true; // Reset on Next Update 15 | 16 | public void SetBlend(float blend, float deltaTime = 1f) 17 | { 18 | delay = deltaTime * blend / (1f - blend); 19 | } 20 | 21 | public Quaternion Update(Quaternion input, float deltaTime = 1f) 22 | { 23 | if (deltaTime > 0f && 24 | !reset) { 25 | float alpha = delay / deltaTime; 26 | float blend = alpha / (1f + alpha); 27 | // NOTE: If delay -> 0 then blend -> 0, 28 | // reducing the filter to this.value = value. 29 | // NOTE: If deltaTime -> 0 blend -> 1, 30 | // so the change in the filtered value will be suppressed 31 | value = Quaternion.Slerp(value, input, 1f - blend); 32 | } else { 33 | value = input; 34 | reset = false; 35 | } 36 | return value; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/SmoothedVector3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Leap.Unity{ 4 | /// 5 | /// Time-step independent exponential smoothing. 6 | /// 7 | /// 8 | /// When moving at a constant speed: speed * delay = Value - SmoothedVector3.value. 9 | /// 10 | [System.Serializable] 11 | public class SmoothedVector3 { 12 | public Vector3 value = Vector3.zero; // Filtered value 13 | public float delay = 0f; // Mean delay 14 | public bool reset = true; // Reset on Next Update 15 | 16 | public void SetBlend(float blend, float deltaTime = 1f) 17 | { 18 | delay = deltaTime * blend / (1f - blend); 19 | } 20 | 21 | public Vector3 Update(Vector3 input, float deltaTime = 1f) 22 | { 23 | if (deltaTime > 0f && 24 | !reset) { 25 | float alpha = delay / deltaTime; 26 | float blend = alpha / (1f + alpha); 27 | // NOTE: If delay -> 0 then blend -> 0, 28 | // reducing the filter to this.value = value. 29 | // NOTE: If deltaTime -> 0 blend -> 1, 30 | // so the change in the filtered value will be suppressed 31 | value = Vector3.Lerp(this.value, input, 1f - blend); 32 | } else { 33 | value = input; 34 | reset = false; 35 | } 36 | return value; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/Utils/StretchToScreen.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************\ 2 | * Copyright (C) Leap Motion, Inc. 2011-2016. * 3 | * Leap Motion proprietary. Licensed under Apache 2.0 * 4 | * Available at http://www.apache.org/licenses/LICENSE-2.0.html * 5 | \******************************************************************************/ 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | 10 | namespace Leap.Unity{ 11 | public class StretchToScreen : MonoBehaviour { 12 | 13 | void Awake() { 14 | GetComponent().pixelInset = new Rect(0.0f, 0.0f, Screen.width, Screen.height); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/VR/EyeType.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | using System; 6 | 7 | namespace Leap.Unity { 8 | [System.Serializable] 9 | public class EyeType { 10 | private const string TARGET_EYE_PROPERTY_NAME = "m_TargetEye"; 11 | private const int TARGET_EYE_LEFT_INDEX = 1; 12 | private const int TARGET_EYE_RIGHT_INDEX = 2; 13 | private const int TARGET_EYE_CENTER_INDEX = 3; 14 | 15 | public enum OrderType { 16 | LEFT = TARGET_EYE_LEFT_INDEX, 17 | RIGHT = TARGET_EYE_RIGHT_INDEX, 18 | CENTER = TARGET_EYE_CENTER_INDEX 19 | } 20 | 21 | [SerializeField] 22 | private OrderType _orderType = OrderType.LEFT; 23 | 24 | private bool _isOnFirst = false; 25 | private bool _hasBegun = false; 26 | 27 | public OrderType Type { 28 | get { 29 | return _orderType; 30 | } 31 | } 32 | 33 | public bool IsLeftEye { 34 | get { 35 | if (!_hasBegun) { 36 | throw new Exception("Cannot call IsLeftEye or IsRightEye before BeginCamera has been called!"); 37 | } 38 | 39 | switch (_orderType) { 40 | case OrderType.LEFT: return true; 41 | case OrderType.RIGHT: return false; 42 | case OrderType.CENTER: return _isOnFirst; 43 | default: throw new Exception("Unexpected order type " + _orderType); 44 | } 45 | } 46 | } 47 | 48 | public bool IsRightEye { 49 | get { 50 | return !IsLeftEye; 51 | } 52 | } 53 | 54 | public EyeType(OrderType type) { 55 | _orderType = type; 56 | } 57 | 58 | #if UNITY_EDITOR 59 | public void UpdateOrderGivenComponent(Component component) { 60 | if (Application.isPlaying) { 61 | return; 62 | } 63 | 64 | //Allow the user to specify themselves if VR is disabled 65 | if (!VRSettings.enabled || !PlayerSettings.virtualRealitySupported) { 66 | return; 67 | } 68 | 69 | Camera camera = component.GetComponent(); 70 | if (camera == null) { 71 | camera = component.gameObject.AddComponent(); 72 | } 73 | 74 | SerializedObject obj = new SerializedObject(camera); 75 | SerializedProperty targetEyeProp = obj.FindProperty(TARGET_EYE_PROPERTY_NAME); 76 | OrderType newOrder = (OrderType)targetEyeProp.intValue; 77 | if (_orderType != newOrder) { 78 | _orderType = newOrder; 79 | EditorUtility.SetDirty(component); 80 | } 81 | } 82 | #endif 83 | 84 | public void BeginCamera() { 85 | if (!_hasBegun) { 86 | _isOnFirst = true; 87 | _hasBegun = true; 88 | } else { 89 | _isOnFirst = !_isOnFirst; 90 | } 91 | } 92 | 93 | public void Reset() { 94 | _hasBegun = false; 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /VRGIN/LeapMotion/VR/TemporalWarpingStatus.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using Leap; 4 | using System.Collections; 5 | 6 | namespace Leap.Unity{ 7 | public class TemporalWarpingStatus : MonoBehaviour { 8 | public LeapVRTemporalWarping cameraAlignment; 9 | 10 | protected Text textField; 11 | 12 | protected SmoothedFloat _imageLatency = new SmoothedFloat(); 13 | protected SmoothedFloat _frameDelta = new SmoothedFloat(); 14 | [SerializeField] 15 | LeapProvider Provider; 16 | 17 | void Start () { 18 | textField = GetComponent (); 19 | if (textField == null) { 20 | gameObject.SetActive(false); 21 | } 22 | 23 | _imageLatency.delay = 0.1f; 24 | _frameDelta.delay = 0.1f; 25 | } 26 | 27 | // Update is called once per frame 28 | void Update () { 29 | //if (cameraAlignment == null) { 30 | // Debug.Log("TemporalWarpingStatus requires LeapCameraAlignment reference -> status will be disabled"); 31 | // gameObject.SetActive(false); 32 | // return; 33 | //} 34 | 35 | //if (!cameraAlignment.isActiveAndEnabled) { 36 | // return; 37 | //} 38 | 39 | //ImageList list = Provider.CurrentFrame.Images; 40 | // Leap.Image image = list.IRLeft; 41 | // float latency = Provider.GetLeapController().Now() - image.Timestamp; 42 | // _imageLatency.Update(latency, Time.deltaTime); 43 | 44 | 45 | //_frameDelta.Update(Time.deltaTime, Time.deltaTime); 46 | 47 | //string statusText = "IMAGE LATENCY: " + (_imageLatency.value / 1000f).ToString("#00.0") + " ms\n"; 48 | //statusText += "FRAME DELTA: " + (_frameDelta.value * 1000).ToString ("#00.0") + " ms\n"; 49 | //statusText += "REWIND ADJUST: " + (cameraAlignment.RewindAdjust).ToString ("#00.0") + " ms\n"; 50 | 51 | //textField.text = statusText; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /VRGIN/LeapMotion/VR/VRHeightOffset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.VR; 3 | using System; 4 | using System.Linq; 5 | 6 | public class VRHeightOffset : MonoBehaviour { 7 | 8 | [Serializable] 9 | public class DeviceHeightPair { 10 | public string DeviceName; 11 | public float HeightOffset; 12 | 13 | public DeviceHeightPair(string deviceName, float heightOffset) { 14 | DeviceName = deviceName; 15 | HeightOffset = heightOffset; 16 | } 17 | } 18 | 19 | public DeviceHeightPair[] _deviceOffsets; 20 | 21 | void Reset() { 22 | _deviceOffsets = new DeviceHeightPair[1]; 23 | _deviceOffsets[0] = new DeviceHeightPair("oculus", 1f); 24 | } 25 | 26 | void Start() { 27 | if (VRDevice.isPresent && VRSettings.enabled && _deviceOffsets != null) { 28 | #if UNITY_5_4_OR_NEWER 29 | string deviceName = VRSettings.loadedDeviceName; 30 | #else 31 | string deviceName = VRDevice.family; 32 | #endif 33 | var deviceHeightPair = _deviceOffsets.FirstOrDefault(d => deviceName.ToLower().Contains(d.DeviceName.ToLower())); 34 | if (deviceHeightPair != null) { 35 | transform.Translate(Vector3.up * deviceHeightPair.HeightOffset); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Managed/System.Configuration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Managed/System.Configuration.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Managed/System.Drawing.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Managed/System.Drawing.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Managed/System.Xml.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Managed/System.Xml.Linq.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Managed/System.Xml.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Managed/System.Xml.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Managed/System.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Managed/System.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86/LeapC.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86/LeapC.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86/OculusSpatializerPlugin.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86/OculusSpatializerPlugin.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86/openvr_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86/openvr_api.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86_64/LeapC.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86_64/LeapC.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86_64/OculusSpatializerPlugin.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86_64/OculusSpatializerPlugin.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Data/Plugins/x86_64/openvr_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Data/Plugins/x86_64/openvr_api.dll -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/Images/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/Images/cursor.png -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/Images/icon_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/Images/icon_play.png -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/Images/icon_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/Images/icon_settings.png -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/Images/icon_warp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/Images/icon_warp.png -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/VR/SpeechServer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/VR/SpeechServer.exe -------------------------------------------------------------------------------- /VRGIN/Libs/Plugins/VR/SpeechTransport.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/Plugins/VR/SpeechTransport.dll -------------------------------------------------------------------------------- /VRGIN/Libs/dxgi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Libs/dxgi.dll -------------------------------------------------------------------------------- /VRGIN/Modes/StandingMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using Valve.VR; 7 | using VRGIN.Controls; 8 | using VRGIN.Controls.Tools; 9 | using VRGIN.Core; 10 | 11 | namespace VRGIN.Modes 12 | { 13 | public class StandingMode : ControlMode 14 | { 15 | 16 | public override void Impersonate(IActor actor, ImpersonationMode mode) 17 | { 18 | base.Impersonate(actor, mode); 19 | 20 | MoveToPosition(actor.Eyes.position, actor.Eyes.rotation, mode == ImpersonationMode.Approximately); 21 | 22 | } 23 | 24 | public override void OnDestroy() 25 | { 26 | base.OnDestroy(); 27 | } 28 | 29 | protected override void OnStart() 30 | { 31 | base.OnStart(); 32 | 33 | VR.Camera.SteamCam.origin.position = Vector3.zero; 34 | VR.Camera.SteamCam.origin.rotation = Quaternion.identity; 35 | 36 | } 37 | 38 | protected override void OnUpdate() 39 | { 40 | base.OnUpdate(); 41 | 42 | if (VRCamera.Instance.HasValidBlueprint) 43 | { 44 | SyncCameras(); 45 | } 46 | } 47 | 48 | protected virtual void SyncCameras() 49 | { 50 | VRCamera.Instance.Blueprint.transform.position = VR.Camera.SteamCam.head.position; 51 | VRCamera.Instance.Blueprint.transform.rotation = VR.Camera.SteamCam.head.rotation; 52 | } 53 | 54 | public override IEnumerable Tools 55 | { 56 | get 57 | { 58 | return base.Tools.Concat(new Type[] { typeof(MenuTool), typeof(WarpTool) }); 59 | } 60 | } 61 | 62 | public override ETrackingUniverseOrigin TrackingOrigin 63 | { 64 | get 65 | { 66 | return ETrackingUniverseOrigin.TrackingUniverseStanding; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /VRGIN/Native/MouseOperations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using static VRGIN.Native.WindowsInterop; 4 | 5 | namespace VRGIN.Native 6 | { 7 | public class MouseOperations 8 | { 9 | 10 | public static void SetCursorPosition(int X, int Y) 11 | { 12 | SetCursorPos(X, Y); 13 | } 14 | 15 | public static void SetClientCursorPosition(int x, int y) 16 | { 17 | var clientRect = WindowManager.GetClientRect(); 18 | SetCursorPos(x + clientRect.Left, y + clientRect.Top); 19 | } 20 | 21 | public static POINT GetClientCursorPosition() 22 | { 23 | var pos = GetCursorPosition(); 24 | var clientRect = WindowManager.GetClientRect(); 25 | 26 | return new POINT(pos.X - clientRect.Left, pos.Y - clientRect.Top); 27 | } 28 | 29 | public static void SetCursorPosition(POINT point) 30 | { 31 | SetCursorPos(point.X, point.Y); 32 | } 33 | 34 | public static POINT GetCursorPosition() 35 | { 36 | POINT currentMousePoint; 37 | var gotPoint = GetCursorPos(out currentMousePoint); 38 | if (!gotPoint) { currentMousePoint = new POINT(0, 0); } 39 | return currentMousePoint; 40 | } 41 | 42 | 43 | public static void MouseEvent(MouseEventFlags value) 44 | { 45 | POINT position = GetCursorPosition(); 46 | 47 | mouse_event 48 | ((int)value, 49 | position.X, 50 | position.Y, 51 | 0, 52 | 0) 53 | ; 54 | } 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /VRGIN/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("VRGIN")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("VRGIN")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("22788a2c-7695-4a6a-a9f0-115ab9a05fd4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /VRGIN/Resources/hands_5_3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/hands_5_3 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_0 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_2 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_3 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_4 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_5 -------------------------------------------------------------------------------- /VRGIN/Resources/vrgin_5_6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/Resources/vrgin_5_6 -------------------------------------------------------------------------------- /VRGIN/SteamVR/Prefabs/[SteamVR].prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &132594 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 458990} 11 | - 114: {fileID: 11432822} 12 | m_Layer: 0 13 | m_Name: '[SteamVR]' 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &458990 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 132594} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11432822 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 132594} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: e979227f3384fac4b8ca0b3550bf005c, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | helpSeconds: 10 43 | helpText: You may now put on your headset. 44 | helpStyle: 45 | m_Name: 46 | m_Normal: 47 | m_Background: {fileID: 0} 48 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 49 | m_Hover: 50 | m_Background: {fileID: 0} 51 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 52 | m_Active: 53 | m_Background: {fileID: 0} 54 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 55 | m_Focused: 56 | m_Background: {fileID: 0} 57 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 58 | m_OnNormal: 59 | m_Background: {fileID: 0} 60 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 61 | m_OnHover: 62 | m_Background: {fileID: 0} 63 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 64 | m_OnActive: 65 | m_Background: {fileID: 0} 66 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 67 | m_OnFocused: 68 | m_Background: {fileID: 0} 69 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 70 | m_Border: 71 | m_Left: 0 72 | m_Right: 0 73 | m_Top: 0 74 | m_Bottom: 0 75 | m_Margin: 76 | m_Left: 0 77 | m_Right: 0 78 | m_Top: 0 79 | m_Bottom: 0 80 | m_Padding: 81 | m_Left: 0 82 | m_Right: 0 83 | m_Top: 0 84 | m_Bottom: 0 85 | m_Overflow: 86 | m_Left: 0 87 | m_Right: 0 88 | m_Top: 0 89 | m_Bottom: 0 90 | m_Font: {fileID: 0} 91 | m_FontSize: 0 92 | m_FontStyle: 0 93 | m_Alignment: 0 94 | m_WordWrap: 0 95 | m_RichText: 1 96 | m_TextClipping: 0 97 | m_ImagePosition: 0 98 | m_ContentOffset: {x: 0, y: 0} 99 | m_FixedWidth: 0 100 | m_FixedHeight: 0 101 | m_StretchWidth: 1 102 | m_StretchHeight: 0 103 | leftMask: 104 | serializedVersion: 2 105 | m_Bits: 0 106 | rightMask: 107 | serializedVersion: 2 108 | m_Bits: 0 109 | trackingSpace: 1 110 | --- !u!1001 &100100000 111 | Prefab: 112 | m_ObjectHideFlags: 1 113 | serializedVersion: 2 114 | m_Modification: 115 | m_TransformParent: {fileID: 0} 116 | m_Modifications: [] 117 | m_RemovedComponents: [] 118 | m_ParentPrefab: {fileID: 0} 119 | m_RootGameObject: {fileID: 132594} 120 | m_IsPrefabParent: 1 121 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_AlphaOut.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_AlphaOut" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float luminance(float3 color) 23 | { 24 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 25 | } 26 | 27 | float4 frag(v2f i) : COLOR { 28 | float4 color = tex2D(_MainTex, i.tex); 29 | float a = saturate(color.a + luminance(color.rgb)); 30 | return float4(a, a, a, a); 31 | } 32 | 33 | ENDCG 34 | 35 | SubShader { 36 | Pass { 37 | ZTest Always Cull Off ZWrite Off 38 | Fog { Mode Off } 39 | 40 | CGPROGRAM 41 | #pragma vertex vert 42 | #pragma fragment frag 43 | ENDCG 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_Blit.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Blit" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = v.vertex; 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return tex2D(_MainTex, i.tex); 24 | } 25 | 26 | float4 frag_linear(v2f i) : COLOR { 27 | return pow(tex2D(_MainTex, i.tex), 1.0 / 2.2); 28 | } 29 | 30 | ENDCG 31 | 32 | SubShader { 33 | Pass { 34 | ZTest Always Cull Off ZWrite Off 35 | Fog { Mode Off } 36 | 37 | CGPROGRAM 38 | #pragma vertex vert 39 | #pragma fragment frag 40 | ENDCG 41 | } 42 | Pass { 43 | ZTest Always Cull Off ZWrite Off 44 | Fog { Mode Off } 45 | 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag_linear 49 | ENDCG 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_BlitFlip.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_BlitFlip" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex.x = v.texcoord.x; 19 | o.tex.y = 1 - v.texcoord.y; 20 | return o; 21 | } 22 | 23 | float4 frag(v2f i) : COLOR { 24 | return tex2D(_MainTex, i.tex); 25 | } 26 | 27 | ENDCG 28 | 29 | SubShader { 30 | Pass { 31 | ZTest Always Cull Off ZWrite Off 32 | Fog { Mode Off } 33 | 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment frag 37 | ENDCG 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_ClearAll.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_ClearAll" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return float4(0, 0, 0, 0); 24 | } 25 | 26 | ENDCG 27 | 28 | SubShader { 29 | Tags{ "Queue" = "Background" } 30 | Pass { 31 | ZTest Always Cull Off ZWrite On 32 | Fog { Mode Off } 33 | 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment frag 37 | ENDCG 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_ColorOut.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_ColorOut" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float luminance(float3 color) 23 | { 24 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 25 | } 26 | 27 | float4 frag(v2f i) : COLOR { 28 | float4 color = tex2D(_MainTex, i.tex); 29 | return float4(color.rgb, 1); 30 | } 31 | 32 | ENDCG 33 | 34 | SubShader { 35 | Pass { 36 | ZTest Always Cull Off ZWrite Off 37 | Fog { Mode Off } 38 | 39 | CGPROGRAM 40 | #pragma vertex vert 41 | #pragma fragment frag 42 | ENDCG 43 | } 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_ExternalCamera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &128450 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 417074} 11 | - 114: {fileID: 11479102} 12 | m_Layer: 0 13 | m_Name: SteamVR_ExternalCamera 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!1 &129796 20 | GameObject: 21 | m_ObjectHideFlags: 0 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | serializedVersion: 4 25 | m_Component: 26 | - 4: {fileID: 444732} 27 | - 114: {fileID: 11487396} 28 | - 114: {fileID: 11472986} 29 | m_Layer: 0 30 | m_Name: Controller (third) 31 | m_TagString: Untagged 32 | m_Icon: {fileID: 0} 33 | m_NavMeshLayer: 0 34 | m_StaticEditorFlags: 0 35 | m_IsActive: 1 36 | --- !u!4 &417074 37 | Transform: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 128450} 42 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 43 | m_LocalPosition: {x: 0, y: 0, z: 0} 44 | m_LocalScale: {x: 1, y: 1, z: 1} 45 | m_Children: 46 | - {fileID: 444732} 47 | m_Father: {fileID: 0} 48 | m_RootOrder: 0 49 | --- !u!4 &444732 50 | Transform: 51 | m_ObjectHideFlags: 1 52 | m_PrefabParentObject: {fileID: 0} 53 | m_PrefabInternal: {fileID: 100100000} 54 | m_GameObject: {fileID: 129796} 55 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 56 | m_LocalPosition: {x: 0, y: 0, z: 0} 57 | m_LocalScale: {x: 1, y: 1, z: 1} 58 | m_Children: [] 59 | m_Father: {fileID: 417074} 60 | m_RootOrder: 0 61 | --- !u!114 &11472986 62 | MonoBehaviour: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 129796} 67 | m_Enabled: 1 68 | m_EditorHideFlags: 0 69 | m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3} 70 | m_Name: 71 | m_EditorClassIdentifier: 72 | index: -1 73 | origin: {fileID: 0} 74 | isValid: 0 75 | --- !u!114 &11479102 76 | MonoBehaviour: 77 | m_ObjectHideFlags: 1 78 | m_PrefabParentObject: {fileID: 0} 79 | m_PrefabInternal: {fileID: 100100000} 80 | m_GameObject: {fileID: 128450} 81 | m_Enabled: 1 82 | m_EditorHideFlags: 0 83 | m_Script: {fileID: 11500000, guid: e3b47c2980b93bc48844a54641dab5b8, type: 3} 84 | m_Name: 85 | m_EditorClassIdentifier: 86 | left: {fileID: 0} 87 | right: {fileID: 0} 88 | objects: 89 | - {fileID: 129796} 90 | --- !u!114 &11487396 91 | MonoBehaviour: 92 | m_ObjectHideFlags: 1 93 | m_PrefabParentObject: {fileID: 0} 94 | m_PrefabInternal: {fileID: 100100000} 95 | m_GameObject: {fileID: 129796} 96 | m_Enabled: 1 97 | m_EditorHideFlags: 0 98 | m_Script: {fileID: 11500000, guid: c9da270df5147d24597cc106058c1fa7, type: 3} 99 | m_Name: 100 | m_EditorClassIdentifier: 101 | offset: {fileID: 0} 102 | frontCam: {fileID: 0} 103 | backCam: {fileID: 0} 104 | --- !u!1001 &100100000 105 | Prefab: 106 | m_ObjectHideFlags: 1 107 | serializedVersion: 2 108 | m_Modification: 109 | m_TransformParent: {fileID: 0} 110 | m_Modifications: [] 111 | m_RemovedComponents: [] 112 | m_ParentPrefab: {fileID: 0} 113 | m_RootGameObject: {fileID: 128450} 114 | m_IsPrefabParent: 1 115 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_Fade.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Fade" { 2 | SubShader { Pass { 3 | Blend SrcAlpha OneMinusSrcAlpha 4 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } 5 | BindChannels { Bind "vertex", vertex Bind "color", color } 6 | } } } -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_HiddenArea.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_HiddenArea" { 2 | 3 | CGINCLUDE 4 | 5 | #include "UnityCG.cginc" 6 | 7 | float4 vert(appdata_base v) : SV_POSITION { return v.vertex; } 8 | float4 frag(float4 v : SV_POSITION) : COLOR { return float4(0,0,0,0); } 9 | 10 | ENDCG 11 | 12 | SubShader { 13 | Tags { "Queue" = "Background" } 14 | Pass { 15 | ZTest Always Cull Off ZWrite On 16 | Fog { Mode Off } 17 | 18 | CGPROGRAM 19 | #pragma vertex vert 20 | #pragma fragment frag 21 | ENDCG 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_Overlay.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Overlay" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = v.vertex; 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return tex2D(_MainTex, i.tex); 24 | } 25 | 26 | float4 frag_linear(v2f i) : COLOR { 27 | return pow(tex2D(_MainTex, i.tex), 2.2); 28 | } 29 | 30 | ENDCG 31 | 32 | SubShader { 33 | Pass { 34 | Blend SrcAlpha OneMinusSrcAlpha 35 | ZTest Always Cull Off ZWrite Off 36 | Fog { Mode Off } 37 | 38 | CGPROGRAM 39 | #pragma vertex vert 40 | #pragma fragment frag 41 | ENDCG 42 | } 43 | Pass { 44 | Blend SrcAlpha OneMinusSrcAlpha 45 | ZTest Always Cull Off ZWrite Off 46 | Fog { Mode Off } 47 | 48 | CGPROGRAM 49 | #pragma vertex vert 50 | #pragma fragment frag_linear 51 | ENDCG 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Resources/SteamVR_SphericalProjection.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_SphericalProjection" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "white" {} 4 | _N ("N (normal of plane)", Vector) = (0,0,0,0) 5 | _Phi0 ("Phi0", Float) = 0 6 | _Phi1 ("Phi1", Float) = 1 7 | _Theta0 ("Theta0", Float) = 0 8 | _Theta1 ("Theta1", Float) = 1 9 | _UAxis ("uAxis", Vector) = (0,0,0,0) 10 | _VAxis ("vAxis", Vector) = (0,0,0,0) 11 | _UOrigin ("uOrigin", Vector) = (0,0,0,0) 12 | _VOrigin ("vOrigin", Vector) = (0,0,0,0) 13 | _UScale ("uScale", Float) = 1 14 | _VScale ("vScale", Float) = 1 15 | } 16 | 17 | CGINCLUDE 18 | 19 | #include "UnityCG.cginc" 20 | 21 | sampler2D _MainTex; 22 | float4 _N; 23 | float _Phi0, _Phi1, _Theta0, _Theta1; 24 | float4 _UAxis, _VAxis; 25 | float4 _UOrigin, _VOrigin; 26 | float _UScale, _VScale; 27 | 28 | struct v2f { 29 | float4 pos : SV_POSITION; 30 | float2 tex : TEXCOORD0; 31 | }; 32 | 33 | v2f vert(appdata_base v) { 34 | v2f o; 35 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 36 | o.tex = float2( 37 | lerp(_Phi0, _Phi1, v.texcoord.x), 38 | lerp(_Theta0, _Theta1, v.texcoord.y)); 39 | return o; 40 | } 41 | 42 | float3 cartesian(float phi, float theta) 43 | { 44 | float sinTheta = sin(theta); 45 | return float3( 46 | sinTheta * sin(phi), 47 | cos(theta), 48 | sinTheta * cos(phi)); 49 | } 50 | 51 | float4 frag(v2f i) : COLOR { 52 | float3 V = cartesian(i.tex.x, i.tex.y); 53 | float3 P = V / dot(V, _N.xyz); // intersection point on plane 54 | float2 uv = float2( 55 | dot(P - _UOrigin.xyz, _UAxis.xyz) * _UScale, 56 | dot(P - _VOrigin.xyz, _VAxis.xyz) * _VScale); 57 | return tex2D(_MainTex, uv); 58 | } 59 | 60 | ENDCG 61 | 62 | SubShader { 63 | Pass { 64 | ZTest Always Cull Off ZWrite Off 65 | Fog { Mode Off } 66 | 67 | CGPROGRAM 68 | #pragma vertex vert 69 | #pragma fragment frag 70 | ENDCG 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_CameraFlip.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2015, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Flips the camera output back to normal for D3D. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | 10 | public class SteamVR_CameraFlip : MonoBehaviour 11 | { 12 | static Material blitMaterial; 13 | 14 | void OnEnable() 15 | { 16 | if (blitMaterial == null) 17 | blitMaterial = new Material(VRGIN.Helpers.UnityHelper.GetShader("Custom/SteamVR_BlitFlip")); 18 | } 19 | 20 | void OnRenderImage(RenderTexture src, RenderTexture dest) 21 | { 22 | Graphics.Blit(src, dest, blitMaterial); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_CameraMask.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Masks out pixels that cannot be seen through the connected hmd. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using UnityEngine.Rendering; 10 | 11 | [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] 12 | public class SteamVR_CameraMask : MonoBehaviour 13 | { 14 | static Material material; 15 | static Mesh[] hiddenAreaMeshes = new Mesh[] { null, null }; 16 | 17 | MeshFilter meshFilter; 18 | 19 | void Awake() 20 | { 21 | meshFilter = GetComponent(); 22 | 23 | if (material == null) 24 | material = new Material(VRGIN.Helpers.UnityHelper.GetShader("Custom/SteamVR_HiddenArea")); 25 | 26 | var mr = GetComponent(); 27 | mr.material = material; 28 | mr.shadowCastingMode = ShadowCastingMode.Off; 29 | mr.receiveShadows = false; 30 | #if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) 31 | mr.lightProbeUsage = LightProbeUsage.Off; 32 | #else 33 | mr.useLightProbes = false; 34 | #endif 35 | mr.reflectionProbeUsage = ReflectionProbeUsage.Off; 36 | } 37 | 38 | public void Set(SteamVR vr, Valve.VR.EVREye eye) 39 | { 40 | int i = (int)eye; 41 | if (hiddenAreaMeshes[i] == null) 42 | hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[i]); 43 | meshFilter.mesh = hiddenAreaMeshes[i]; 44 | } 45 | 46 | public void Clear() 47 | { 48 | meshFilter.mesh = null; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_Ears.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2016, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Handles aligning audio listener when using speakers. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(AudioListener))] 11 | public class SteamVR_Ears : MonoBehaviour 12 | { 13 | public SteamVR_Camera vrcam; 14 | 15 | bool usingSpeakers; 16 | Quaternion offset; 17 | 18 | private void OnNewPosesApplied(params object[] args) 19 | { 20 | var origin = vrcam.origin; 21 | var baseRotation = origin != null ? origin.rotation : Quaternion.identity; 22 | transform.rotation = baseRotation * offset; 23 | } 24 | 25 | void OnEnable() 26 | { 27 | usingSpeakers = false; 28 | 29 | var settings = OpenVR.Settings; 30 | if (settings != null) 31 | { 32 | var error = EVRSettingsError.None; 33 | if (settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_UsingSpeakers_Bool, false, ref error)) 34 | { 35 | usingSpeakers = true; 36 | 37 | var yawOffset = settings.GetFloat(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float, 0.0f, ref error); 38 | offset = Quaternion.Euler(0.0f, yawOffset, 0.0f); 39 | } 40 | } 41 | 42 | if (usingSpeakers) 43 | SteamVR_Utils.Event.Listen("new_poses_applied", OnNewPosesApplied); 44 | } 45 | 46 | void OnDisable() 47 | { 48 | if (usingSpeakers) 49 | SteamVR_Utils.Event.Remove("new_poses_applied", OnNewPosesApplied); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_GameView.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Handles rendering to the game view window 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [RequireComponent(typeof(Camera))] 10 | public class SteamVR_GameView : MonoBehaviour 11 | { 12 | #if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) // DEPRECATED in Unity 5.4+ 13 | public float scale = 1.5f; 14 | public bool drawOverlay = true; 15 | 16 | static Material overlayMaterial; 17 | 18 | void OnEnable() 19 | { 20 | if (overlayMaterial == null) 21 | { 22 | overlayMaterial = new Material(VRGIN.Helpers.UnityHelper.GetShader("Custom/SteamVR_Overlay")); 23 | } 24 | } 25 | 26 | void OnPostRender() 27 | { 28 | var vr = SteamVR.instance; 29 | var camera = GetComponent(); 30 | var aspect = scale * camera.aspect / vr.aspect; 31 | 32 | var x0 = -scale; 33 | var x1 = scale; 34 | var y0 = aspect; 35 | var y1 = -aspect; 36 | 37 | var blitMaterial = SteamVR_Camera.blitMaterial; 38 | blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(camera.hdr); 39 | 40 | GL.PushMatrix(); 41 | GL.LoadOrtho(); 42 | #if !(UNITY_5_0) 43 | blitMaterial.SetPass(0); 44 | #else 45 | blitMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0); 46 | #endif 47 | GL.Begin(GL.QUADS); 48 | GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(x0, y0, 0); 49 | GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(x1, y0, 0); 50 | GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(x1, y1, 0); 51 | GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(x0, y1, 0); 52 | GL.End(); 53 | GL.PopMatrix(); 54 | 55 | var overlay = SteamVR_Overlay.instance; 56 | if (overlay && overlay.texture && overlayMaterial && drawOverlay) 57 | { 58 | var texture = overlay.texture; 59 | overlayMaterial.mainTexture = texture; 60 | 61 | var u0 = 0.0f; 62 | var v0 = 1.0f - (float)Screen.height / texture.height; 63 | var u1 = (float)Screen.width / texture.width; 64 | var v1 = 1.0f; 65 | 66 | GL.PushMatrix(); 67 | GL.LoadOrtho(); 68 | #if !(UNITY_5_0) 69 | overlayMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0); 70 | #else 71 | overlayMaterial.SetPass(0); 72 | #endif 73 | GL.Begin(GL.QUADS); 74 | GL.TexCoord2(u0, v0); GL.Vertex3(-1, -1, 0); 75 | GL.TexCoord2(u1, v0); GL.Vertex3( 1, -1, 0); 76 | GL.TexCoord2(u1, v1); GL.Vertex3( 1, 1, 0); 77 | GL.TexCoord2(u0, v1); GL.Vertex3(-1, 1, 0); 78 | GL.End(); 79 | GL.PopMatrix(); 80 | } 81 | } 82 | #endif 83 | } 84 | 85 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_Skybox.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2015, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Sets cubemap to use in the compositor. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Skybox : MonoBehaviour 11 | { 12 | // Note: Unity's Left and Right Skybox shader variables are switched. 13 | public Texture front, back, left, right, top, bottom; 14 | 15 | public enum CellSize 16 | { 17 | x1024, x64, x32, x16, x8 18 | } 19 | public CellSize StereoCellSize = CellSize.x32; 20 | 21 | public float StereoIpdMm = 64.0f; 22 | 23 | public void SetTextureByIndex(int i, Texture t) 24 | { 25 | switch (i) 26 | { 27 | case 0: 28 | front = t; 29 | break; 30 | case 1: 31 | back = t; 32 | break; 33 | case 2: 34 | left = t; 35 | break; 36 | case 3: 37 | right = t; 38 | break; 39 | case 4: 40 | top = t; 41 | break; 42 | case 5: 43 | bottom = t; 44 | break; 45 | } 46 | } 47 | 48 | public Texture GetTextureByIndex(int i) 49 | { 50 | switch (i) 51 | { 52 | case 0: 53 | return front; 54 | case 1: 55 | return back; 56 | case 2: 57 | return left; 58 | case 3: 59 | return right; 60 | case 4: 61 | return top; 62 | case 5: 63 | return bottom; 64 | } 65 | return null; 66 | } 67 | 68 | static public void SetOverride( 69 | Texture front = null, 70 | Texture back = null, 71 | Texture left = null, 72 | Texture right = null, 73 | Texture top = null, 74 | Texture bottom = null ) 75 | { 76 | var compositor = OpenVR.Compositor; 77 | if (compositor != null) 78 | { 79 | var handles = new Texture[] { front, back, left, right, top, bottom }; 80 | var textures = new Texture_t[6]; 81 | for (int i = 0; i < 6; i++) 82 | { 83 | textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero; 84 | textures[i].eType = SteamVR.instance.graphicsAPI; 85 | textures[i].eColorSpace = EColorSpace.Auto; 86 | } 87 | var error = compositor.SetSkyboxOverride(textures); 88 | if (error != EVRCompositorError.None) 89 | { 90 | Debug.LogError("Failed to set skybox override with error: " + error); 91 | if (error == EVRCompositorError.TextureIsOnWrongDevice) 92 | Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity."); 93 | else if (error == EVRCompositorError.TextureUsesUnsupportedFormat) 94 | Debug.Log("Ensure skybox textures are not compressed and have no mipmaps."); 95 | } 96 | } 97 | } 98 | 99 | static public void ClearOverride() 100 | { 101 | var compositor = OpenVR.Compositor; 102 | if (compositor != null) 103 | compositor.ClearSkyboxOverride(); 104 | } 105 | 106 | void OnEnable() 107 | { 108 | SetOverride(front, back, left, right, top, bottom); 109 | } 110 | 111 | void OnDisable() 112 | { 113 | ClearOverride(); 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_SphericalProjection.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2016, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Applies spherical projection to output. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [ExecuteInEditMode] 10 | public class SteamVR_SphericalProjection : MonoBehaviour 11 | { 12 | static Material material; 13 | 14 | public void Set(Vector3 N, 15 | float phi0, float phi1, float theta0, float theta1, // in degrees 16 | Vector3 uAxis, Vector3 uOrigin, float uScale, 17 | Vector3 vAxis, Vector3 vOrigin, float vScale) 18 | { 19 | if (material == null) 20 | material = new Material(VRGIN.Helpers.UnityHelper.GetShader("Custom/SteamVR_SphericalProjection")); 21 | 22 | material.SetVector("_N", new Vector4(N.x, N.y, N.z)); 23 | material.SetFloat("_Phi0", phi0 * Mathf.Deg2Rad); 24 | material.SetFloat("_Phi1", phi1 * Mathf.Deg2Rad); 25 | material.SetFloat("_Theta0", theta0 * Mathf.Deg2Rad + Mathf.PI / 2); 26 | material.SetFloat("_Theta1", theta1 * Mathf.Deg2Rad + Mathf.PI / 2); 27 | material.SetVector("_UAxis", uAxis); 28 | material.SetVector("_VAxis", vAxis); 29 | material.SetVector("_UOrigin", uOrigin); 30 | material.SetVector("_VOrigin", vOrigin); 31 | material.SetFloat("_UScale", uScale); 32 | material.SetFloat("_VScale", vScale); 33 | } 34 | 35 | void OnRenderImage(RenderTexture src, RenderTexture dest) 36 | { 37 | Graphics.Blit(src, dest, material); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_Stats.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Helper to display various hmd stats via GUIText 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Stats : MonoBehaviour 11 | { 12 | public GUIText text; 13 | 14 | public Color fadeColor = Color.black; 15 | public float fadeDuration = 1.0f; 16 | 17 | void Awake() 18 | { 19 | if (text == null) 20 | { 21 | text = GetComponent(); 22 | text.enabled = false; 23 | } 24 | 25 | if (fadeDuration > 0) 26 | { 27 | SteamVR_Fade.Start(fadeColor, 0); 28 | SteamVR_Fade.Start(Color.clear, fadeDuration); 29 | } 30 | } 31 | 32 | double lastUpdate = 0.0f; 33 | 34 | void Update() 35 | { 36 | if (text != null) 37 | { 38 | if (Input.GetKeyDown(KeyCode.I)) 39 | { 40 | text.enabled = !text.enabled; 41 | } 42 | 43 | if (text.enabled) 44 | { 45 | var compositor = OpenVR.Compositor; 46 | if (compositor != null) 47 | { 48 | var timing = new Compositor_FrameTiming(); 49 | timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming)); 50 | compositor.GetFrameTiming(ref timing, 0); 51 | 52 | var update = timing.m_flSystemTimeInSeconds; 53 | if (update > lastUpdate) 54 | { 55 | var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f; 56 | lastUpdate = update; 57 | text.text = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.m_nNumDroppedFrames); 58 | } 59 | else 60 | { 61 | lastUpdate = update; 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_Status.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Base class for fading things based on SteamVR events 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | public abstract class SteamVR_Status : MonoBehaviour 10 | { 11 | public string message; // name of event to respond to 12 | public float duration, fade; 13 | 14 | protected float timer; 15 | protected bool status; 16 | 17 | public enum Mode 18 | { 19 | OnTrue, 20 | OnFalse, 21 | WhileTrue, 22 | WhileFalse 23 | } 24 | 25 | public Mode mode; 26 | 27 | protected abstract void SetAlpha(float a); 28 | 29 | void OnEnable() 30 | { 31 | SteamVR_Utils.Event.Listen(message, OnEvent); 32 | } 33 | 34 | void OnDisable() 35 | { 36 | SteamVR_Utils.Event.Remove(message, OnEvent); 37 | } 38 | 39 | void OnEvent(params object[] args) 40 | { 41 | status = (bool)args[0]; 42 | if (status) 43 | { 44 | if (mode == Mode.OnTrue) 45 | timer = duration; 46 | } 47 | else 48 | { 49 | if (mode == Mode.OnFalse) 50 | timer = duration; 51 | } 52 | } 53 | 54 | void Update() 55 | { 56 | if (mode == Mode.OnTrue || mode == Mode.OnFalse) 57 | { 58 | timer -= Time.deltaTime; 59 | if (timer < 0.0f) 60 | { 61 | SetAlpha(0.0f); 62 | } 63 | else 64 | { 65 | var a = 1.0f; 66 | if (timer < fade) 67 | a = timer / fade; 68 | if (timer > duration - fade) 69 | a = Mathf.InverseLerp(duration, duration - fade, timer); 70 | SetAlpha(a); 71 | } 72 | } 73 | else 74 | { 75 | var show = (mode == Mode.WhileTrue && status == true) || (mode == Mode.WhileFalse && status == false); 76 | timer = show ? Mathf.Min(fade, timer + Time.deltaTime) : Mathf.Max(0.0f, timer - Time.deltaTime); 77 | SetAlpha(timer / fade); 78 | } 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_StatusText.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Used to display SteamVR status messages 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [RequireComponent(typeof(GUIText))] 10 | public class SteamVR_StatusText : SteamVR_Status 11 | { 12 | GUIText text; 13 | 14 | void Awake() 15 | { 16 | text = GetComponent(); 17 | 18 | if (mode == Mode.WhileTrue || mode == Mode.WhileFalse) 19 | timer = fade * text.color.a; 20 | } 21 | 22 | protected override void SetAlpha(float a) 23 | { 24 | if (a > 0.0f) 25 | { 26 | text.enabled = true; 27 | text.color = new Color(text.color.r, text.color.g, text.color.b, a); 28 | } 29 | else 30 | { 31 | text.enabled = false; 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_TrackedObject.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: For controlling in-game objects with tracked devices. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_TrackedObject : MonoBehaviour 11 | { 12 | public enum EIndex 13 | { 14 | None = -1, 15 | Hmd = (int)OpenVR.k_unTrackedDeviceIndex_Hmd, 16 | Device1, 17 | Device2, 18 | Device3, 19 | Device4, 20 | Device5, 21 | Device6, 22 | Device7, 23 | Device8, 24 | Device9, 25 | Device10, 26 | Device11, 27 | Device12, 28 | Device13, 29 | Device14, 30 | Device15 31 | } 32 | 33 | public EIndex index; 34 | public Transform origin; // if not set, relative to parent 35 | public bool isValid = false; 36 | 37 | private void OnNewPoses(params object[] args) 38 | { 39 | if (index == EIndex.None) 40 | return; 41 | 42 | var i = (int)index; 43 | 44 | isValid = false; 45 | var poses = (Valve.VR.TrackedDevicePose_t[])args[0]; 46 | if (poses.Length <= i) 47 | return; 48 | 49 | if (!poses[i].bDeviceIsConnected) 50 | return; 51 | 52 | if (!poses[i].bPoseIsValid) 53 | return; 54 | 55 | isValid = true; 56 | 57 | var pose = new SteamVR_Utils.RigidTransform(poses[i].mDeviceToAbsoluteTracking); 58 | 59 | if (origin != null) 60 | { 61 | pose = new SteamVR_Utils.RigidTransform(origin) * pose; 62 | pose.pos.x *= origin.localScale.x; 63 | pose.pos.y *= origin.localScale.y; 64 | pose.pos.z *= origin.localScale.z; 65 | transform.position = pose.pos; 66 | transform.rotation = pose.rot; 67 | } 68 | else 69 | { 70 | transform.localPosition = pose.pos; 71 | transform.localRotation = pose.rot; 72 | } 73 | } 74 | 75 | void OnEnable() 76 | { 77 | var render = SteamVR_Render.instance; 78 | if (render == null) 79 | { 80 | enabled = false; 81 | return; 82 | } 83 | 84 | SteamVR_Utils.Event.Listen("new_poses", OnNewPoses); 85 | } 86 | 87 | void OnDisable() 88 | { 89 | SteamVR_Utils.Event.Remove("new_poses", OnNewPoses); 90 | } 91 | 92 | public void SetDeviceIndex(int index) 93 | { 94 | if (System.Enum.IsDefined(typeof(EIndex), index)) 95 | this.index = (EIndex)index; 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Scripts/SteamVR_UpdatePoses.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2016, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Helper to update poses when using native OpenVR integration. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(Camera))] 11 | public class SteamVR_UpdatePoses : MonoBehaviour 12 | { 13 | void Awake() 14 | { 15 | var camera = GetComponent(); 16 | #if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) 17 | camera.stereoTargetEye = StereoTargetEyeMask.None; 18 | #endif 19 | camera.clearFlags = CameraClearFlags.Nothing; 20 | camera.useOcclusionCulling = false; 21 | camera.cullingMask = 0; 22 | camera.depth = -9999; 23 | } 24 | 25 | void OnPreCull() 26 | { 27 | var compositor = OpenVR.Compositor; 28 | if (compositor != null) 29 | { 30 | var render = SteamVR_Render.instance; 31 | compositor.GetLastPoses(render.poses, render.gamePoses); 32 | SteamVR_Utils.Event.Send("new_poses", render.poses); 33 | SteamVR_Utils.Event.Send("new_poses_applied"); 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Textures/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/SteamVR/Textures/arrow.png -------------------------------------------------------------------------------- /VRGIN/SteamVR/Textures/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/SteamVR/Textures/background.png -------------------------------------------------------------------------------- /VRGIN/SteamVR/Textures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/SteamVR/Textures/logo.png -------------------------------------------------------------------------------- /VRGIN/SteamVR/Textures/overlay.renderTexture: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!84 &8400000 4 | RenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: overlay 9 | m_ImageContentsHash: 10 | serializedVersion: 2 11 | Hash: 00000000000000000000000000000000 12 | m_Width: 2048 13 | m_Height: 2048 14 | m_AntiAliasing: 8 15 | m_DepthFormat: 0 16 | m_ColorFormat: 0 17 | m_MipMap: 0 18 | m_GenerateMips: 1 19 | m_SRGB: 0 20 | m_TextureSettings: 21 | m_FilterMode: 2 22 | m_Aniso: 9 23 | m_MipBias: 0 24 | m_WrapMode: 1 25 | -------------------------------------------------------------------------------- /VRGIN/SteamVR/Textures/workshop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/SteamVR/Textures/workshop.png -------------------------------------------------------------------------------- /VRGIN/SteamVR/upgrading.md: -------------------------------------------------------------------------------- 1 | # Upgrading SteamVR 2 | 3 | When upgrading SteamVR, you have to follow these steps: 4 | 5 | 1. When the shaders have been changed, make a new Asset Bundle and replace the file `steamvr` with it. 6 | 2. Make a Find-and-Replace over all scripts in SteamVR, replacing *Shader.Find* with *VRGIN.Helpers.UnityHelper.GetShader* -------------------------------------------------------------------------------- /VRGIN/U46/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("VRGIN.U46")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("VRGIN.U46")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8fe87229-42a4-4cb0-846a-7a2726569b17")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /VRGIN/U46/Resource.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace VRGIN.U46.U46 { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resource { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resource() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VRGIN.U46.U46.Resource", typeof(Resource).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Byte[]. 65 | /// 66 | internal static byte[] hands { 67 | get { 68 | object obj = ResourceManager.GetObject("hands", resourceCulture); 69 | return ((byte[])(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Byte[]. 75 | /// 76 | internal static byte[] steamvr { 77 | get { 78 | object obj = ResourceManager.GetObject("steamvr", resourceCulture); 79 | return ((byte[])(obj)); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /VRGIN/U46/Resources/hands.unity3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/Resources/hands.unity3d -------------------------------------------------------------------------------- /VRGIN/U46/Resources/steamvr.unity3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/Resources/steamvr.unity3d -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Materials/portalworkshop.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 3 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: portalworkshop 10 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: [] 12 | m_CustomRenderQueue: -1 13 | m_SavedProperties: 14 | serializedVersion: 2 15 | m_TexEnvs: 16 | data: 17 | first: 18 | name: _MainTex 19 | second: 20 | m_Texture: {fileID: 2800000, guid: a57cd5c56c9d75c4ba0ee9fbc6e1d8df, type: 3} 21 | m_Scale: {x: 1, y: 1} 22 | m_Offset: {x: 0, y: 0} 23 | m_Floats: {} 24 | m_Colors: {} 25 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Prefabs/[SteamVR].prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &132594 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 458990} 11 | - 114: {fileID: 11432822} 12 | m_Layer: 0 13 | m_Name: '[SteamVR]' 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &458990 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 132594} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11432822 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 132594} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: e979227f3384fac4b8ca0b3550bf005c, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | helpSeconds: 10 43 | helpText: You may now put on your headset. 44 | helpStyle: 45 | m_Name: 46 | m_Normal: 47 | m_Background: {fileID: 0} 48 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 49 | m_Hover: 50 | m_Background: {fileID: 0} 51 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 52 | m_Active: 53 | m_Background: {fileID: 0} 54 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 55 | m_Focused: 56 | m_Background: {fileID: 0} 57 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 58 | m_OnNormal: 59 | m_Background: {fileID: 0} 60 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 61 | m_OnHover: 62 | m_Background: {fileID: 0} 63 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 64 | m_OnActive: 65 | m_Background: {fileID: 0} 66 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 67 | m_OnFocused: 68 | m_Background: {fileID: 0} 69 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 70 | m_Border: 71 | m_Left: 0 72 | m_Right: 0 73 | m_Top: 0 74 | m_Bottom: 0 75 | m_Margin: 76 | m_Left: 0 77 | m_Right: 0 78 | m_Top: 0 79 | m_Bottom: 0 80 | m_Padding: 81 | m_Left: 0 82 | m_Right: 0 83 | m_Top: 0 84 | m_Bottom: 0 85 | m_Overflow: 86 | m_Left: 0 87 | m_Right: 0 88 | m_Top: 0 89 | m_Bottom: 0 90 | m_Font: {fileID: 0} 91 | m_FontSize: 0 92 | m_FontStyle: 0 93 | m_Alignment: 0 94 | m_WordWrap: 0 95 | m_RichText: 1 96 | m_TextClipping: 0 97 | m_ImagePosition: 0 98 | m_ContentOffset: {x: 0, y: 0} 99 | m_FixedWidth: 0 100 | m_FixedHeight: 0 101 | m_StretchWidth: 1 102 | m_StretchHeight: 0 103 | leftMask: 104 | serializedVersion: 2 105 | m_Bits: 0 106 | rightMask: 107 | serializedVersion: 2 108 | m_Bits: 0 109 | trackingSpace: 1 110 | --- !u!1001 &100100000 111 | Prefab: 112 | m_ObjectHideFlags: 1 113 | serializedVersion: 2 114 | m_Modification: 115 | m_TransformParent: {fileID: 0} 116 | m_Modifications: [] 117 | m_RemovedComponents: [] 118 | m_ParentPrefab: {fileID: 0} 119 | m_RootGameObject: {fileID: 132594} 120 | m_IsPrefabParent: 1 121 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_AlphaOut.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_AlphaOut" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float luminance(float3 color) 23 | { 24 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 25 | } 26 | 27 | float4 frag(v2f i) : COLOR { 28 | float4 color = tex2D(_MainTex, i.tex); 29 | float a = saturate(color.a + luminance(color.rgb)); 30 | return float4(a, a, a, a); 31 | } 32 | 33 | ENDCG 34 | 35 | SubShader { 36 | Pass { 37 | ZTest Always Cull Off ZWrite Off 38 | Fog { Mode Off } 39 | 40 | CGPROGRAM 41 | #pragma vertex vert 42 | #pragma fragment frag 43 | ENDCG 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_Blit.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Blit" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = v.vertex; 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return tex2D(_MainTex, i.tex); 24 | } 25 | 26 | float4 frag_linear(v2f i) : COLOR { 27 | return pow(tex2D(_MainTex, i.tex), 1.0 / 2.2); 28 | } 29 | 30 | ENDCG 31 | 32 | SubShader { 33 | Pass { 34 | ZTest Always Cull Off ZWrite Off 35 | Fog { Mode Off } 36 | 37 | CGPROGRAM 38 | #pragma vertex vert 39 | #pragma fragment frag 40 | ENDCG 41 | } 42 | Pass { 43 | ZTest Always Cull Off ZWrite Off 44 | Fog { Mode Off } 45 | 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag_linear 49 | ENDCG 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_BlitFlip.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_BlitFlip" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex.x = v.texcoord.x; 19 | o.tex.y = 1 - v.texcoord.y; 20 | return o; 21 | } 22 | 23 | float4 frag(v2f i) : COLOR { 24 | return tex2D(_MainTex, i.tex); 25 | } 26 | 27 | ENDCG 28 | 29 | SubShader { 30 | Pass { 31 | ZTest Always Cull Off ZWrite Off 32 | Fog { Mode Off } 33 | 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment frag 37 | ENDCG 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_ClearAll.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_ClearAll" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return float4(0, 0, 0, 0); 24 | } 25 | 26 | ENDCG 27 | 28 | SubShader { 29 | Tags{ "Queue" = "Background" } 30 | Pass { 31 | ZTest Always Cull Off ZWrite On 32 | Fog { Mode Off } 33 | 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment frag 37 | ENDCG 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_ColorOut.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_ColorOut" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float luminance(float3 color) 23 | { 24 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 25 | } 26 | 27 | float4 frag(v2f i) : COLOR { 28 | float4 color = tex2D(_MainTex, i.tex); 29 | return float4(color.rgb, 1); 30 | } 31 | 32 | ENDCG 33 | 34 | SubShader { 35 | Pass { 36 | ZTest Always Cull Off ZWrite Off 37 | Fog { Mode Off } 38 | 39 | CGPROGRAM 40 | #pragma vertex vert 41 | #pragma fragment frag 42 | ENDCG 43 | } 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_ExternalCamera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &128450 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 417074} 11 | - 114: {fileID: 11479102} 12 | m_Layer: 0 13 | m_Name: SteamVR_ExternalCamera 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!1 &129796 20 | GameObject: 21 | m_ObjectHideFlags: 0 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | serializedVersion: 4 25 | m_Component: 26 | - 4: {fileID: 444732} 27 | - 114: {fileID: 11487396} 28 | - 114: {fileID: 11472986} 29 | m_Layer: 0 30 | m_Name: Controller (third) 31 | m_TagString: Untagged 32 | m_Icon: {fileID: 0} 33 | m_NavMeshLayer: 0 34 | m_StaticEditorFlags: 0 35 | m_IsActive: 1 36 | --- !u!4 &417074 37 | Transform: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 128450} 42 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 43 | m_LocalPosition: {x: 0, y: 0, z: 0} 44 | m_LocalScale: {x: 1, y: 1, z: 1} 45 | m_Children: 46 | - {fileID: 444732} 47 | m_Father: {fileID: 0} 48 | m_RootOrder: 0 49 | --- !u!4 &444732 50 | Transform: 51 | m_ObjectHideFlags: 1 52 | m_PrefabParentObject: {fileID: 0} 53 | m_PrefabInternal: {fileID: 100100000} 54 | m_GameObject: {fileID: 129796} 55 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 56 | m_LocalPosition: {x: 0, y: 0, z: 0} 57 | m_LocalScale: {x: 1, y: 1, z: 1} 58 | m_Children: [] 59 | m_Father: {fileID: 417074} 60 | m_RootOrder: 0 61 | --- !u!114 &11472986 62 | MonoBehaviour: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 129796} 67 | m_Enabled: 1 68 | m_EditorHideFlags: 0 69 | m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3} 70 | m_Name: 71 | m_EditorClassIdentifier: 72 | index: -1 73 | origin: {fileID: 0} 74 | isValid: 0 75 | --- !u!114 &11479102 76 | MonoBehaviour: 77 | m_ObjectHideFlags: 1 78 | m_PrefabParentObject: {fileID: 0} 79 | m_PrefabInternal: {fileID: 100100000} 80 | m_GameObject: {fileID: 128450} 81 | m_Enabled: 1 82 | m_EditorHideFlags: 0 83 | m_Script: {fileID: 11500000, guid: e3b47c2980b93bc48844a54641dab5b8, type: 3} 84 | m_Name: 85 | m_EditorClassIdentifier: 86 | left: {fileID: 0} 87 | right: {fileID: 0} 88 | objects: 89 | - {fileID: 129796} 90 | --- !u!114 &11487396 91 | MonoBehaviour: 92 | m_ObjectHideFlags: 1 93 | m_PrefabParentObject: {fileID: 0} 94 | m_PrefabInternal: {fileID: 100100000} 95 | m_GameObject: {fileID: 129796} 96 | m_Enabled: 1 97 | m_EditorHideFlags: 0 98 | m_Script: {fileID: 11500000, guid: c9da270df5147d24597cc106058c1fa7, type: 3} 99 | m_Name: 100 | m_EditorClassIdentifier: 101 | offset: {fileID: 0} 102 | frontCam: {fileID: 0} 103 | backCam: {fileID: 0} 104 | --- !u!1001 &100100000 105 | Prefab: 106 | m_ObjectHideFlags: 1 107 | serializedVersion: 2 108 | m_Modification: 109 | m_TransformParent: {fileID: 0} 110 | m_Modifications: [] 111 | m_RemovedComponents: [] 112 | m_ParentPrefab: {fileID: 0} 113 | m_RootGameObject: {fileID: 128450} 114 | m_IsPrefabParent: 1 115 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_Fade.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Fade" { 2 | SubShader { Pass { 3 | Blend SrcAlpha OneMinusSrcAlpha 4 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } 5 | BindChannels { Bind "vertex", vertex Bind "color", color } 6 | } } } -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_HiddenArea.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_HiddenArea" { 2 | 3 | CGINCLUDE 4 | 5 | #include "UnityCG.cginc" 6 | 7 | float4 vert(appdata_base v) : SV_POSITION { return v.vertex; } 8 | float4 frag(float4 v : SV_POSITION) : COLOR { return float4(0,0,0,0); } 9 | 10 | ENDCG 11 | 12 | SubShader { 13 | Tags { "Queue" = "Background" } 14 | Pass { 15 | ZTest Always Cull Off ZWrite On 16 | Fog { Mode Off } 17 | 18 | CGPROGRAM 19 | #pragma vertex vert 20 | #pragma fragment frag 21 | ENDCG 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Resources/SteamVR_Overlay.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SteamVR_Overlay" { 2 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 3 | 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | sampler2D _MainTex; 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 tex : TEXCOORD0; 13 | }; 14 | 15 | v2f vert(appdata_base v) { 16 | v2f o; 17 | o.pos = v.vertex; 18 | o.tex = v.texcoord; 19 | return o; 20 | } 21 | 22 | float4 frag(v2f i) : COLOR { 23 | return tex2D(_MainTex, i.tex); 24 | } 25 | 26 | float4 frag_linear(v2f i) : COLOR { 27 | return pow(tex2D(_MainTex, i.tex), 2.2); 28 | } 29 | 30 | ENDCG 31 | 32 | SubShader { 33 | Pass { 34 | Blend SrcAlpha OneMinusSrcAlpha 35 | ZTest Always Cull Off ZWrite Off 36 | Fog { Mode Off } 37 | 38 | CGPROGRAM 39 | #pragma vertex vert 40 | #pragma fragment frag 41 | ENDCG 42 | } 43 | Pass { 44 | Blend SrcAlpha OneMinusSrcAlpha 45 | ZTest Always Cull Off ZWrite Off 46 | Fog { Mode Off } 47 | 48 | CGPROGRAM 49 | #pragma vertex vert 50 | #pragma fragment frag_linear 51 | ENDCG 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_CameraFlip.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2015, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Flips the camera output back to normal for D3D. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using System; 10 | using VRGIN.Core; 11 | using VRGIN.Helpers; 12 | 13 | public class SteamVR_CameraFlip : MonoBehaviour 14 | { 15 | static Material blitMaterial; 16 | 17 | void OnEnable() 18 | { 19 | try 20 | { 21 | if (blitMaterial == null) 22 | blitMaterial = new Material(UnityHelper.GetShader("SteamVR_BlitFlip")); 23 | } catch(Exception e) 24 | { 25 | Console.WriteLine(e); 26 | } 27 | } 28 | 29 | void OnRenderImage(RenderTexture src, RenderTexture dest) 30 | { 31 | try 32 | { 33 | Graphics.Blit(src, dest, blitMaterial); 34 | } catch(Exception e) 35 | { 36 | Console.WriteLine(e); 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_CameraMask.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Masks out pixels that cannot be seen through the connected hmd. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using UnityEngine.Rendering; 10 | using System; 11 | using VRGIN.Core; 12 | using VRGIN.Helpers; 13 | 14 | [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] 15 | public class SteamVR_CameraMask : ProtectedBehaviour 16 | { 17 | static Material material; 18 | static Mesh[] hiddenAreaMeshes = new Mesh[] { null, null }; 19 | 20 | MeshFilter meshFilter; 21 | 22 | protected override void OnAwake() 23 | { 24 | meshFilter = GetComponent(); 25 | 26 | if (material == null) 27 | material = new Material(UnityHelper.GetShader("SteamVR_HiddenArea")); 28 | 29 | var mr = GetComponent(); 30 | mr.material = material; 31 | mr.castShadows = false; 32 | //mr.shadowCastingMode = ShadowCastingMode.Off; 33 | mr.receiveShadows = false; 34 | #if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 || UNITY_4_5 || UNITY_4_5) 35 | mr.lightProbeUsage = LightProbeUsage.Off; 36 | #else 37 | mr.useLightProbes = false; 38 | #endif 39 | //mr.reflectionProbeUsage = ReflectionProbeUsage.Off; 40 | } 41 | 42 | public void Set(SteamVR vr, Valve.VR.EVREye eye) 43 | { 44 | try 45 | { 46 | int i = (int)eye; 47 | if (hiddenAreaMeshes[i] == null) 48 | hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[i]); 49 | meshFilter.mesh = hiddenAreaMeshes[i]; 50 | } catch(Exception e) 51 | { 52 | Console.WriteLine(e); 53 | } 54 | } 55 | 56 | public void Clear() 57 | { 58 | meshFilter.mesh = null; 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_Ears.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2016, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Handles aligning audio listener when using speakers. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(AudioListener))] 11 | public class SteamVR_Ears : MonoBehaviour 12 | { 13 | public SteamVR_Camera vrcam; 14 | 15 | bool usingSpeakers; 16 | Quaternion offset; 17 | 18 | private void OnNewPosesApplied(params object[] args) 19 | { 20 | var origin = vrcam.origin; 21 | var baseRotation = origin != null ? origin.rotation : Quaternion.identity; 22 | transform.rotation = baseRotation * offset; 23 | } 24 | 25 | void OnEnable() 26 | { 27 | usingSpeakers = false; 28 | 29 | var settings = OpenVR.Settings; 30 | if (settings != null) 31 | { 32 | var error = EVRSettingsError.None; 33 | if (settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_UsingSpeakers_Bool, false, ref error)) 34 | { 35 | usingSpeakers = true; 36 | 37 | var yawOffset = settings.GetFloat(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float, 0.0f, ref error); 38 | offset = Quaternion.Euler(0.0f, yawOffset, 0.0f); 39 | } 40 | } 41 | 42 | if (usingSpeakers) 43 | SteamVR_Utils.Event.Listen("new_poses_applied", OnNewPosesApplied); 44 | } 45 | 46 | void OnDisable() 47 | { 48 | if (usingSpeakers) 49 | SteamVR_Utils.Event.Remove("new_poses_applied", OnNewPosesApplied); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_GameView.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Handles rendering to the game view window 4 | // 5 | //============================================================================= 6 | 7 | using System; 8 | using UnityEngine; 9 | using VRGIN.Core; 10 | using VRGIN.Helpers; 11 | 12 | [RequireComponent(typeof(Camera))] 13 | public class SteamVR_GameView : MonoBehaviour 14 | { 15 | public float scale = 1.5f; 16 | public bool drawOverlay = true; 17 | 18 | static Material overlayMaterial; 19 | 20 | void OnEnable() 21 | { 22 | if (overlayMaterial == null) 23 | { 24 | overlayMaterial = new Material(UnityHelper.GetShader("SteamVR_Overlay")); 25 | } 26 | } 27 | 28 | void OnPostRender() 29 | { 30 | try 31 | { 32 | var vr = SteamVR.instance; 33 | var camera = GetComponent(); 34 | var aspect = scale * camera.aspect / vr.aspect; 35 | 36 | var x0 = -scale; 37 | var x1 = scale; 38 | var y0 = aspect; 39 | var y1 = -aspect; 40 | 41 | var blitMaterial = SteamVR_Camera.blitMaterial; 42 | blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(camera.hdr); 43 | 44 | GL.PushMatrix(); 45 | GL.LoadOrtho(); 46 | #if !(UNITY_5_0 || UNITY_4_5) 47 | blitMaterial.SetPass(0); 48 | #else 49 | blitMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0); 50 | #endif 51 | GL.Begin(GL.QUADS); 52 | GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(x0, y0, 0); 53 | GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(x1, y0, 0); 54 | GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(x1, y1, 0); 55 | GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(x0, y1, 0); 56 | GL.End(); 57 | GL.PopMatrix(); 58 | 59 | var overlay = SteamVR_Overlay.instance; 60 | if (overlay && overlay.texture && overlayMaterial && drawOverlay) 61 | { 62 | var texture = overlay.texture; 63 | overlayMaterial.mainTexture = texture; 64 | 65 | var u0 = 0.0f; 66 | var v0 = 1.0f - (float)Screen.height / texture.height; 67 | var u1 = (float)Screen.width / texture.width; 68 | var v1 = 1.0f; 69 | 70 | GL.PushMatrix(); 71 | GL.LoadOrtho(); 72 | #if !(UNITY_5_0 || UNITY_4_5) 73 | overlayMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0); 74 | #else 75 | overlayMaterial.SetPass(0); 76 | #endif 77 | GL.Begin(GL.QUADS); 78 | GL.TexCoord2(u0, v0); GL.Vertex3(-1, -1, 0); 79 | GL.TexCoord2(u1, v0); GL.Vertex3(1, -1, 0); 80 | GL.TexCoord2(u1, v1); GL.Vertex3(1, 1, 0); 81 | GL.TexCoord2(u0, v1); GL.Vertex3(-1, 1, 0); 82 | GL.End(); 83 | GL.PopMatrix(); 84 | } 85 | } catch(Exception e) 86 | { 87 | Console.WriteLine(e); 88 | } 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_Skybox.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2015, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Sets cubemap to use in the compositor. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Skybox : MonoBehaviour 11 | { 12 | // Note: Unity's Left and Right Skybox shader variables are switched. 13 | public Texture front, back, left, right, top, bottom; 14 | 15 | public void SetTextureByIndex(int i, Texture t) 16 | { 17 | switch (i) 18 | { 19 | case 0: 20 | front = t; 21 | break; 22 | case 1: 23 | back = t; 24 | break; 25 | case 2: 26 | left = t; 27 | break; 28 | case 3: 29 | right = t; 30 | break; 31 | case 4: 32 | top = t; 33 | break; 34 | case 5: 35 | bottom = t; 36 | break; 37 | } 38 | } 39 | 40 | public Texture GetTextureByIndex(int i) 41 | { 42 | switch (i) 43 | { 44 | case 0: 45 | return front; 46 | case 1: 47 | return back; 48 | case 2: 49 | return left; 50 | case 3: 51 | return right; 52 | case 4: 53 | return top; 54 | case 5: 55 | return bottom; 56 | } 57 | return null; 58 | } 59 | 60 | static public void SetOverride( 61 | Texture front = null, 62 | Texture back = null, 63 | Texture left = null, 64 | Texture right = null, 65 | Texture top = null, 66 | Texture bottom = null ) 67 | { 68 | var compositor = OpenVR.Compositor; 69 | if (compositor != null) 70 | { 71 | var handles = new Texture[] { front, back, left, right, top, bottom }; 72 | var textures = new Texture_t[6]; 73 | for (int i = 0; i < 6; i++) 74 | { 75 | textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero; 76 | textures[i].eType = SteamVR.instance.graphicsAPI; 77 | textures[i].eColorSpace = EColorSpace.Auto; 78 | } 79 | var error = compositor.SetSkyboxOverride(textures); 80 | if (error != EVRCompositorError.None) 81 | { 82 | Debug.LogError("Failed to set skybox override with error: " + error); 83 | if (error == EVRCompositorError.TextureIsOnWrongDevice) 84 | Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity."); 85 | else if (error == EVRCompositorError.TextureUsesUnsupportedFormat) 86 | Debug.Log("Ensure skybox textures are not compressed and have no mipmaps."); 87 | } 88 | } 89 | } 90 | 91 | static public void ClearOverride() 92 | { 93 | var compositor = OpenVR.Compositor; 94 | if (compositor != null) 95 | compositor.ClearSkyboxOverride(); 96 | } 97 | 98 | void OnEnable() 99 | { 100 | SetOverride(front, back, left, right, top, bottom); 101 | } 102 | 103 | void OnDisable() 104 | { 105 | ClearOverride(); 106 | } 107 | } 108 | 109 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_Stats.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Helper to display various hmd stats via GUIText 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Stats : MonoBehaviour 11 | { 12 | public GUIText text; 13 | 14 | public Color fadeColor = Color.black; 15 | public float fadeDuration = 1.0f; 16 | 17 | void Awake() 18 | { 19 | if (text == null) 20 | { 21 | text = GetComponent(); 22 | text.enabled = false; 23 | } 24 | 25 | if (fadeDuration > 0) 26 | { 27 | SteamVR_Fade.Start(fadeColor, 0); 28 | SteamVR_Fade.Start(Color.clear, fadeDuration); 29 | } 30 | } 31 | 32 | double lastUpdate = 0.0f; 33 | 34 | void Update() 35 | { 36 | if (text != null) 37 | { 38 | if (Input.GetKeyDown(KeyCode.I)) 39 | { 40 | text.enabled = !text.enabled; 41 | } 42 | 43 | if (text.enabled) 44 | { 45 | var compositor = OpenVR.Compositor; 46 | if (compositor != null) 47 | { 48 | var timing = new Compositor_FrameTiming(); 49 | timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming)); 50 | compositor.GetFrameTiming(ref timing, 0); 51 | 52 | var update = timing.m_flSystemTimeInSeconds; 53 | if (update > lastUpdate) 54 | { 55 | var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f; 56 | lastUpdate = update; 57 | text.text = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.m_nNumDroppedFrames); 58 | } 59 | else 60 | { 61 | lastUpdate = update; 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_Status.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Base class for fading things based on SteamVR events 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | public abstract class SteamVR_Status : MonoBehaviour 10 | { 11 | public string message; // name of event to respond to 12 | public float duration, fade; 13 | 14 | protected float timer; 15 | protected bool status; 16 | 17 | public enum Mode 18 | { 19 | OnTrue, 20 | OnFalse, 21 | WhileTrue, 22 | WhileFalse 23 | } 24 | 25 | public Mode mode; 26 | 27 | protected abstract void SetAlpha(float a); 28 | 29 | void OnEnable() 30 | { 31 | SteamVR_Utils.Event.Listen(message, OnEvent); 32 | } 33 | 34 | void OnDisable() 35 | { 36 | SteamVR_Utils.Event.Remove(message, OnEvent); 37 | } 38 | 39 | void OnEvent(params object[] args) 40 | { 41 | status = (bool)args[0]; 42 | if (status) 43 | { 44 | if (mode == Mode.OnTrue) 45 | timer = duration; 46 | } 47 | else 48 | { 49 | if (mode == Mode.OnFalse) 50 | timer = duration; 51 | } 52 | } 53 | 54 | void Update() 55 | { 56 | if (mode == Mode.OnTrue || mode == Mode.OnFalse) 57 | { 58 | timer -= Time.deltaTime; 59 | if (timer < 0.0f) 60 | { 61 | SetAlpha(0.0f); 62 | } 63 | else 64 | { 65 | var a = 1.0f; 66 | if (timer < fade) 67 | a = timer / fade; 68 | if (timer > duration - fade) 69 | a = Mathf.InverseLerp(duration, duration - fade, timer); 70 | SetAlpha(a); 71 | } 72 | } 73 | else 74 | { 75 | var show = (mode == Mode.WhileTrue && status == true) || (mode == Mode.WhileFalse && status == false); 76 | timer = show ? Mathf.Min(fade, timer + Time.deltaTime) : Mathf.Max(0.0f, timer - Time.deltaTime); 77 | SetAlpha(timer / fade); 78 | } 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_StatusText.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Used to display SteamVR status messages 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [RequireComponent(typeof(GUIText))] 10 | public class SteamVR_StatusText : SteamVR_Status 11 | { 12 | GUIText text; 13 | 14 | void Awake() 15 | { 16 | text = GetComponent(); 17 | 18 | if (mode == Mode.WhileTrue || mode == Mode.WhileFalse) 19 | timer = fade * text.color.a; 20 | } 21 | 22 | protected override void SetAlpha(float a) 23 | { 24 | if (a > 0.0f) 25 | { 26 | text.enabled = true; 27 | text.color = new Color(text.color.r, text.color.g, text.color.b, a); 28 | } 29 | else 30 | { 31 | text.enabled = false; 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_TrackedObject.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2014, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: For controlling in-game objects with tracked devices. 4 | // 5 | //============================================================================= 6 | 7 | using System; 8 | using UnityEngine; 9 | using Valve.VR; 10 | 11 | public class SteamVR_TrackedObject : MonoBehaviour 12 | { 13 | public enum EIndex 14 | { 15 | None = -1, 16 | Hmd = (int)OpenVR.k_unTrackedDeviceIndex_Hmd, 17 | Device1, 18 | Device2, 19 | Device3, 20 | Device4, 21 | Device5, 22 | Device6, 23 | Device7, 24 | Device8, 25 | Device9, 26 | Device10, 27 | Device11, 28 | Device12, 29 | Device13, 30 | Device14, 31 | Device15 32 | } 33 | 34 | public EIndex index; 35 | public Transform origin; // if not set, relative to parent 36 | public bool isValid = false; 37 | 38 | private void OnNewPoses(params object[] args) 39 | { 40 | if (index == EIndex.None) 41 | return; 42 | 43 | var i = (int)index; 44 | 45 | isValid = false; 46 | var poses = (Valve.VR.TrackedDevicePose_t[])args[0]; 47 | if (poses.Length <= i) 48 | return; 49 | 50 | if (!poses[i].bDeviceIsConnected) 51 | return; 52 | 53 | if (!poses[i].bPoseIsValid) 54 | return; 55 | 56 | isValid = true; 57 | 58 | var pose = new SteamVR_Utils.RigidTransform(poses[i].mDeviceToAbsoluteTracking); 59 | 60 | if (origin != null) 61 | { 62 | pose = new SteamVR_Utils.RigidTransform(origin) * pose; 63 | pose.pos.x *= origin.localScale.x; 64 | pose.pos.y *= origin.localScale.y; 65 | pose.pos.z *= origin.localScale.z; 66 | transform.position = pose.pos; 67 | transform.rotation = pose.rot; 68 | } 69 | else 70 | { 71 | transform.localPosition = pose.pos; 72 | transform.localRotation = pose.rot; 73 | } 74 | //Console.WriteLine(transform.localPosition.y); 75 | } 76 | 77 | void Update() 78 | { 79 | } 80 | 81 | void OnEnable() 82 | { 83 | var render = SteamVR_Render.instance; 84 | if (render == null) 85 | { 86 | enabled = false; 87 | return; 88 | } 89 | 90 | SteamVR_Utils.Event.Listen("new_poses", OnNewPoses); 91 | } 92 | 93 | void OnDisable() 94 | { 95 | SteamVR_Utils.Event.Remove("new_poses", OnNewPoses); 96 | } 97 | 98 | public void SetDeviceIndex(int index) 99 | { 100 | Console.WriteLine("Set index to " + index); 101 | if (System.Enum.IsDefined(typeof(EIndex), index)) 102 | this.index = (EIndex)index; 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Scripts/SteamVR_UpdatePoses.cs: -------------------------------------------------------------------------------- 1 | //========= Copyright 2016, Valve Corporation, All rights reserved. =========== 2 | // 3 | // Purpose: Helper to update poses when using native OpenVR integration. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(Camera))] 11 | public class SteamVR_UpdatePoses : MonoBehaviour 12 | { 13 | void Awake() 14 | { 15 | var camera = GetComponent(); 16 | #if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 || UNITY_4_5 || UNITY_4_5) 17 | camera.targetEye = TargetEyeMask.kTargetEyeMaskNone; 18 | #endif 19 | camera.clearFlags = CameraClearFlags.Nothing; 20 | camera.useOcclusionCulling = false; 21 | camera.cullingMask = 0; 22 | camera.depth = -9999; 23 | } 24 | 25 | void OnPreCull() 26 | { 27 | var compositor = OpenVR.Compositor; 28 | if (compositor != null) 29 | { 30 | var render = SteamVR_Render.instance; 31 | compositor.GetLastPoses(render.poses, render.gamePoses); 32 | SteamVR_Utils.Event.Send("new_poses", render.poses); 33 | SteamVR_Utils.Event.Send("new_poses_applied"); 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Textures/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/SteamVR/Textures/arrow.png -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Textures/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/SteamVR/Textures/background.png -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Textures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/SteamVR/Textures/logo.png -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Textures/overlay.renderTexture: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!84 &8400000 4 | RenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: overlay 9 | m_ImageContentsHash: 10 | serializedVersion: 2 11 | Hash: 00000000000000000000000000000000 12 | m_Width: 2048 13 | m_Height: 2048 14 | m_AntiAliasing: 8 15 | m_DepthFormat: 0 16 | m_ColorFormat: 0 17 | m_MipMap: 0 18 | m_GenerateMips: 1 19 | m_SRGB: 0 20 | m_TextureSettings: 21 | m_FilterMode: 2 22 | m_Aniso: 9 23 | m_MipBias: 0 24 | m_WrapMode: 1 25 | -------------------------------------------------------------------------------- /VRGIN/U46/SteamVR/Textures/portalworkshop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eusth/VRGIN/8f08b27e97be67e012f985899865412eadb5a9f0/VRGIN/U46/SteamVR/Textures/portalworkshop.png -------------------------------------------------------------------------------- /VRGIN/Visuals/ArcRenderer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System; 6 | using VRGIN.Core; 7 | 8 | namespace VRGIN.Visuals 9 | { 10 | [RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))] 11 | public class ArcRenderer : MonoBehaviour 12 | { 13 | 14 | public int VertexCount = 50; 15 | public float UvSpeed = 5; 16 | public float Velocity = 6f; 17 | private MeshFilter _MeshFilter; 18 | private Renderer _Renderer; 19 | public Vector3 target; 20 | public float Offset = 0; 21 | public float Scale = 1; 22 | private Mesh _mesh; 23 | 24 | // Use this for initialization 25 | void Awake() 26 | { 27 | _MeshFilter = GetComponent(); 28 | _Renderer = GetComponent(); 29 | 30 | _mesh = new Mesh(); 31 | _Renderer.material = VRManager.Instance.Context.Materials.Sprite; 32 | #if UNITY_4_5 33 | _Renderer.castShadows = false; 34 | #else 35 | _Renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; 36 | #endif 37 | _Renderer.receiveShadows = false; 38 | _Renderer.useLightProbes = false; 39 | _Renderer.material.color = VRManager.Instance.Context.PrimaryColor; 40 | } 41 | 42 | 43 | // Update is called once per frame 44 | public void Update() 45 | { 46 | var direction = transform.forward; 47 | var vertices = new List(); 48 | 49 | var pos = transform.position; 50 | float v = -(Velocity * transform.forward).y * Scale; 51 | float g = Physics.gravity.y * Scale; 52 | //float maxH = (v * v) / (2 * g); 53 | //float h = Mathf.Max(maxH, pos.y - Offset); 54 | float h = pos.y - Offset; 55 | 56 | float totT1 = (Mathf.Sqrt(v * v - 2 * g * h) + v) / g; 57 | float totT2 = (v - Mathf.Sqrt(v * v - 2 * g * h)) / g; 58 | float totT = Mathf.Max(totT1, totT2); 59 | totT = Mathf.Abs(totT); 60 | 61 | float timeStep = totT / VertexCount; 62 | 63 | for (int i = 0; i <= VertexCount; i++) 64 | { 65 | float t = Mathf.Clamp(((i / (VertexCount - 1f)) * totT) + ((Time.time * UvSpeed) % 2) * timeStep - timeStep, 0, totT); 66 | //Logger.Info(t); 67 | vertices.Add(transform.InverseTransformPoint(pos + ((direction * Velocity) * t + 0.5f * Physics.gravity * t * t) * Scale)); 68 | } 69 | 70 | 71 | target = transform.position + ((direction * Velocity) * totT + 0.5f * Physics.gravity * totT * totT) * Scale; 72 | target.y = 0; 73 | 74 | GetComponent().material.mainTextureOffset += new Vector2(UvSpeed * Time.deltaTime, 0); 75 | 76 | _mesh.vertices = vertices.ToArray(); 77 | //mesh.SetIndices(vertices.Select((v, i) => i).ToArray(), MeshTopology.LineStrip, 0); 78 | _mesh.SetIndices(vertices.Take(vertices.Count - 1).Select((ve, i) => i).Where(i => i % 2 == 0).SelectMany(i => new int[] { i, i + 1 }).ToArray(), MeshTopology.Lines, 0); 79 | 80 | _MeshFilter.mesh = _mesh; 81 | } 82 | 83 | void OnEnable() 84 | { 85 | GetComponent().enabled = true; 86 | } 87 | 88 | void OnDisable() 89 | { 90 | GetComponent().enabled = false; 91 | } 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /VRGIN/Visuals/IMaterialPalette.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace VRGIN.Visuals 8 | { 9 | public interface IMaterialPalette 10 | { 11 | Material Sprite 12 | { 13 | get; 14 | } 15 | 16 | Material Unlit 17 | { 18 | get; 19 | } 20 | 21 | Material UnlitTransparent 22 | { 23 | get; 24 | } 25 | 26 | Material UnlitTransparentCombined 27 | { 28 | get; 29 | } 30 | 31 | Shader StandardShader 32 | { 33 | get; 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /VRGIN/Visuals/SimulatedCursor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | using VRGIN.Core; 8 | using VRGIN.Helpers; 9 | 10 | namespace VRGIN.Visuals 11 | { 12 | /// 13 | /// Cursor Quad that simulates a cursor when the game uses a hardware cursor. 14 | /// 15 | public class SimulatedCursor : ProtectedBehaviour 16 | { 17 | private Texture2D _Sprite; 18 | private Texture2D _DefaultSprite; 19 | private Vector2 _Scale; 20 | 21 | /// 22 | /// Creates a new SimulatedCursor. Use this to make one. 23 | /// 24 | /// 25 | public static SimulatedCursor Create() 26 | { 27 | var cursor = new GameObject("VRGIN_Cursor") 28 | .AddComponent(); 29 | 30 | return cursor; 31 | } 32 | 33 | protected override void OnAwake() 34 | { 35 | base.OnAwake(); 36 | _DefaultSprite = UnityHelper.LoadImage("cursor.png"); 37 | _Scale = new Vector2(_DefaultSprite.width, _DefaultSprite.height) * 0.5f; 38 | } 39 | 40 | protected override void OnStart() 41 | { 42 | base.OnStart(); 43 | } 44 | 45 | void OnGUI() 46 | { 47 | // Just before the VRGUI hook kicks in 48 | GUI.depth = int.MinValue + 1; 49 | #if UNITY_4_5 50 | if (Screen.showCursor) 51 | #else 52 | if (Cursor.visible) 53 | #endif 54 | { 55 | var pos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y); 56 | 57 | GUI.DrawTexture(new Rect(pos.x, pos.y, _Scale.x, _Scale.y), _Sprite ?? _DefaultSprite); 58 | 59 | //_Cursor.GetComponent().anchoredPosition = Input.mousePosition; 60 | } 61 | 62 | } 63 | 64 | public void SetCursor(Texture2D texture) 65 | { 66 | _Sprite = texture; 67 | } 68 | } 69 | } 70 | --------------------------------------------------------------------------------