void Start() { handVRMain_ = FindObjectOfType <HandVRMain>(); rigidbody_ = GetComponent <Rigidbody>(); renderer_ = GetComponent <Renderer>(); if (renderer_ != null) { renderer_.enabled = false; } }
void Start() { handVRMain_ = FindObjectOfType <HandVRMain>(); handMRManager_ = FindObjectOfType <HandMRManager>(); renderer_ = transform.GetComponentInChildren <Renderer>(); defaultColor_ = renderer_.material.GetColor("_Color"); renderer_.material.SetColor("_Color", new Color(defaultColor_.r, defaultColor_.g, defaultColor_.b, 0f)); defaultColorInner_ = renderer_.material.GetColor("_ColorInner"); renderer_.material.SetColor("_ColorInner", new Color(defaultColorInner_.r, defaultColorInner_.g, defaultColorInner_.b, 0f)); }
void Update() { if (handVRMain_ == null) { handVRMain_ = FindObjectOfType <HandVRMain>(); } if (handVRMain_ == null) { return; } int id = handVRMain_.GetIdFromHandednesses(ThisEitherHand); if (id < 0) { PhysicEnabled = false; if (Time.unscaledTime > currentDisableTime_) { if (renderer_ != null) { renderer_.enabled = false; } } return; } float[] posVecArray = handVRMain_.GetLandmark(id, Index); if (posVecArray != null) { if (renderer_ != null) { renderer_.enabled = true; } PhysicEnabled = true; position_ = new Vector3(posVecArray[0], posVecArray[1], posVecArray[2]); currentDisableTime_ = Time.unscaledTime + DISABLE_TIME; } else { PhysicEnabled = false; if (Time.unscaledTime > currentDisableTime_) { if (renderer_ != null) { renderer_.enabled = false; } } } }
void Start() { handVRMain_ = FindObjectOfType <HandVRMain>(); handMRManager_ = FindObjectOfType <HandMRManager>(); foreach (Transform child in transform) { HandVRPosition posObj = child.GetComponent <HandVRPosition>(); if (posObj != null) { fingers_[posObj.Index] = child; posObj.ThisEitherHand = ThisEitherHand; } } startInputDevice(); }
void Reset() { try { HandMRManagerObj = FindObjectOfType <HandMRManager>(); HologlaCameraManagerObj = HandMRManagerObj.GetComponentInChildren <HologlaCameraManager>().gameObject; HandVRMainObj = HandMRManagerObj.GetComponentInChildren <HandVRMain>(); var hologlaInput = HandMRManagerObj.GetComponentInChildren <HologlaInput>(); LeftButton = hologlaInput.LeftButtonComp.transform; RightButton = hologlaInput.RightButtonComp.transform; } catch (NullReferenceException) { Debug.Log("Setting SettingFromPlayerPrefs is failed.\nPlease setting from Inspector."); } var handArea = FindObjectOfType <HandArea>(); if (handArea != null) { HandAreaObj = handArea.gameObject; } }
IEnumerator Start() { #if LANG_JP ExplanationText.text = "マーカーを映してください"; #else ExplanationText.text = "Please capture marker."; #endif while (MarkerTransforms == null) { yield return(null); } #if LANG_JP ExplanationText.text = "マーカーの近くの平面に手を置き、撮影ボタンを押してください"; #else ExplanationText.text = "Put your hands near by marker, and push Capture button."; #endif HandVRMain handVRMain = FindObjectOfType <HandVRMain>(); for (; ;) { while (!captureButtonIsClicked_) { yield return(null); } captureButtonIsClicked_ = false; float[][] landmarks = new float[21][]; for (int index = 0; index < 21; index++) { landmarks[index] = handVRMain.GetLandmarkOnImage(0, index); if (landmarks[index] == null) { break; } } if (landmarks[20] == null) { #if LANG_JP ExplanationText.text = "手の認識に失敗しました。もう一度撮影してください"; #else ExplanationText.text = "Failed to hand recognition."; #endif continue; } Vector3 point0 = MainCamera.WorldToViewportPoint(MarkerTransforms[0].position); Vector3 point1 = MainCamera.WorldToViewportPoint(MarkerTransforms[1].position); Vector3 point2 = MainCamera.WorldToViewportPoint(MarkerTransforms[2].position); Vector3 point3 = MainCamera.WorldToViewportPoint(MarkerTransforms[3].position); handSizeCalibFindHomography( point0.x * Screen.width / Screen.height, 1f - point0.y, point1.x * Screen.width / Screen.height, 1f - point1.y, point2.x * Screen.width / Screen.height, 1f - point2.y, point3.x * Screen.width / Screen.height, 1f - point3.y, 0.14f); for (int index = 0; index < 21; index++) { handSizeCalibTransform(ref landmarks[index][0], ref landmarks[index][1]); } float angle = -Mathf.Atan2(landmarks[9][1] - landmarks[0][1], landmarks[9][0] - landmarks[0][0]) + 90f * Mathf.Deg2Rad; float sin = Mathf.Sin(angle); float cos = Mathf.Cos(angle); int[] pointIds = new int[] { 0, 5, 9, 13, 17 }; for (int loop = 0; loop < pointIds.Length; loop++) { float x = landmarks[pointIds[loop]][0] - landmarks[0][0]; float y = landmarks[pointIds[loop]][1] - landmarks[0][1]; PlayerPrefs.SetFloat("HandMR_PointPosX_" + loop, x * cos - y * sin); PlayerPrefs.SetFloat("HandMR_PointPosY_" + loop, x * sin + y * cos); } PlayerPrefs.SetFloat("HandMR_PointLength_0", calcLength(landmarks[1], landmarks[0])); PlayerPrefs.SetFloat("HandMR_PointLength_1", calcLength(landmarks[2], landmarks[1])); PlayerPrefs.SetFloat("HandMR_PointLength_2", calcLength(landmarks[3], landmarks[2])); PlayerPrefs.SetFloat("HandMR_PointLength_3", calcLength(landmarks[4], landmarks[3])); PlayerPrefs.SetFloat("HandMR_PointLength_4", calcLength(landmarks[6], landmarks[5])); PlayerPrefs.SetFloat("HandMR_PointLength_5", calcLength(landmarks[7], landmarks[6])); PlayerPrefs.SetFloat("HandMR_PointLength_6", calcLength(landmarks[8], landmarks[7])); PlayerPrefs.SetFloat("HandMR_PointLength_7", calcLength(landmarks[10], landmarks[9])); PlayerPrefs.SetFloat("HandMR_PointLength_8", calcLength(landmarks[11], landmarks[10])); PlayerPrefs.SetFloat("HandMR_PointLength_9", calcLength(landmarks[12], landmarks[11])); PlayerPrefs.SetFloat("HandMR_PointLength_10", calcLength(landmarks[14], landmarks[13])); PlayerPrefs.SetFloat("HandMR_PointLength_11", calcLength(landmarks[15], landmarks[14])); PlayerPrefs.SetFloat("HandMR_PointLength_12", calcLength(landmarks[16], landmarks[15])); PlayerPrefs.SetFloat("HandMR_PointLength_13", calcLength(landmarks[18], landmarks[17])); PlayerPrefs.SetFloat("HandMR_PointLength_14", calcLength(landmarks[19], landmarks[18])); PlayerPrefs.SetFloat("HandMR_PointLength_15", calcLength(landmarks[20], landmarks[19])); PlayerPrefs.Save(); #if LANG_JP ExplanationText.text = "設定に成功しました"; #else ExplanationText.text = "Success."; #endif handVRMain.ResetHandValues(); } }