public static Quaternion GetRotation(this Matrix4x4 matrix) { Quaternion quaternion = default(Quaternion); quaternion.w = Mathf.Sqrt(Mathf.Max(0f, 1f + matrix.m00 + matrix.m11 + matrix.m22)) / 2f; quaternion.x = Mathf.Sqrt(Mathf.Max(0f, 1f + matrix.m00 - matrix.m11 - matrix.m22)) / 2f; quaternion.y = Mathf.Sqrt(Mathf.Max(0f, 1f - matrix.m00 + matrix.m11 - matrix.m22)) / 2f; quaternion.z = Mathf.Sqrt(Mathf.Max(0f, 1f - matrix.m00 - matrix.m11 + matrix.m22)) / 2f; quaternion.x = SteamVR_Utils._copysign(quaternion.x, matrix.m21 - matrix.m12); quaternion.y = SteamVR_Utils._copysign(quaternion.y, matrix.m02 - matrix.m20); quaternion.z = SteamVR_Utils._copysign(quaternion.z, matrix.m10 - matrix.m01); return(quaternion); }
private void UpdateBulletDisplayAmount(InventorySlotAmmo item, int clipLeft) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot)) { m_numberBulletsInMagDisplay.text = clipLeft + "\n----\n" + ((int)(item.BulletsMaxCap * item.RelInPack)).ToString(); m_numberBulletsInMagDisplay.ForceMeshUpdate(false); m_bulletsInMagDisplay.MaxValue = Mathf.Max(item.BulletClipSize, 1); m_bulletsInMagDisplay.UpdateCurrentAmmo(clipLeft); m_bulletsInMagDisplay.UpdateAmmoGridDivisions(); } }
private SteamVR() { BlackMagic.LoadBlackMagic(); ClassInjector.RegisterTypeInIl2Cpp <MelonCoroutineCallbacks>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_ActivateActionSetOnLoad>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Boolean>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Single>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Skeleton>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Vector2>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Vector3>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Behaviour_Pose>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Camera>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_CameraFlip>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_CameraMask>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Ears>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_ExternalCamera>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Frustum>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Fade>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_GameView>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_IK>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Overlay>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_PlayArea>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_RenderModel>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Render>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Skeleton_Poser>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_SphericalProjection>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_Skybox>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_TrackingReferenceManager>(); ClassInjector.RegisterTypeInIl2Cpp <SteamVR_TrackedObject>(); UnityHooks.Init(); this.hmd = OpenVR.System; UnityEngine.Debug.Log("<b>[SteamVR_Standalone]</b> Initialized. Connected to " + this.hmd_TrackingSystemName + ":" + this.hmd_SerialNumber); this.compositor = OpenVR.Compositor; this.overlay = OpenVR.Overlay; uint num = 0u; uint num2 = 0u; this.hmd.GetRecommendedRenderTargetSize(ref num, ref num2); this.sceneWidth = num; this.sceneHeight = num2; float num3 = 0f; float num4 = 0f; float num5 = 0f; float num6 = 0f; this.hmd.GetProjectionRaw(EVREye.Eye_Left, ref num3, ref num4, ref num5, ref num6); float num7 = 0f; float num8 = 0f; float num9 = 0f; float num10 = 0f; this.hmd.GetProjectionRaw(EVREye.Eye_Right, ref num7, ref num8, ref num9, ref num10); this.tanHalfFov = new Vector2(Mathf.Max(new float[] { -num3, num4, -num7, num8 }), Mathf.Max(new float[] { -num5, num6, -num9, num10 })); this.textureBounds = new VRTextureBounds_t[2]; this.textureBounds[0].uMin = 0.5f + 0.5f * num3 / this.tanHalfFov.x; this.textureBounds[0].uMax = 0.5f + 0.5f * num4 / this.tanHalfFov.x; this.textureBounds[0].vMin = 0.5f - 0.5f * num6 / this.tanHalfFov.y; this.textureBounds[0].vMax = 0.5f - 0.5f * num5 / this.tanHalfFov.y; this.textureBounds[1].uMin = 0.5f + 0.5f * num7 / this.tanHalfFov.x; this.textureBounds[1].uMax = 0.5f + 0.5f * num8 / this.tanHalfFov.x; this.textureBounds[1].vMin = 0.5f - 0.5f * num10 / this.tanHalfFov.y; this.textureBounds[1].vMax = 0.5f - 0.5f * num9 / this.tanHalfFov.y; SteamVR.OpenVRMagic.SetSubmitParams(this.textureBounds[0], this.textureBounds[1], EVRSubmitFlags.Submit_Default); this.sceneWidth /= Mathf.Max(this.textureBounds[0].uMax - this.textureBounds[0].uMin, this.textureBounds[1].uMax - this.textureBounds[1].uMin); this.sceneHeight /= Mathf.Max(this.textureBounds[0].vMax - this.textureBounds[0].vMin, this.textureBounds[1].vMax - this.textureBounds[1].vMin); this.aspect = this.tanHalfFov.x / this.tanHalfFov.y; this.fieldOfView = 2f * Mathf.Atan(this.tanHalfFov.y) * 57.29578f; this.eyes = new SteamVR_Utils.RigidTransform[] { new SteamVR_Utils.RigidTransform(this.hmd.GetEyeToHeadTransform(EVREye.Eye_Left)), new SteamVR_Utils.RigidTransform(this.hmd.GetEyeToHeadTransform(EVREye.Eye_Right)) }; GraphicsDeviceType graphicsDeviceType = SystemInfo.graphicsDeviceType; if (graphicsDeviceType <= GraphicsDeviceType.OpenGLES3) { if (graphicsDeviceType != GraphicsDeviceType.OpenGLES2 && graphicsDeviceType != GraphicsDeviceType.OpenGLES3) { goto IL_3F8; } } else if (graphicsDeviceType != GraphicsDeviceType.OpenGLCore) { if (graphicsDeviceType == GraphicsDeviceType.Vulkan) { this.textureType = ETextureType.Vulkan; goto IL_3FF; } goto IL_3F8; } this.textureType = ETextureType.OpenGL; goto IL_3FF; IL_3F8: this.textureType = ETextureType.DirectX; IL_3FF: SteamVR_Events.Initializing.Listen((this.OnInitializing)); SteamVR_Events.Calibrating.Listen((this.OnCalibrating)); SteamVR_Events.OutOfRange.Listen((this.OnOutOfRange)); SteamVR_Events.DeviceConnected.Listen((this.OnDeviceConnected)); SteamVR_Events.NewPoses.Listen((this.OnNewPoses)); }