| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 | 
							- using System;
 
- using UnityEngine;
 
- public class ViveCamera : OvrCamera
 
- {
 
- 	protected override void Awake()
 
- 	{
 
- 		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_nBackCullingMask = this.m_goCenterEye.GetComponent<Camera>().cullingMask;
 
- 		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_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("ViveCamBaseHead").transform;
 
- 		this.m_trBaseHead.SetParent(GameMain.Instance.transform, false);
 
- 		this.m_trBaseRoomBase = new GameObject("BaseRoomBase").transform;
 
- 		this.m_trBaseRoomBase.SetParent(this.m_trBaseHead, 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<ViveController>();
 
- 		this.m_VRCtrlLeft.Init();
 
- 		this.m_VRCtrlRight = transform2.GetComponent<ViveController>();
 
- 		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_camClearCam = this.m_trRealHead.Find("ClearCamera").GetComponent<Camera>();
 
- 		NDebug.Assert(this.m_camClearCam != null, "ClearCameraが見つかりません。");
 
- 		this.m_camClearCam.gameObject.SetActive(false);
 
- 		this.m_camClearCam.enabled = false;
 
- 		this.m_view = this.m_trRealHead.GetComponent<SteamVR_GameView>();
 
- 		this.m_view.enabled = true;
 
- 		this.UpdateHeadScale();
 
- 	}
 
- 	public override void ReCallcOffset()
 
- 	{
 
- 		Vector3 position = this.m_trBaseHead.position;
 
- 		Quaternion rotation = this.m_trBaseHead.rotation;
 
- 		this.m_trBaseHead.position = this.m_trRealHead.position;
 
- 		Vector3 eulerAngles = this.m_trRealHead.rotation.eulerAngles;
 
- 		this.m_trBaseHead.rotation = Quaternion.Euler(0f, eulerAngles.y, 0f);
 
- 		this.m_trBaseRoomBase.position = base.transform.position;
 
- 		this.m_trBaseRoomBase.rotation = base.transform.rotation;
 
- 		this.m_trBaseHead.position = position;
 
- 		Vector3 eulerAngles2 = rotation.eulerAngles;
 
- 		this.m_trBaseHead.rotation = Quaternion.Euler(0f, eulerAngles2.y, 0f);
 
- 		this.UpdateRealPosRot();
 
- 	}
 
- 	public override void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible)
 
- 	{
 
- 		Camera component = this.m_goCenterEye.GetComponent<Camera>();
 
- 		if (f_bVisible)
 
- 		{
 
- 			component.cullingMask |= 1 << (int)f_eMask;
 
- 		}
 
- 		else
 
- 		{
 
- 			component.cullingMask &= ~(1 << (int)f_eMask);
 
- 		}
 
- 	}
 
- 	public override void CameraMaskReset()
 
- 	{
 
- 		Camera component = this.m_goCenterEye.GetComponent<Camera>();
 
- 		component.cullingMask = this.m_nBackCullingMask;
 
- 	}
 
- 	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 (GameMain.Instance.CMSystem.OvrCameraHeightType == CMSystem.OVR_CAM_HEIGHT_TYPE.VR)
 
- 		{
 
- 			if (f_bYFromFloor)
 
- 			{
 
- 				f_vecWorldPos.y = this.GetYfromFloor(f_vecWorldPos);
 
- 			}
 
- 			Vector3 position = this.m_trBaseRoomBase.position;
 
- 			this.m_trBaseHead.position = f_vecWorldPos;
 
- 			Vector3 b = f_vecWorldPos - this.GetRealHeadTransform().position;
 
- 			this.m_trBaseRoomBase.position = position + b;
 
- 		}
 
- 		else
 
- 		{
 
- 			if (f_bYFromFloor)
 
- 			{
 
- 				f_vecWorldPos = this.GetFloorPos(f_vecWorldPos);
 
- 			}
 
- 			Vector3 position2 = this.m_trBaseRoomBase.position;
 
- 			Vector3 position3 = this.GetRealHeadTransform().position;
 
- 			position3.y = position2.y;
 
- 			Vector3 b2 = position2 - position3;
 
- 			this.m_trBaseRoomBase.position = f_vecWorldPos + b2;
 
- 		}
 
- 		this.UpdateRealPosRot();
 
- 	}
 
- 	public override void SetFootPos(Vector3 f_vecFootPos, CameraMain.STAND_SIT f_eState)
 
- 	{
 
- 		if (GameMain.Instance.CMSystem.OvrCameraHeightType == CMSystem.OVR_CAM_HEIGHT_TYPE.VR)
 
- 		{
 
- 			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);
 
- 		}
 
- 		else
 
- 		{
 
- 			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);
 
- 		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;
 
- 		Quaternion rotation = Quaternion.LookRotation(new Vector3(this.m_trTarget.position.x, 0f, this.m_trTarget.position.z) - new Vector3(this.m_trVirtualMy.position.x, 0f, this.m_trVirtualMy.position.z));
 
- 		this.m_trBaseHead.rotation = 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_trBaseRoomBase.position;
 
- 		base.transform.rotation = this.m_trBaseRoomBase.rotation;
 
- 	}
 
- 	public override void MirrorSwitch()
 
- 	{
 
- 		if (this.m_camClearCam != null)
 
- 		{
 
- 			if (!this.m_camClearCam.enabled || !this.m_camClearCam.gameObject.activeSelf)
 
- 			{
 
- 				this.m_camClearCam.enabled = true;
 
- 				this.m_camClearCam.gameObject.SetActive(true);
 
- 				this.m_view.enabled = false;
 
- 			}
 
- 			else
 
- 			{
 
- 				this.m_camClearCam.enabled = false;
 
- 				this.m_camClearCam.gameObject.SetActive(false);
 
- 				this.m_view.enabled = true;
 
- 			}
 
- 		}
 
- 	}
 
- 	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 Camera m_camClearCam;
 
- 	private SteamVR_GameView m_view;
 
- 	private enum MouseButtonDown
 
- 	{
 
- 		MBD_LEFT,
 
- 		MBD_RIGHT,
 
- 		MBD_MIDDLE
 
- 	}
 
- }
 
 
  |