123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- using System;
- using UnityEngine;
- public class DummyVRCamera : OvrCamera
- {
- public override bool IsNoHandController
- {
- get
- {
- return true;
- }
- }
- protected override void Awake()
- {
- this.m_fDistanceRate = 1.4f;
- this.m_trRealHead = UTY.GetChildObject(base.gameObject, "Main Camera (head)", false).transform;
- this.m_goCenterEye = UTY.GetChildObject(base.gameObject, "Main Camera (head)/Main Camera (eye)", false);
- this.m_trCenterEye = this.m_goCenterEye.transform;
- this.m_camMain = this.m_goCenterEye.GetComponent<Camera>();
- this.m_FadeTargetCameraOVR = this.m_goCenterEye.GetComponent<ScreenOverlay>();
- this.m_BloomOVR = this.m_goCenterEye.GetComponent<Bloom>();
- this.m_fBloomDefIntensity = this.m_BloomOVR.bloomIntensity;
- this.m_trTarget = new GameObject("OVRCamTarget").transform;
- this.m_trTarget.SetParent(GameMain.Instance.transform, false);
- this.m_trVirtualMy = new GameObject("OVRCamMy").transform;
- this.m_trVirtualMy.SetParent(GameMain.Instance.transform, false);
- GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("OVR/OvrHeadScale")) as GameObject;
- gameObject.SetActive(true);
- GameObject gameObject2 = GameObject.Find("SystemUI Root");
- gameObject.transform.SetParent(gameObject2.transform, false);
- this.m_labelHeadScale = gameObject.GetComponentInChildren<UILabel>();
- this.m_labelHeadScale.enabled = false;
- this.m_goOvrUiScreen = UTY.GetChildObject(this.m_trRealHead.gameObject, "UI", false);
- this.m_goOvrUiTablet = UTY.GetChildObject(base.gameObject, "Odogu_TabletPC", false);
- this.m_trOvrUiTablet = this.m_goOvrUiTablet.transform;
- this.m_OvrTablet = this.m_goOvrUiTablet.GetComponent<OvrTablet>();
- this.m_OvrTablet.Init(this.m_trRealHead.gameObject);
- Vignetting vignetting = base.gameObject.AddComponent<Vignetting>();
- vignetting.enabled = false;
- Camera component = base.gameObject.GetComponent<Camera>();
- component.enabled = false;
- this.m_trBaseHead = new GameObject("DummyVRCamBaseHead").transform;
- this.m_trBaseHead.SetParent(GameMain.Instance.transform, false);
- this.m_trCursorLaserHit = this.m_goOvrUiScreen.transform.Find("ovr_screen/hit");
- NDebug.Assert(this.m_trCursorLaserHit != null, "UI Cursor Hit オブジェクトが見つかりません。");
- float ovrViveCursorLaserHitScale = GameMain.Instance.CMSystem.OvrViveCursorLaserHitScale;
- this.m_trCursorLaserHit.localScale = new Vector3(ovrViveCursorLaserHitScale, ovrViveCursorLaserHitScale, ovrViveCursorLaserHitScale);
- this.m_VREvnetText = this.m_trRealHead.Find("VREventText").GetComponent<VREventText>();
- Texture2D texture2D = Resources.Load<Texture2D>("System/Texture/black");
- SteamVR_Skybox.SetOverride(texture2D, texture2D, texture2D, texture2D, texture2D, texture2D);
- Transform transform = base.transform.Find("Controller (left)");
- Transform transform2 = base.transform.Find("Controller (right)");
- this.m_VRCtrlLeft = transform.GetComponent<DummyVRController>();
- this.m_VRCtrlLeft.Init();
- this.m_VRCtrlRight = transform2.GetComponent<DummyVRController>();
- this.m_VRCtrlRight.Init();
- Transform transform3 = this.m_trRealHead.Find("EyeRayCaster");
- this.m_EyeRay = transform3.GetComponent<OvrEyeRay>();
- NDebug.Assert(this.m_EyeRay != null, "視線検出機構がみつかりません。");
- this.m_DummyHand = base.transform.Find("HandPlayer").GetComponent<DummyVRHandAnimator>();
- NDebug.Assert(this.m_DummyHand != null, "HandPlayer が見つかりません。");
- this.m_DummyHand.gameObject.SetActive(false);
- this.UpdateHeadScale();
- this.m_bWheelToZoom = true;
- }
- public override void Start()
- {
- this.m_goOvrUiScreen.SetActive(false);
- this.m_goOvrUiTablet.SetActive(true);
- this.m_goOvrUiNow = this.m_goOvrUiTablet;
- this.ReCallcOffset();
- }
- public override void ChangeControllerNew(bool f_bNew)
- {
- }
- public override void DefaultControllerMode(bool f_bEnable)
- {
- }
- public override void ReCallcOffset()
- {
- }
- public override void OnLevelWasLoaded(int level)
- {
- base.OnLevelWasLoaded(level);
- this.m_bDummyYotogiCamera = this.m_bIsSceneYotogi;
- this.m_bIsSceneYotogi = false;
- }
- public override void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible)
- {
- if (f_bVisible)
- {
- }
- }
- public override void CameraMaskReset()
- {
- }
- public override void SetCameraType(CameraMain.CameraType f_eType)
- {
- }
- public override CameraMain.CameraType GetCameraType()
- {
- return CameraMain.CameraType.Free;
- }
- public override void SetControl(bool f_bEnable)
- {
- }
- public override bool GetControl()
- {
- return true;
- }
- public override void SetTargetPos(Vector3 f_vecWorldPos, bool f_bSelf = true)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.m_trTarget.position = f_vecWorldPos;
- this.SetTransform(this.m_trTarget.position, this.m_vRot, this.m_fDistance);
- }
- public override Vector3 GetTargetPos()
- {
- return this.m_trTarget.position;
- }
- public override void SetDistance(float f_fDistance, bool f_bSelf = true)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.m_fDistance = f_fDistance;
- this.SetTransform(this.m_trTarget.position, this.m_vRot, this.m_fDistance);
- }
- public override float GetDistance()
- {
- return this.m_fDistance;
- }
- public override void SetAroundAngle(Vector2 f_vecAngle, bool f_bSelf = true)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.SetTransform(this.m_trTarget.position, f_vecAngle, this.m_fDistance);
- }
- public override Vector2 GetAroundAngle()
- {
- return this.m_vRot;
- }
- public override void SetTargetOffset(Vector3 f_vOffs, bool f_bSelf = true)
- {
- }
- public override Vector3 GetPos()
- {
- return this.m_trBaseHead.position;
- }
- public override void SetRealHeadPos(Vector3 f_vecWorldPos, bool f_bYFromFloor = false)
- {
- if (f_bYFromFloor)
- {
- f_vecWorldPos.y = this.GetYfromFloor(f_vecWorldPos);
- }
- this.m_trBaseHead.position = f_vecWorldPos;
- this.UpdateRealPosRot();
- }
- public override void SetRealHeadRot(Vector3 f_vecWorldRot, bool f_bRotYOnly = true)
- {
- Transform realHeadTransform = this.GetRealHeadTransform();
- this.m_trBaseHead.position = realHeadTransform.position;
- if (f_bRotYOnly)
- {
- this.m_trBaseHead.rotation = Quaternion.Euler(0f, realHeadTransform.rotation.eulerAngles.y, 0f);
- }
- else
- {
- this.m_trBaseHead.rotation = Quaternion.Euler(f_vecWorldRot);
- }
- float num = f_vecWorldRot.y - realHeadTransform.rotation.eulerAngles.y;
- f_vecWorldRot.y = realHeadTransform.rotation.eulerAngles.y + num;
- this.m_trBaseHead.rotation = Quaternion.Euler(f_vecWorldRot);
- this.UpdateRealPosRot();
- }
- public override void SetFootPos(Vector3 f_vecFootPos, CameraMain.STAND_SIT f_eState)
- {
- if (f_eState == CameraMain.STAND_SIT.STAND)
- {
- f_vecFootPos.y += GameMain.Instance.CMSystem.VRCameraHeightStandOffs;
- }
- else if (f_eState == CameraMain.STAND_SIT.SIT)
- {
- f_vecFootPos.y += GameMain.Instance.CMSystem.VRCameraHeightSitOffs;
- }
- else
- {
- f_vecFootPos.y += this.GetYfromFloor(this.GetRealHeadTransform().position);
- }
- this.SetRealHeadPos(f_vecFootPos, false);
- }
- public override Transform GetBaseHeadTransform()
- {
- return this.m_trBaseHead;
- }
- public override Transform GetRealHeadTransform()
- {
- return this.m_trRealHead;
- }
- private void SetTransform(Vector3 f_vecTargetPosWorld, Vector2 f_vecRot, float f_fDistance)
- {
- this.m_trTarget.position = f_vecTargetPosWorld;
- this.m_vRot = f_vecRot;
- this.m_trVirtualMy.rotation = Quaternion.identity;
- this.m_trVirtualMy.Rotate(new Vector3(0f, f_vecRot.x, 0f), Space.World);
- this.m_trVirtualMy.Rotate(new Vector3(f_vecRot.y, 0f, 0f), Space.Self);
- if (this.m_bDummyYotogiCamera)
- {
- f_fDistance *= this.m_fDistanceRate;
- }
- this.m_trVirtualMy.position = this.m_trVirtualMy.rotation * new Vector3(0f, 0f, -f_fDistance) + this.m_trTarget.position;
- this.m_trBaseHead.position = this.m_trVirtualMy.position + (this.m_trTarget.position - this.m_trVirtualMy.position) * 0.5f;
- this.m_trBaseHead.rotation = this.m_trVirtualMy.rotation;
- this.UpdateRealPosRot();
- }
- public override void Reset(CameraMain.CameraType f_eType, bool f_bControl)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- base.RemoveChaseCameraAll();
- this.SetTargetPos(new Vector3(0f, 1.5f, 0f), true);
- }
- public override void FadeOutNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
- {
- }
- public override void FadeInNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
- {
- }
- protected override float GetFadeIntensity()
- {
- return this.m_FadeTargetCameraOVR.intensity;
- }
- protected override void OnProcessFade(float f_fIntensity)
- {
- this.m_FadeTargetCameraOVR.intensity = f_fIntensity;
- }
- protected override void OnOverlayState(bool f_bEnable)
- {
- this.m_FadeTargetCameraOVR.enabled = f_bEnable;
- }
- public override Ray GetForwardRay()
- {
- return new Ray(this.m_trCenterEye.position, this.m_trCenterEye.rotation * Vector3.forward);
- }
- public override void UpdateHeadScale()
- {
- float ovrHeadScale = GameMain.Instance.CMSystem.OvrHeadScale;
- base.gameObject.transform.localScale = new Vector3(ovrHeadScale, ovrHeadScale, ovrHeadScale);
- this.m_trBaseHead.localScale = base.gameObject.transform.localScale;
- }
- protected override void UpdateRealPosRot()
- {
- base.transform.position = this.m_trBaseHead.position;
- base.transform.rotation = this.m_trBaseHead.rotation;
- this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero));
- }
- public override void MirrorSwitch()
- {
- }
- public override void UIPosReset(float f_fOffsetRotY = 0f)
- {
- }
- protected override void Update()
- {
- if (GameMain.Instance == null)
- {
- return;
- }
- if (!base.IsUIShow)
- {
- UICamera.InputEnable = false;
- }
- if (this.m_DummyHand != null)
- {
- this.m_DummyHand.Show = (this.m_unDummyHandVisibleFlag != 0U);
- }
- if (this.m_BloomOVR != null)
- {
- bool enabled = this.m_BloomOVR.enabled;
- this.m_BloomOVR.enabled = GameMain.Instance.CMSystem.Bloom;
- this.m_BloomOVR.bloomIntensity = this.m_fBloomDefIntensity * (float)GameMain.Instance.CMSystem.BloomValue * 0.01f;
- if (this.m_BloomOVR.bloomIntensity <= 0.01f)
- {
- this.m_BloomOVR.enabled = false;
- }
- else
- {
- this.m_BloomOVR.enabled = true;
- }
- if (base.IsUIShow)
- {
- this.m_BloomOVR.enabled = false;
- }
- if (this.m_BloomOVR.enabled != enabled)
- {
- GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
- }
- }
- float vrcameraFov = GameMain.Instance.CMSystem.VRCameraFov;
- if (this.m_fBackFOV != vrcameraFov)
- {
- this.m_camMain.fieldOfView = vrcameraFov;
- float num = (vrcameraFov - 30f) / 30f;
- float num2 = 0.23f + 0.17f * num;
- this.m_VREvnetText.gameObject.transform.localScale = new Vector3(num2, num2, num2);
- this.m_fBackFOV = vrcameraFov;
- }
- RaycastHit raycastHit;
- if (Physics.Raycast(this.m_camMain.ScreenPointToRay(Input.mousePosition), out raycastHit, float.PositiveInfinity, 33554432))
- {
- Vector2 textureCoord = raycastHit.textureCoord;
- Vector2 v = new Vector2(1280f * (textureCoord.x / 1f), 720f * (textureCoord.y / 1f));
- GameMain.Instance.OvrMgr.SystemUICamera.SetOvrVirtualMousePos(false, v);
- }
- this.m_bSlideMoving = false;
- this.vFowerd = this.m_trCenterEye.rotation * Vector3.forward;
- this.vLeft = this.m_trCenterEye.rotation * Vector3.left;
- this.vUp = this.m_trCenterEye.rotation * Vector3.up;
- if (GameMain.Instance.CMSystem.VRCameraPlaneMove)
- {
- this.vLeft.y = (this.vFowerd.y = 0f);
- this.vLeft.Normalize();
- this.vFowerd.Normalize();
- this.vUp = Vector3.up;
- }
- this.v = this.m_trBaseHead.position;
- if (this.m_bFallThrough || !this.m_bUiToggle)
- {
- if (this.m_bWheelToZoom && !base.IsUIShow)
- {
- this.v += this.vFowerd * (NInput.GetAxis(this.mouseAxisZoom) * (this.m_MoveSpeed * 10f * Time.deltaTime));
- }
- if (NInput.GetMouseButton(2))
- {
- Vector3 vector = new Vector3(-NInput.GetAxis(this.mouseAxisX), -NInput.GetAxis(this.mouseAxisY), 0f);
- this.v += this.vLeft * (vector.x * this.m_MoveSpeed * Time.deltaTime);
- this.v -= this.vUp * (vector.y * this.m_MoveSpeed * Time.deltaTime);
- this.m_bSlideMoving = true;
- }
- if (NInput.GetMouseButton(1))
- {
- }
- }
- if (NInput.GetMouseButton(1))
- {
- this.vMouseMoving += new Vector2(Math.Abs(NInput.GetAxis("Mouse X")), Math.Abs(NInput.GetAxis("Mouse Y")));
- }
- else
- {
- if ((this.m_bFallThrough || this.m_bIsForceRightClickUiToggle) && NInput.GetMouseButtonUp(1) && this.vMouseMoving.magnitude < 3f && this.m_bRightClickUIToggle)
- {
- this.ToggleUI();
- }
- this.vMouseMoving = Vector2.zero;
- }
- if (GameMain.Instance.MainCamera.GetFadeState() != CameraMain.FadeState.Out)
- {
- if (Input.GetKey(KeyCode.A))
- {
- this.v += this.vLeft * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.A) * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.D))
- {
- this.v -= this.vLeft * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.D) * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.W))
- {
- this.v += this.vFowerd * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.W) * Time.deltaTime);
- }
- if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.S))
- {
- this.v -= this.vFowerd * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.S) * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.Z))
- {
- this.v -= this.vUp * (this.m_MoveSpeed * base.MoveSpeedAccel * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.X))
- {
- this.v += this.vUp * (this.m_MoveSpeed * base.MoveSpeedAccel * Time.deltaTime);
- }
- if (this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY)
- {
- this.m_trBaseHead.position = this.v;
- }
- if (Input.GetKey(KeyCode.Q))
- {
- this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), -90f * base.RotSpeedAccel * Time.deltaTime, Space.World);
- }
- if (Input.GetKey(KeyCode.E))
- {
- this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 90f * base.RotSpeedAccel * Time.deltaTime, Space.World);
- }
- if (!base.IsUIShow && !this.m_bSlideMoving && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height && (NInput.InputUseLegacyAxisMode || (Cursor.lockState == CursorLockMode.Locked && !Cursor.visible)) && !base.IsFadeOut())
- {
- this.m_vHeadRotTarget.x = this.m_vHeadRotTarget.x - NInput.GetAxis("Mouse Y") * this.m_fHeadRotSpeed * base.RotMouseSpeedAccel;
- this.m_vHeadRotTarget.y = this.m_vHeadRotTarget.y + NInput.GetAxis("Mouse X") * this.m_fHeadRotSpeed * base.RotMouseSpeedAccel;
- this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), this.m_vHeadRotTarget.y - this.m_vHeadRotEaseBef.y, Space.World);
- float d = 1f;
- if (GameMain.Instance.CMSystem.VRCamRotDownUp)
- {
- d = -1f;
- }
- this.m_trBaseHead.Rotate(this.m_trBaseHead.right * d, this.m_vHeadRotTarget.x - this.m_vHeadRotEaseBef.x, Space.World);
- this.m_vHeadRotEaseBef = this.m_vHeadRotTarget;
- }
- else
- {
- this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero));
- }
- }
- else
- {
- this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero));
- }
- if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq))
- {
- if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
- {
- this.SnapShotOVR(false);
- }
- else if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
- {
- this.SnapShotOVR(true);
- }
- }
- if (Input.GetKeyUp(KeyCode.R))
- {
- this.ReCallcOffset();
- }
- if (Input.GetKeyUp(KeyCode.Space))
- {
- this.ToggleUI();
- }
- if (base.IsUIShow)
- {
- Cursor.visible = true;
- Cursor.lockState = CursorLockMode.None;
- }
- else if (this.m_bUiShowBack)
- {
- Cursor.visible = false;
- Cursor.lockState = CursorLockMode.Locked;
- }
- else
- {
- if (Input.GetKeyUp(KeyCode.Escape))
- {
- Cursor.visible = true;
- Cursor.lockState = CursorLockMode.None;
- }
- if (NInput.GetMouseButtonUp(0) && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height)
- {
- Cursor.visible = false;
- Cursor.lockState = CursorLockMode.Locked;
- }
- }
- base.transform.position = this.m_trBaseHead.position;
- base.transform.rotation = this.m_trBaseHead.rotation;
- this.CheckSwitchManHeadEnable(this.m_trRealHead.position);
- this.m_bUiShowBack = base.IsUIShow;
- }
- private void OnDrawGizmos()
- {
- if (this.m_trTarget != null)
- {
- Gizmos.DrawIcon(this.m_trTarget.position, "gizmo_eye.png", true);
- if (base.enabled)
- {
- Gizmos.color = Color.cyan;
- Gizmos.DrawRay(this.m_trVirtualMy.position, this.m_trTarget.position - this.m_trVirtualMy.position);
- Gizmos.DrawRay(this.m_trCenterEye.position, this.m_trCenterEye.rotation * Vector3.forward * 10f);
- }
- }
- }
- private Vector2 m_vHeadRotEaseNow = Vector2.zero;
- private Vector2 m_vHeadRotEaseBef = Vector2.zero;
- public float m_fHeadRotSpeed = 1.5f;
- public float m_fHeadRotEase = 0.5f;
- private Vector2 m_vHeadRotTarget = Vector2.zero;
- public float m_fDistanceRate = 1.4f;
- private ScreenOverlay m_Fade;
- private Camera m_camMain;
- private float m_fBackFOV;
- private bool m_bDummyYotogiCamera;
- private enum MouseButtonDown
- {
- MBD_LEFT,
- MBD_RIGHT,
- MBD_MIDDLE
- }
- }
|