private void Update() { //This lerp will fade the color of the object _graphic.color = Color.Lerp(_graphic.color, _targetColor, Time.deltaTime * (1 / AnimationTime)); if (containsText) { text.color = Color.Lerp(text.color, targetTextColor, Time.deltaTime * (1 / AnimationTime)); } //check if user has focused on button and pressed trigger if (ViveInput.GetPressDown(controllerToSet.controller, ControllerButton.Trigger) && inFocus) { Debug.Log("Trigger pressed with gaze"); if (clickAudio != null) { clickAudio.Play(0); } buttonReference.onClick.Invoke(); } }
void Update() { UpdateSpellSwitcher(); if (ViveInput.GetPressDown(m_handRole, ControllerButton.Trigger)) { ElementalMagic.CastSpell(transform.position, transform.forward); } if (ViveInput.GetPressDown(m_handRole, ControllerButton.Grip)) { ElementalMagic.SwitchSpell(); } if (ViveInput.GetPressDown(m_handRole, ControllerButton.PadTouch)) { m_spellSwitcherScript.Activate(); } else if (ViveInput.GetPress(m_handRole, ControllerButton.PadTouch)) { Vector2 touchPosition = ViveInput.GetPadAxis(m_handRole, true); if (touchPosition.x > 0 && touchPosition.y > 0) // First Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Fire); } else if (touchPosition.x < 0 && touchPosition.y > 0) // Second Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Water); } else if (touchPosition.x < 0 && touchPosition.y < 0) // Third Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Lightning); } else if (touchPosition.x > 0 && touchPosition.y < 0) // Fourth Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Stone); } } else if (ViveInput.GetPressUp(m_handRole, ControllerButton.PadTouch)) { m_spellSwitcherScript.Deactivate(); } }
/// <summary> /// When scalingActivated is true and both triggers are pressed, /// scale the game object base on the change of distance between two controllers /// </summary> void Update() { if (scalingActivated && ViveInput.GetPressEx(HandRole.RightHand, ControllerButton.Trigger) && ViveInput.GetPressEx(HandRole.LeftHand, ControllerButton.Trigger)) // Conditions for active scaling { var rightHandIndex = ViveRole.GetDeviceIndexEx(HandRole.RightHand); var leftHandIndex = ViveRole.GetDeviceIndexEx(HandRole.LeftHand); if (VRModule.IsValidDeviceIndex(rightHandIndex) && VRModule.IsValidDeviceIndex(leftHandIndex)) { var rightHandState = VRModule.GetDeviceState(rightHandIndex); var leftHandState = VRModule.GetDeviceState(leftHandIndex); // Get device state for both hands float dist = Vector3.Distance(rightHandState.position, leftHandState.position); if (prevDist == 0) { prevDist = dist; } else { // Scaling the object based on distance change gameObject.transform.localScale *= (1 + scalingFactor * (dist - prevDist)); prevDist = dist; } } else { Debug.Log("Scaling: controller state error"); } } if (ViveInput.GetPressUpEx(HandRole.RightHand, ControllerButton.Trigger) || ViveInput.GetPressUpEx(HandRole.LeftHand, ControllerButton.Trigger)) { prevDist = 0.0f; } }
static int PadToIndex(HandPoseManager.LR lr, int partitionCount, float padCenterSize) { if (partitionCount <= 0) { return(-1); } var handRole = LRToRole(lr); if (!ViveInput.GetPressEx(handRole, ControllerButton.PadTouch)) { return(-1); } if (partitionCount == 1) { return(0); } var axis = ViveInput.GetPadAxisEx(handRole); // パッド座標を極座標に変換 float unitAngle = 360f / (partitionCount - 1); // 前方から外側周り var isClockWise = (lr == HandPoseManager.LR.R); var angleOffset = unitAngle + (isClockWise ? 90 : -90); var polar = new PolarCircular(axis, new PolarContext2(Vector2.zero, angleOffset, isClockWise)).NormalizeAngle(); //Debug.Log("PadAxis: " + axis); //Debug.LogFormat("PadAngle: {0}, {1}", polar.theta, (int)(Mathf.Floor(polar.NormalizeAngle().theta / unitAngle) + 1)); if (polar.r < padCenterSize) { return(0); } else { return((int)Mathf.Floor(polar.theta / unitAngle) + 1); } }
// Update is called once per frame void Update() { if (ViveInput.GetButtonDown(hand, ViveButton.Trigger)) { var numberOfColliders = Physics.OverlapSphereNonAlloc(transform.position, 0.05f, cols, grabLayer); if (numberOfColliders == 0) { return; } var rb = cols[0].GetComponent <Rigidbody>(); if (!rb) { return; } cols[0].gameObject.layer = 0; grabbedBody = rb; grabbedBody.transform.SetParent(transform); grabbedBody.isKinematic = true; grabbedBody.useGravity = false; } else if (ViveInput.GetButtonUp(hand, ViveButton.Trigger)) { if (!grabbedBody) { return; } cols[0].gameObject.layer = LayerMask.NameToLayer("lift"); grabbedBody.transform.SetParent(null); grabbedBody.isKinematic = false; grabbedBody.useGravity = true; grabbedBody.velocity = ViveInput.GetVelocity(hand); grabbedBody.angularVelocity = ViveInput.GetAngularVelocity(hand); grabbedBody = null; } }
protected TouchPadPosition GetTouchPosition() { Vector2 axis = ViveInput.GetPadAxis(m_viveRole); if (axis.x > -0.5 && axis.x < 0.5 && axis.y < 0) { return(TouchPadPosition.Down); } else if (axis.x > -0.5 && axis.x < 0.5 && axis.y > 0) { return(TouchPadPosition.Up); } else if (axis.x < 0 && axis.y < 0.5 && axis.y > -0.5) { return(TouchPadPosition.Left); } else if (axis.x > 0 && axis.y < 0.5 && axis.y > -0.5) { return(TouchPadPosition.Right); } return(TouchPadPosition.Center); }
/// <summary> /// Listener wieder aus der Registrierung /// herausnehmen beim Beenden der Anwendung /// </summary> private void OnDestroy() { ViveInput.RemoveListenerEx(HandRole.RightHand, theButton, ButtonEventType.Down, Con.ToggleHighlight); ViveInput.RemoveListenerEx(HandRole.RightHand, theButton, ButtonEventType.Up, Con.ToggleHighlight); ViveInput.RemoveListenerEx(HandRole.LeftHand, theButton, ButtonEventType.Down, Con.ToggleHighlight); ViveInput.RemoveListenerEx(HandRole.LeftHand, theButton, ButtonEventType.Up, Con.ToggleHighlight); }
public override void StateUpdate() { if (!MRWallManager.instance.CheckUnitStatus() && !playGameOverVideo) { MRWallManager.instance.PlayGameOverVideo(); playGameOverVideo = true; } else if (playGameOverVideo && !GameOverVideoPlayer.instance.isPlaying) { if (ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Trigger) || Input.GetKeyDown(KeyCode.Space)) { if (!prepareExit) { AudioManager.instance.SmoothTurnOffBackGMusic(1f); prepareExit = true; } } if (!AudioManager.instance.isBackGroundMusiPlaying) { stateManager.SetState((int)PaintBallStateManager.PaintBallStateEnum.WAIT_USER_TRIGGER); } } }
IEnumerator Pickup() { while (!(inFocus && !isPlaying && ViveInput.GetPressDown(controllerToSet.controller, ControllerButton.Trigger))) { yield return null; } isPlaying = true; cursor.SetActive(false); clickAudio.Play(0); UnityEvent events = eventList[count]; events.Invoke(); count++; yield return new WaitForSeconds(eventDelay); //if there are multiple events, repeat if (toRepeat || count < limit) { isPlaying = false; StartCoroutine(Pickup()); } }
// Update is called once per frame void Update() { if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.FullTrigger) || ViveInput.GetPress(HandRole.LeftHand, ControllerButton.FullTrigger)) { flying(); } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.Menu)) { if (scene.name == "MainRoom") { Application.Quit(); //Wird genutzt um die Applikation zu beenden, wenn diese aus Unity heraus gestartet wird. #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #endif } else { SceneManager.LoadScene("MainRoom"); } } }
void VivePress() { if (sphereHold) { if (ViveInput.GetPressUp(HandRole.RightHand, ControllerButton.Menu) || ViveInput.GetPressUp(HandRole.LeftHand, ControllerButton.Menu)) { if (!timeUI) { //open timesphere menu shapeMenu.gameObject.SetActive(false); timeMenu.gameObject.SetActive(true); timeUI = true; } else { //open timesphere menu shapeMenu.gameObject.SetActive(false); timeMenu.gameObject.SetActive(false); timeUI = false; } } } }
private void OnTriggerStay(Collider other) { if (other.GetType() == typeof(SphereCollider)) { bool triggerPressed = ViveInput.GetPress(HandRole.RightHand, ControllerButton.Trigger) ^ ViveInput.GetPress(HandRole.LeftHand, ControllerButton.Trigger); // Zusaetzliche Einschraenkung des Interaktionsbereichs auf die Hoehe der Griffe des Steuerrads / Feinabstimmung fuer Steuerrad if (!triggerPressed || Vector3.Distance(otherCollider, transform.position) < .9f || Vector3.Distance(otherCollider, transform.position) > 1.9f) { grabbed = false; deltaAngle = 0f; } else if (triggerPressed && !grabbed) { grabbed = true; oldVector = new Vector3(transform.position.x - otherCollider.x, transform.position.y - otherCollider.y, 0f).normalized; } otherCollider = other.transform.position; } }
public void HandleEvents() { ViveInput left = state_handler.vive_input_left; ViveInput right = state_handler.vive_input_right; // if (left.colliding_object) // { // if (left.colliding_object.tag == "TAGGED") // { // // researching with research hand: // IncreaseBubble(); // points += tagged_points; // point value rep // } // else // { // // incorrect hand for the job // ShrinkBubble(); // points -= sick_points; // point value rep // } // } // if (right.colliding_object) // { // if (right.colliding_object.tag == "SICK") // { // // healing with healing hand: // IncreaseBubble(); // points += sick_points; // point value rep // } // else // { // // incorrect hand for the job // ShrinkBubble(); // points -= tagged_points; // point value rep // } // } }
void Update() { if (ViveInput.GetPressDown(HandRole.LeftHand, ControllerButton.Trigger)) { isActive = !isActive; } if (isActive) { start = transform.GetChild(1).position; forward = transform.GetChild(2).position; Debug.DrawRay(start, transform.GetChild(1).forward *2.5f, Color.green); this.gameObject.GetComponent <LineRenderer>().positionCount = 2; this.gameObject.GetComponent <LineRenderer>().SetPositions(new Vector3[2] { start, forward }); this.gameObject.GetComponent <LineRenderer>().startWidth = 0.05f; this.gameObject.GetComponent <LineRenderer>().endWidth = 0.05f; } else { this.gameObject.GetComponent <LineRenderer>().positionCount = 0; } }
void Update() { if (currentTimeState == TimeState.Invalid && (Input.GetKeyDown(KeyCode.E) || (RaycastScript.interactingObject == door && ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Trigger)))) { currentTimeState = TimeState.Morning; transitionManager.makeTransition(Transition.Intro); } if (currentTimeState == TimeState.Date && (Input.GetKeyDown(KeyCode.A) || ViveInput.GetPressDown(HandRole.LeftHand, ControllerButton.Trigger))) { addToLoveState(currentCharacterId, 20); progressTimeState(); } if (Input.GetKeyDown(KeyCode.X)) { advancetoNextDay(); } if (Input.GetKeyDown(KeyCode.Z)) { progressTimeState(); } }
/// <summary> /// when scaling is actived (The object is grabbed), /// change its scale based on the Y axis value of the joystick /// </summary> void Update() { if (scalingActivated) { float joystickY = 0.0f; switch (handGrabbing) { case joystick.leftHand: joystickY = ViveInput.GetAxisEx(HandRole.LeftHand, ControllerAxis.JoystickY); break; case joystick.rightHand: joystickY = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.JoystickY); break; case joystick.none: Debug.Log("Scaling error: no trigger press, grabbed with another button?"); break; } gameObject.transform.localScale *= (1 + scalingFactor * joystickY); } }
void Update() { if (RaycastScript.minigameObject == gameObject && !isAttached && ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Trigger)) { attachToController(); } else if (isAttached && ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Trigger)) { detachFromController(); } if (isAttached) { updatePositionWhenAttached(); } if (timeSinceLastUpdate >= 0.1f) { previousPosition = transform.position; timeSinceLastUpdate = 0; } timeSinceLastUpdate += Time.deltaTime; }
// Update is called once per frame void Update() { RaycastHit hit; if (ViveInput.GetButtonState(ViveHand.Left, ViveButton.Trigger)) { line.enabled = true; if (Physics.Raycast(transform.position, transform.forward, out hit)) { line.SetPosition(1, new Vector3(0f, 0f, hit.distance)); } else { line.SetPosition(1, new Vector3(0f, 0f, 100f)); } } if (ViveInput.GetButtonUp(ViveHand.Left, ViveButton.Trigger)) { line.enabled = false; if (Physics.Raycast(transform.position, transform.forward, out hit)) { var btn = hit.collider.gameObject.GetComponent <Button>(); if (btn) { btn.onClick.Invoke(); } var MeshRendererfound = hit.collider.gameObject.GetComponent <MeshRenderer> (); if (MeshRendererfound) { MeshRendererfound.material = Material_Singletone.Instance.SelectMaterial; } } } }
public static ViveInput GetInstance() { if (inst != null) { return(inst); } inst = FindObjectOfType <ViveInput>(); if (inst != null) { return(inst); } var gObj = GameObject.Find("GlobalScripts"); if (gObj == null) { gObj = new GameObject("GlobalScripts"); gObj.transform.SetSiblingIndex(0); } inst = gObj.AddComponent <ViveInput>(); return(inst); }
public void UpdateState() { //1: select [scan] | [load] ,2:[saving], 3:[loading], 0: select wall done, 4: [scanning], 5: [Select wall] if (scanningProgress == 0) { return; } bool padpress = ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Pad); bool triggerpress = ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Trigger); if (scanningProgress == 1)//select [scan] | [load] { GameManager.Instance.EnableInfoText(true); if (triggerpress) { SRWorkControl.Instance.SetScanning(true); scanningProgress = 4; } else if (padpress || Input.GetKeyUp(KeyCode.A) ) { if (StartLoadReconstructData()) { scanningProgress = 3; } else { GameManager.Instance.ShowInfoTextAni("<line-height=150%><b><size=120%>None scanned data!\n<line-height=80%><size=100%>Press <color=#FFC000FF>Trigger</b>\n<color=white><size=80%>to start scanning room"); } } } else if (scanningProgress == 2)//[saving] { //eyeInfoText.text = "Saving..." + savingPercent + "%"; } else if (scanningProgress == 3)//[loading] { loadingDotTime += Time.deltaTime; if (loadingDotTime > 0.2f) { loadingDotTime = 0; int dotcount = 0; string sss = GameManager.Instance.GetInfoText(); foreach (char c in sss) { if (c == '.') { dotcount++; } } if (dotcount % 30 == 0) { sss += "\r\n"; } sss += '.'; GameManager.Instance.SetInfoText(sss); } } else if (scanningProgress == 4)//[scanning] { GameManager.Instance.ShowInfoTextAni("<size=120%><b>Please look around to scanning...<line-height=150%><size=100%>\nPress <color=#FFC000FF>Pad</b><line-height=80%><color=white><size=80%> :\nto save scene<b><line-height=150%><size=100%>\nPress <color=#FFC000FF>Trigger</b><line-height=80%><color=white><size=80%> :\nto cancel scanning"); if (padpress) { SRWorkControl.Instance.SaveScanning( (percentage) => { GameManager.Instance.ShowInfoTextAni("<b>Saving...<color=#FFC000FF><size=120%>" + percentage + "%"); }, () => { //save done then load... StartLoadReconstructData(); scanningProgress = 3; } ); scanningProgress = 2; } else if (triggerpress) { SRWorkControl.Instance.SetScanning(false); scanningProgress = 1; GameManager.Instance.infoTextStart(); } } else if (scanningProgress == 5) { if (ReconstructManager.Instance.reconstructDataAnalyzeDone) { manager.SwitchState(GameStateManager.GameState.SELECTWALL); } } }
void OnDestroy() { inst = null; }
// Update is called once per frame void Update() { isPressedR = ViveInput.GetPress(HandRole.RightHand, ControllerButton.Trigger); isPressedL = ViveInput.GetPress(HandRole.LeftHand, ControllerButton.Trigger); }
private void Update() { if (m_updateDynamically) { #if (VIU_OCULUSVR_1_32_0_OR_NEWER || VIU_OCULUSVR_1_36_0_OR_NEWER || VIU_OCULUSVR_1_37_0_OR_NEWER) && VIU_OCULUSVR_AVATAR if (sdkAvatar == IntPtr.Zero) { return; } if (m_deviceIndex == LEFT_INDEX) { inputStateLeft.transform.position = transform.position; inputStateLeft.transform.orientation = transform.rotation; inputStateLeft.transform.scale = transform.localScale; inputStateLeft.buttonMask = 0; inputStateLeft.touchMask = ovrAvatarTouch.Pointing | ovrAvatarTouch.ThumbUp; if (ViveInput.GetPress(HandRole.LeftHand, ControllerButton.AKey)) { inputStateLeft.buttonMask |= ovrAvatarButton.One; } if (ViveInput.GetPress(HandRole.LeftHand, ControllerButton.BKey)) { inputStateLeft.buttonMask |= ovrAvatarButton.Two; } if (ViveInput.GetPress(HandRole.LeftHand, ControllerButton.System)) { inputStateLeft.buttonMask |= ovrAvatarButton.Three; } if (ViveInput.GetPress(HandRole.LeftHand, ControllerButton.Pad)) { inputStateLeft.buttonMask |= ovrAvatarButton.Joystick; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.AKeyTouch)) { inputStateLeft.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateLeft.touchMask |= ovrAvatarTouch.One; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.BkeyTouch)) { inputStateLeft.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateLeft.touchMask |= ovrAvatarTouch.Two; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.PadTouch)) { inputStateLeft.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateLeft.touchMask |= ovrAvatarTouch.Joystick; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.TriggerTouch)) { inputStateLeft.touchMask &= ~ovrAvatarTouch.Pointing; inputStateLeft.touchMask |= ovrAvatarTouch.Index; } inputStateLeft.joystickX = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.JoystickX); inputStateLeft.joystickY = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.JoystickY); inputStateLeft.indexTrigger = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.Trigger); inputStateLeft.handTrigger = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.CapSenseGrip); inputStateLeft.isActive = true; } else if (m_deviceIndex == RIGHT_INDEX) { inputStateRight.transform.position = transform.position; inputStateRight.transform.orientation = transform.rotation; inputStateRight.transform.scale = transform.localScale; inputStateRight.buttonMask = 0; inputStateRight.touchMask = ovrAvatarTouch.Pointing | ovrAvatarTouch.ThumbUp; if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.AKey)) { inputStateRight.buttonMask |= ovrAvatarButton.One; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.BKey)) { inputStateRight.buttonMask |= ovrAvatarButton.Two; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.Pad)) { inputStateRight.buttonMask |= ovrAvatarButton.Joystick; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.AKeyTouch)) { inputStateRight.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateRight.touchMask |= ovrAvatarTouch.One; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.BkeyTouch)) { inputStateRight.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateRight.touchMask |= ovrAvatarTouch.Two; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.PadTouch)) { inputStateRight.touchMask &= ~ovrAvatarTouch.ThumbUp; inputStateRight.touchMask |= ovrAvatarTouch.Joystick; } if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.TriggerTouch)) { inputStateRight.touchMask &= ~ovrAvatarTouch.Pointing; inputStateRight.touchMask |= ovrAvatarTouch.Index; } inputStateRight.joystickX = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.JoystickX); inputStateRight.joystickY = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.JoystickY); inputStateRight.indexTrigger = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.Trigger); inputStateRight.handTrigger = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.CapSenseGrip); inputStateRight.isActive = true; } CAPI.ovrAvatarPose_UpdateHandsWithType(sdkAvatar, inputStateLeft, inputStateRight, m_controllerType); CAPI.ovrAvatarPose_Finalize(sdkAvatar, Time.deltaTime); #endif UpdateComponents(); #if VIU_OCULUSVR_1_37_0_OR_NEWER && VIU_OCULUSVR_AVATAR if (m_deviceIndex == LEFT_INDEX) { ovrAvatarControllerComponent component = new ovrAvatarControllerComponent(); if (CAPI.ovrAvatarPose_GetLeftControllerComponent(sdkAvatar, ref component)) { UpdateAvatarComponent(component.renderComponent); } } else if (m_deviceIndex == RIGHT_INDEX) { ovrAvatarControllerComponent component = new ovrAvatarControllerComponent(); if (CAPI.ovrAvatarPose_GetRightControllerComponent(sdkAvatar, ref component)) { UpdateAvatarComponent(component.renderComponent); } } #endif } }
ulong ConvertString(string action) { ViveInput input = GetInputFor(action); return(Decode(input)); }
protected virtual void LateUpdate() { var needUpdate = false; switch (laserPointerActiveMode) { case LaserPointerActiveModeEnum.None: needUpdate |= SetRightLaserPointerActive(false); needUpdate |= SetLeftLaserPointerActive(false); break; case LaserPointerActiveModeEnum.ToggleByMenuClick: if (ViveInput.GetPressUpEx(HandRole.RightHand, ControllerButton.Menu)) { ToggleRightLaserPointer(); needUpdate = true; } if (ViveInput.GetPressUpEx(HandRole.LeftHand, ControllerButton.Menu)) { ToggleLeftLaserPointer(); needUpdate = true; } break; } switch (curvePointerActiveMode) { case CurvePointerActiveModeEnum.None: needUpdate |= SetRightCurvePointerActive(false); needUpdate |= SetLeftCurvePointerActive(false); break; case CurvePointerActiveModeEnum.ActiveOnPadPressed: needUpdate |= SetRightCurvePointerActive(ViveInput.GetPressEx(HandRole.RightHand, ControllerButton.Pad)); needUpdate |= SetLeftCurvePointerActive(ViveInput.GetPressEx(HandRole.LeftHand, ControllerButton.Pad)); break; case CurvePointerActiveModeEnum.ToggleByPadDoubleClick: if (ViveInput.GetPressDownEx(HandRole.RightHand, ControllerButton.Pad) && ViveInput.ClickCountEx(HandRole.RightHand, ControllerButton.Pad) == 2) { ToggleRightCurvePointer(); needUpdate = true; } if (ViveInput.GetPressDownEx(HandRole.LeftHand, ControllerButton.Pad) && ViveInput.ClickCountEx(HandRole.LeftHand, ControllerButton.Pad) == 2) { ToggleLeftCurvePointer(); needUpdate = true; } break; } switch (customModelActiveMode) { case CustomModelActiveModeEnum.None: needUpdate |= ChangeProp.Set(ref m_rightCustomModelActive, false); needUpdate |= ChangeProp.Set(ref m_leftCustomModelActive, false); break; case CustomModelActiveModeEnum.ActiveOnGripped: needUpdate |= SetRightCustomModelActive(ViveInput.GetPressEx(HandRole.RightHand, ControllerButton.Grip)); needUpdate |= SetLeftCustomModelActive(ViveInput.GetPressEx(HandRole.LeftHand, ControllerButton.Grip)); break; case CustomModelActiveModeEnum.ToggleByDoubleGrip: if (ViveInput.GetPressDownEx(HandRole.RightHand, ControllerButton.Grip) && ViveInput.ClickCountEx(HandRole.RightHand, ControllerButton.Grip) == 2) { ToggleRightCustomModel(); needUpdate = true; } if (ViveInput.GetPressDownEx(HandRole.LeftHand, ControllerButton.Grip) && ViveInput.ClickCountEx(HandRole.LeftHand, ControllerButton.Grip) == 2) { ToggleLeftCustomModel(); needUpdate = true; } break; } if (needUpdate) { UpdateActivity(); } }
// Update is called once per frame void Update() { right_blood = mainfall02.right_blood; left_blood = mainfall02.left_blood; //抓取判斷 if (ViveInput.GetPress(HandRole.RightHand, ControllerButton.Grip)) { rightHandGrip = true; } else { rightHandGrip = false; } if (ViveInput.GetPress(HandRole.LeftHand, ControllerButton.Grip)) { leftHandGrip = true; } else { leftHandGrip = false; } //右手 //血量判斷 if (rightHandGrip && right_blood >= 0 && Vector3.Distance(rightPos.position, stonePos.position) <= 0.2f) { //right_blood = right_blood - 0.1f; gamestart = true; this.transform.position = rightPos.position; wall.transform.position = this.transform.position + pos; grabsomething = true; mainfall02.r_cost = true; // mainfall02.gamestart = true; //支點與手距離判定 /* * if (Vector3.Distance(rightPos.position, stonePos.position)<=0.2f) * { * this.transform.position = rightPos.position; * wall.transform.position = this.transform.position + pos; * //grabsomething = true; * fall.GetComponent<fall02>().r_cost = true; * } * else * { * //grabsomething = false; * fall.GetComponent<fall02>().r_cost = false; * * }*/ } else { //mainfall02.r_cost = false; grabsomething = false; this.transform.position = wall.transform.position - pos; //right_blood = right_blood +0.03f; } //左手 if (leftHandGrip && left_blood >= 0 && Vector3.Distance(leftPos.position, stonePos.position) <= 0.2f) { //left_blood = left_blood - 0.1f; gamestart = true; //支點與手距離判定 this.transform.position = leftPos.position; wall.transform.position = this.transform.position + pos; //grabsomething = true; mainfall02.l_cost = true; /* * if (Vector3.Distance(leftPos.position, stonePos.position) <= 0.2f) * { * this.transform.position = leftPos.position; * wall.transform.position = this.transform.position + pos; * //grabsomething = true; * mainfall02.l_cost = true; * } * else * { * //grabsomething = false; * fall.GetComponent<fall02>().l_cost = false; * this.transform.position = wall.transform.position - pos; * }*/ } else { //fall.GetComponent<fall02>().l_cost = false; this.transform.position = wall.transform.position - pos; } //固定相對位置 }
float GetY() { return(ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.PadY)); }
// Update is called once per frame void Update() { if (ViveInput.GetTouchDown(Controller.Right, ButtonMask.Trigger)) { Debug.Log("右コントローラのトリガーを浅く引いた"); } if (ViveInput.GetPressDown(Controller.Right, ButtonMask.Trigger)) { Debug.Log("右コントローラのトリガーを深く引いた"); } if (ViveInput.GetTouchUp(Controller.Right, ButtonMask.Trigger)) { Debug.Log("右コントローラのトリガーを離した"); } if (ViveInput.GetPressDown(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドをクリックした"); } if (ViveInput.GetPress(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドをクリックしている"); } if (ViveInput.GetPressUp(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドをクリックして離した"); } if (ViveInput.GetTouchDown(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドに触った"); } if (ViveInput.GetTouchUp(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドを離した"); } if (ViveInput.GetPressDown(Controller.Right, ButtonMask.ApplicationMenu)) { Debug.Log("右コントローラのメニューボタンをクリックした"); } if (ViveInput.GetPressDown(Controller.Right, ButtonMask.Grip)) { Debug.Log("右コントローラのグリップボタンをクリックした"); } if (ViveInput.GetTouch(Controller.Right, ButtonMask.Trigger)) { Debug.Log("右コントローラのトリガーを浅く引いている"); } if (ViveInput.GetPress(Controller.Right, ButtonMask.Trigger)) { Debug.Log("右コントローラのトリガーを深く引いている"); } if (ViveInput.GetTouch(Controller.Right, ButtonMask.Touchpad)) { Debug.Log("右コントローラのタッチパッドに触っている"); } if (ViveInput.GetTouchDown(Controller.Left, ButtonMask.Trigger)) { Debug.Log("左コントローラのトリガーを浅く引いた"); } if (ViveInput.GetPressDown(Controller.Left, ButtonMask.Trigger)) { Debug.Log("左コントローラのトリガーを深く引いた"); } if (ViveInput.GetTouchUp(Controller.Left, ButtonMask.Trigger)) { Debug.Log("左コントローラのトリガーを離した"); } if (ViveInput.GetPressDown(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドをクリックした"); } if (ViveInput.GetPress(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドをクリックしている"); } if (ViveInput.GetPressUp(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドをクリックして離した"); } if (ViveInput.GetTouchDown(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドに触った"); } if (ViveInput.GetTouchUp(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドを離した"); } if (ViveInput.GetPressDown(Controller.Left, ButtonMask.ApplicationMenu)) { Debug.Log("左コントローラのメニューボタンをクリックした"); } if (ViveInput.GetPressDown(Controller.Left, ButtonMask.Grip)) { Debug.Log("左コントローラのグリップボタンをクリックした"); } if (ViveInput.GetTouch(Controller.Left, ButtonMask.Trigger)) { Debug.Log("左コントローラのトリガーを浅く引いている"); } if (ViveInput.GetPress(Controller.Left, ButtonMask.Trigger)) { Debug.Log("左コントローラのトリガーを深く引いている"); } if (ViveInput.GetTouch(Controller.Left, ButtonMask.Touchpad)) { Debug.Log("左コントローラのタッチパッドに触っている"); } //Debug.Log(ViveInput.GetTriggerValue(Controller.Right)); //Debug.Log(ViveInput.GetTouchPos(Controller.Right)); }
IEnumerator RecordSize() { while (isSync) { yield return(null); if (ViveInput.GetTriggerValue(HandRole.LeftHand) == 1 && ViveInput.GetTriggerValue(HandRole.RightHand) == 1 && Time.time - startTime < 3) { lengthOfHead.Add((waist.GetPosition(6) - leftHand.GetPosition(1)) * 100); lengthOfLH.Add((waist.GetPosition(6) - leftHand.GetPosition(2)) * 100); lengthOfRH.Add((waist.GetPosition(6) - leftHand.GetPosition(3)) * 100); lengthOfLF.Add((waist.GetPosition(6) - leftHand.GetPosition(4)) * 100); lengthOfRF.Add((waist.GetPosition(6) - leftHand.GetPosition(5)) * 100); Vector3 temp = waist.GetRotation(6) - leftHand.GetRotation(1); temp.x = Mathf.Abs(temp.x); temp.y = Mathf.Abs(temp.y); temp.z = Mathf.Abs(temp.z); rotationOfHead.Add(temp); temp = waist.GetRotation(6) - leftHand.GetRotation(2); temp.x = Mathf.Abs(temp.x); temp.y = Mathf.Abs(temp.y); temp.z = Mathf.Abs(temp.z); rotationOfLH.Add(temp); temp = waist.GetRotation(6) - leftHand.GetRotation(3); temp.x = Mathf.Abs(temp.x); temp.y = Mathf.Abs(temp.y); temp.z = Mathf.Abs(temp.z); rotationOfRH.Add(temp); temp = waist.GetRotation(6) - leftHand.GetRotation(4); temp.x = Mathf.Abs(temp.x); temp.y = Mathf.Abs(temp.y); temp.z = Mathf.Abs(temp.z); rotationOfLF.Add(temp); temp = waist.GetRotation(6) - leftHand.GetRotation(5); temp.x = Mathf.Abs(temp.x); temp.y = Mathf.Abs(temp.y); temp.z = Mathf.Abs(temp.z); rotationOfRF.Add(temp); } else if (ViveInput.GetTriggerValue(HandRole.LeftHand) == 1 && ViveInput.GetTriggerValue(HandRole.RightHand) == 1 && Time.time - startTime >= 3) { Vector3 avgOfHead = new Vector3(0, 0, 0); foreach (Vector3 value in lengthOfHead) { avgOfHead += value; } avgOfHead /= lengthOfHead.Count; Vector3 avgOfLH = new Vector3(0, 0, 0); foreach (Vector3 value in lengthOfLH) { avgOfLH += value; } avgOfLH /= lengthOfLH.Count; Vector3 avgOfRH = new Vector3(0, 0, 0); foreach (Vector3 value in lengthOfRH) { avgOfRH += value; } avgOfRH /= lengthOfRH.Count; Vector3 avgOfLF = new Vector3(0, 0, 0); foreach (Vector3 value in lengthOfLF) { avgOfLF += value; } avgOfLF /= lengthOfLF.Count; Vector3 avgOfRF = new Vector3(0, 0, 0); foreach (Vector3 value in lengthOfRF) { avgOfRF += value; } avgOfRF /= lengthOfRF.Count; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Vector3 avgOfRoHead = new Vector3(0, 0, 0); foreach (Vector3 value in rotationOfHead) { avgOfRoHead += value; } avgOfRoHead /= rotationOfHead.Count; Vector3 avgOfRoLH = new Vector3(0, 0, 0); foreach (Vector3 value in rotationOfLH) { avgOfRoLH += value; } avgOfRoLH /= rotationOfLH.Count; Vector3 avgOfRoRH = new Vector3(0, 0, 0); foreach (Vector3 value in rotationOfRH) { avgOfRoRH += value; } avgOfRoRH /= rotationOfRH.Count; Vector3 avgOfRoLF = new Vector3(0, 0, 0); foreach (Vector3 value in rotationOfLF) { avgOfRoLF += value; } avgOfRoLF /= rotationOfLF.Count; Vector3 avgOfRoRF = new Vector3(0, 0, 0); foreach (Vector3 value in rotationOfRF) { avgOfRoRF += value; } avgOfRoRF /= rotationOfRF.Count; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Debug.Log("호성이 머리좌표 : " + avgOfHead + ", 머리 기울기 : " + avgOfRoHead); Debug.Log("호성이 왼손좌표 : " + avgOfLH + ", 왼손 기울기 : " + avgOfRoLH); Debug.Log("호성이 오른손좌표 : " + avgOfRH + ", 오른손 기울기 : " + avgOfRoRH); Debug.Log("호성이 왼발좌표 : " + avgOfLF + ", 왼발 기울기 : " + avgOfRoLF); Debug.Log("호성이 오른발좌표 : " + avgOfRF + ", 오른발 기울기 : " + avgOfRoRF); string sh, slh, srh, slf, srf; sh = "head\t" + avgOfHead.x.ToString("0.00") + "\t" + avgOfHead.y.ToString("0.00") + "\t" + avgOfHead.z.ToString("0.00") + "\t" + avgOfRoHead.x.ToString("0.00") + "\t" + avgOfRoHead.y.ToString("0.00") + "\t" + avgOfRoHead.z.ToString("0.00"); slh = "lh\t" + avgOfLH.x.ToString("0.00") + "\t" + avgOfLH.y.ToString("0.00") + "\t" + avgOfLH.z.ToString("0.00") + "\t" + avgOfRoLH.x.ToString("0.00") + "\t" + avgOfRoLH.y.ToString("0.00") + "\t" + avgOfRoLH.z.ToString("0.00"); srh = "rh\t" + avgOfRH.x.ToString("0.00") + "\t" + avgOfRH.y.ToString("0.00") + "\t" + avgOfRH.z.ToString("0.00") + "\t" + avgOfRoRH.x.ToString("0.00") + "\t" + avgOfRoRH.y.ToString("0.00") + "\t" + avgOfRoRH.z.ToString("0.00"); slf = "lf\t" + avgOfLF.x.ToString("0.00") + "\t" + avgOfLF.y.ToString("0.00") + "\t" + avgOfLF.z.ToString("0.00") + "\t" + avgOfRoLF.x.ToString("0.00") + "\t" + avgOfRoLF.y.ToString("0.00") + "\t" + avgOfRoLF.z.ToString("0.00"); srf = "rf\t" + avgOfRF.x.ToString("0.00") + "\t" + avgOfRF.y.ToString("0.00") + "\t" + avgOfRF.z.ToString("0.00") + "\t" + avgOfRoRF.x.ToString("0.00") + "\t" + avgOfRoRF.y.ToString("0.00") + "\t" + avgOfRoRF.z.ToString("0.00"); if (!Directory.Exists(Application.dataPath + "/Resources/Transforms/RecordData/")) { Directory.CreateDirectory(Application.dataPath + "/Resources/Transforms/RecordData/"); } // File.Create(Application.dataPath + "/Resources/Transforms/RecordData/" + fileName + ".txt"); FileStream fs = new FileStream(Application.dataPath + "/Resources/Transforms/RecordData/record.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.Unicode); writer.WriteLine("Device\tIndex\tPosX\tPosY\tPosZ\tRotX\tRotY\tRotZ\tTime"); writer.WriteLine(sh); writer.WriteLine(slh); writer.WriteLine(srh); writer.WriteLine(slf); writer.WriteLine(srf); writer.Close(); dataManager = DataManager.GetInstance(); dataManager.SetUserLengthInfo(Mathf.Abs(avgOfHead.y), Pytha(avgOfLH.x, avgOfLH.z), Pytha(avgOfRH.x, avgOfRH.z), Mathf.Abs(avgOfLF.y), Mathf.Abs(avgOfRF.y)); float[] tempLength = dataManager.GetUserLengthInfo(); head.SetUserSize(tempLength[0]); leftHand.SetUserSize(tempLength[1]); rightHand.SetUserSize(tempLength[2]); leftFoot.SetUserSize(tempLength[3]); rightFoot.SetUserSize(tempLength[4]); ExitVRSync(); isSync = false; } else { lengthOfHead.Clear(); lengthOfLH.Clear(); lengthOfRH.Clear(); lengthOfLF.Clear(); lengthOfRF.Clear(); startTime = Time.time; } slider.GetComponent <Slider>().value = (float)(Time.time - startTime); } }
private void Start() { ViveInput.AddListenerEx( minimapActivatorHandRole, minimapActivatorControllerButton, ButtonEventType.Click, __onMinimapActive); }