// Update is called once per frame void Update() { if (clickMove.GetState(handtype) && clickAxis.GetLastAxis(handtype).y > 0) { counter += 50; Debug.Log(counter); //Debug.Log() } if (clickMove.GetState(handtype) && clickAxis.GetLastAxis(handtype).y < 0) { counter += 5; Debug.Log(counter); //Debug.Log() } //if(moveUser2.GetLastAxis(handtype).y > 0) //{ // counter++; // Debug.Log(counter); //} //Debug.Log(moveUser2.GetLastAxis(handtype).y); }
// Update is called once per frame void Update() { //Change seabed using VR if ((clickMove.GetLastStateDown(handtype) && clickAxis.GetLastAxis(handtype).y < 0) || Input.GetKeyDown(KeyCode.DownArrow)) { if (nActualSeaBed > 0) { nActualSeaBed--; seaBed.GetComponent <MeshFilter>().mesh = seaBeds[nActualSeaBed]; imageVR.sprite = seaBedMaps[nActualSeaBed]; imageFS.sprite = seaBedMaps[nActualSeaBed]; dataTimeTextVR.text = "Year: " + (GetComponent <TimeChange>().years[nActualSeaBed]).ToString(); dataTimeTextFS.text = "Year: " + (GetComponent <TimeChange>().years[nActualSeaBed]).ToString(); } } //Change seabed using Flat Screens if ((clickMove.GetLastStateDown(handtype) && clickAxis.GetLastAxis(handtype).y > 0) || Input.GetKeyDown(KeyCode.UpArrow)) { if (nActualSeaBed < seaBeds.Length - 1) { nActualSeaBed++; seaBed.GetComponent <MeshFilter>().mesh = seaBeds[nActualSeaBed]; imageVR.sprite = seaBedMaps[nActualSeaBed]; imageFS.sprite = seaBedMaps[nActualSeaBed]; dataTimeTextVR.text = "Year: " + (GetComponent <TimeChange>().years[nActualSeaBed]).ToString(); dataTimeTextFS.text = "Year: " + (GetComponent <TimeChange>().years[nActualSeaBed]).ToString(); } } }
void Update() { //트랙패드를 클릭했을 경우 if (trackPad.GetStateDown(leftHand)) { Debug.Log("왼쪽 트랙패드 클릭"); //트랙패드의 터치 위치값을 추출 Vector2 touchPos = trackPadPosition.GetLastAxis(leftHand); Debug.Log(touchPos); if (touchPos.x >= 0.2f) { Debug.Log("왼쪽 트랙패드의 오른쪽 클릭"); //트랙패드의 오른쪽 부분을 터치했을 경우 //90도씩 회전값을 누적해 감소 // iTween.RotateTo(this.gameObject, iTween.Hash("rotation",new Vector3(0,-90.0f,0), "time", 0.2f, "easetype", iTween.EaseType.easeOutBounce)); iTween.RotateBy(this.gameObject, iTween.Hash("y", -0.25f, "time", 0.2f, "easetype", iTween.EaseType.easeOutBounce)); } else if (touchPos.x <= -0.2f) { Debug.Log("왼쪽 트랙패드의 왼쪽 클릭"); //트랙패드의 왼쪽 부분을 터치했을 경우 //90도씩 회전값을 누적해 증가 // iTween.RotateTo(this.gameObject, iTween.Hash("rotation", new Vector3(0,-90.0f,0), "time", 0.2f , "easetype" , iTween.EaseType.easeOutBounce)); iTween.RotateBy(this.gameObject, iTween.Hash("y", 0.25f, "time", 0.2f, "easetype", iTween.EaseType.easeOutBounce)); } } }
// Update is called once per frame void Update() { //Sets input values based on trackpad inputs TrackpadValueRight = trackpadAction.GetAxis(SteamVR_Input_Sources.RightHand); TrackpadValueLeft = trackpadAction.GetAxis(SteamVR_Input_Sources.LeftHand); trackpadLastValueLeft = trackpadAction.GetLastAxis(SteamVR_Input_Sources.LeftHand); TrackpackLeftChange = trackpadAction.GetAxisDelta(SteamVR_Input_Sources.LeftHand); if (TrackpadValueLeft == Vector2.zero && trackpadLastValueLeft != Vector2.zero) { TrackpackLeftChange = Vector2.zero; } //Trigger pulled //TODO verify binding if (SteamVR_Input._default.inActions.GrabPinch.GetStateDown(SteamVR_Input_Sources.Any)) { if (CollidedButton) { CollidedButton.onClick.Invoke(); } if (CollidedObject) { //Move window connectedMediaWindow = CollidedObject.gameObject.GetComponent <MediaWindow>(); connectedMediaWindow.WindowPickup(); } } if (SteamVR_Input._default.inActions.GrabPinch.GetStateUp(SteamVR_Input_Sources.Any)) { if (connectedMediaWindow) { Debug.Log("release"); //Move window connectedMediaWindow.WindowRelease(); } } }
// Update is called once per frame void Update() { //Change the salinity with years - for VR if ((clickMove.GetLastStateDown(handtype) && clickAxis.GetLastAxis(handtype).y < 0) || Input.GetKeyDown(KeyCode.DownArrow)) { if (nActualYear > 0) { nActualYear--; dataTimeText.text = "Year: " + (years[nActualYear]).ToString(); freshWater.transform.localScale = new Vector3(xInitialProportion * freshWaterProportions[nActualYear], freshWater.transform.localScale.y, freshWater.transform.localScale.z); print(years[nActualYear]); CreateSalinityDivisions(nActualYear); if (areSalinityPointsVisible) { HideSalinityDivisions(false); } else { HideSalinityDivisions(true); } StartCoroutine(WaitRespawn()); } } //Change the salinity with years for Flat Screens if ((clickMove.GetLastStateDown(handtype) && clickAxis.GetLastAxis(handtype).y > 0) || Input.GetKeyDown(KeyCode.UpArrow)) { if (nActualYear < years.Length - 1) { nActualYear++; dataTimeText.text = "Year: " + (years[nActualYear]).ToString(); freshWater.transform.localScale = new Vector3(xInitialProportion * freshWaterProportions[nActualYear], freshWater.transform.localScale.y, freshWater.transform.localScale.z); print(years[nActualYear]); CreateSalinityDivisions(nActualYear); if (areSalinityPointsVisible) { HideSalinityDivisions(false); } else { HideSalinityDivisions(true); } StartCoroutine(WaitRespawn()); } } //Hide or show freshwater if (Input.GetKeyDown(KeyCode.N) || clickGrip.GetLastStateDown(handtype)) { if (areSalinityPointsVisible) { HideSalinityDivisions(true); areSalinityPointsVisible = false; } else { HideSalinityDivisions(false); areSalinityPointsVisible = true; } } }
private void Update() { uiContainer.transform.LookAt(Camera.main.transform); if (lastTargetedClayObject != null) { MeshRenderer meshRenderer = lastTargetedClayObject.GetComponent <MeshRenderer>(); meshRenderer.enabled = false; lastTargetedClayObject.transform.hasChanged = true; lastTargetedClayObject = null; } GameObject targetObject = null; ClayObject targetedClayObject = null; // NOTE(Juan): Tool selection Vector2 lastJoystickAxis = joystickVector.GetLastAxis(inputSource); bool toolSelectionEnabled = grabed == null && lastJoystickAxis.magnitude > 0.5f; if (grabed == null) { for (int toolIndex = 0; toolIndex < toolCount; ++toolIndex) { toolSprites[toolIndex].gameObject.SetActive(toolSelectionEnabled); } if (!toolSelectionEnabled && justSelectedTool) { justSelectedTool = false; ChangeTool(selectedTool); } if (toolSelectionEnabled) { float toolSelectionDelta = Mathf.PI * 2f / toolCount; toolSelector.transform.localPosition = new Vector3(lastJoystickAxis.x * TOOL_SELECTOR_SIZE, lastJoystickAxis.y * TOOL_SELECTOR_SIZE, 0); float angle = Angle(lastJoystickAxis); int selectedToolIndex = Mathf.RoundToInt(angle / toolSelectionDelta) % toolCount; for (int toolIndex = 0; toolIndex < toolCount; ++toolIndex) { toolSprites[toolIndex].transform.localScale = Vector3.one * (toolIndex == selectedToolIndex ? SELECTED_TOOL_SCALE : DESELECTED_TOOL_SCALE); toolSprites[toolIndex].color = (toolIndex == selectedToolIndex ? SELECTED_TOOL_COLOR : DESELECTED_TOOL_COLOR); } selectedTool = (ClayVRTool)selectedToolIndex; toolText.text = selectedTool.ToString(); justSelectedTool = true; } else { toolSelector.transform.localPosition = Vector3.zero; } float maxDistance = raycastLength; RaycastHit[] hitResults = new RaycastHit[10]; int hitCount = Physics.SphereCastNonAlloc(new Ray(raycastPoint.transform.position, raycastPoint.transform.forward), raycastRadius, hitResults, maxDistance, ClayVR.instance.objectLayerMask); if (hitCount > 0) { float closestDistance = maxDistance * 10f; for (int i = 0; i < hitCount; ++i) { float tempDistance = Vector3.Distance(hitResults[i].transform.position, raycastPoint.transform.position); if (tempDistance < closestDistance) { targetObject = hitResults[i].transform.gameObject; } } targetedClayObject = targetObject.GetComponent <ClayObject>(); if (targetedClayObject != null) { targetedClayObject.transform.hasChanged = true; } lastTargetedClayObject = targetedClayObject; MeshRenderer meshRenderer = lastTargetedClayObject.GetComponent <MeshRenderer>(); meshRenderer.enabled = true; meshRenderer.material = ClayVR.instance.highlightMaterial; } } else { MeshRenderer meshRenderer = grabed.GetComponent <MeshRenderer>(); meshRenderer.enabled = true; meshRenderer.material = ClayVR.instance.grabbedMaterial; } if (grabGrip.GetLastStateDown(inputSource) && grabed == null) { if (targetedClayObject != null) { originalGrabParent = targetObject.transform.parent; if (originalGrabParent.GetComponent <ClayContainer>()) { targetedClayObject.steppedUpdate = .1f; grabed = targetedClayObject; if (currentTool == ClayVRTool.MOVE) { grabed.transform.SetParent(transform); } } } } if (grabGrip.GetLastStateUp(inputSource) && grabed != null) { if (currentTool == ClayVRTool.MOVE) { grabed.transform.SetParent(originalGrabParent); } grabed.steppedUpdate = 0; grabed.transform.hasChanged = true; grabed = null; } Vector3 rootPosition = transform.position; Vector3 rootDelta = (rootPosition - lastRootPositon) * TOOL_SENSIBILITY; lastRootPositon = rootPosition; toolText.color = Color.white; colorPicker.SetActive(!toolSelectionEnabled && currentTool == ClayVRTool.COLOR); if (grabed) { Vector3 toolDelta = grabed.transform.InverseTransformDirection(rootDelta); if (currentTool == ClayVRTool.SCALE) { Vector3 scale = grabed.transform.localScale; scale.x = Mathf.Abs(scale.x + toolDelta.x); scale.y = Mathf.Abs(scale.y + toolDelta.y); scale.z = Mathf.Abs(scale.z + toolDelta.z); grabed.transform.localScale = scale; } else if (currentTool == ClayVRTool.BLEND) { grabed.blend = Mathf.Clamp(grabed.blend + toolDelta.y, -1, 1); toolText.text = currentTool.ToString() + "\n" + grabed.blend.ToString("0.00"); } else if (currentTool == ClayVRTool.PRIMITIVE) { if (interactButton.GetLastStateDown(inputSource)) { grabed.primitiveType = (grabed.primitiveType + 1) % 4; grabed.transform.hasChanged = true; } if ((ClayVRPrimitive)grabed.primitiveType == ClayVRPrimitive.CUBE) { grabed.attrs.x = Mathf.Clamp(grabed.attrs.x + toolDelta.x, -1, 1); toolText.text = currentTool.ToString() + "\n" + ((ClayVRPrimitive)grabed.primitiveType).ToString() + "\n" + string.Format("Round: {0}", grabed.attrs.x.ToString("0.00")); } else if ((ClayVRPrimitive)grabed.primitiveType == ClayVRPrimitive.CYLINDER) { grabed.attrs.x = Mathf.Clamp(grabed.attrs.x + toolDelta.x, -1, 1); grabed.attrs.y = Mathf.Clamp(grabed.attrs.y + toolDelta.y, -1, 1); grabed.attrs.z = Mathf.Clamp(grabed.attrs.z + toolDelta.z, -1, 1); toolText.text = currentTool.ToString() + "\n" + ((ClayVRPrimitive)grabed.primitiveType).ToString() + "\n" + string.Format("Round {0}\nSharp {1}\nCone {2}", grabed.attrs.x.ToString("0.00"), grabed.attrs.y.ToString("0.00"), grabed.attrs.z.ToString("0.00")); } else if ((ClayVRPrimitive)grabed.primitiveType == ClayVRPrimitive.TORUS) { grabed.attrs.x = Mathf.Clamp(grabed.attrs.x + toolDelta.x, -1, 1); toolText.text = currentTool.ToString() + "\n" + ((ClayVRPrimitive)grabed.primitiveType).ToString() + "\n" + string.Format("Fat {0}", grabed.attrs.x.ToString("0.00")); } else { toolText.text = currentTool.ToString() + "\n" + ((ClayVRPrimitive)grabed.primitiveType).ToString(); } grabed.transform.hasChanged = true; } else if (currentTool == ClayVRTool.COLOR) { if (colorToolHSV) { grabed.color = Color.HSVToRGB(pickedColor.x, pickedColor.y, pickedColor.z); } else { grabed.color = new Color(pickedColor.x, pickedColor.y, pickedColor.z); } } } else if (!toolSelectionEnabled) { Vector3 toolDelta = transform.InverseTransformDirection(rootDelta); //if(toolDelta.magnitude > 0) //{ // Debug.Log(string.Format("X: {0} | Y: {1} | Z: {2}", toolDelta.x.ToString("0.000"), toolDelta.y.ToString("0.000"), toolDelta.z.ToString("0.000"))); //} if (currentTool == ClayVRTool.PRIMITIVE) { if (interactButton.GetLastStateDown(inputSource)) { if (targetedClayObject != null) { GameObject pieceObject = ClayVR.ClonePiece(targetedClayObject.gameObject, ClayVR.instance.inEditContainer.transform); pieceObject.transform.position = transform.position; } else { GameObject pieceObject = ClayVR.CreatePiece(ClayVR.instance.inEditContainer.transform); pieceObject.transform.position = transform.position; pieceObject.transform.localScale = Vector3.one * 0.1f; } } } if (currentTool == ClayVRTool.COLOR) { if (interactButton.GetLastStateDown(inputSource)) { if (targetedClayObject != null) { pickedColor.x = targetedClayObject.color.r; pickedColor.y = targetedClayObject.color.g; pickedColor.z = targetedClayObject.color.b; } else { if (colorToolHSV) { Color color = Color.HSVToRGB(pickedColor.x, pickedColor.y, pickedColor.z); pickedColor.x = color.r; pickedColor.y = color.g; pickedColor.z = color.b; } else { Color color = new Color(pickedColor.x, pickedColor.y, pickedColor.z); Color.RGBToHSV(color, out pickedColor.x, out pickedColor.y, out pickedColor.z); } colorToolHSV = !colorToolHSV; } } if (grabGrip.GetState(inputSource)) { pickedColor.x = Mathf.Clamp(pickedColor.x + toolDelta.x, 0, 1); // R / HUE pickedColor.y = Mathf.Clamp(pickedColor.y + toolDelta.y, 0, 1); // G / SATURATION pickedColor.z = Mathf.Clamp(pickedColor.z + toolDelta.z, 0, 1); // B / VALUE } toolSelector.transform.localPosition = new Vector3((pickedColor.x * 2 - 1) * TOOL_SELECTOR_SIZE, (pickedColor.y * 2 - 1) * TOOL_SELECTOR_SIZE, 0); if (colorToolHSV) { colorPickerMaterial.SetFloat("_ZCoord", pickedColor.z); colorPickerMaterial.SetFloat("_HSV", 1); toolText.text = currentTool.ToString() + "\n" + string.Format("H: {0}, S: {1}, V: {2}", pickedColor.x.ToString("0.00"), pickedColor.y.ToString("0.00"), pickedColor.z.ToString("0.00")); toolText.color = Color.HSVToRGB(pickedColor.x, pickedColor.y, pickedColor.z); } else { colorPickerMaterial.SetFloat("_ZCoord", pickedColor.z); colorPickerMaterial.SetFloat("_HSV", -1); toolText.text = currentTool.ToString() + "\n" + string.Format("R: {0}, G: {1}, B: {2}", pickedColor.x.ToString("0.00"), pickedColor.y.ToString("0.00"), pickedColor.z.ToString("0.00")); toolText.color = new Color(pickedColor.x, pickedColor.y, pickedColor.z); } } } }
/// <summary> /// Callback for when Left TouchPad was clicked, check what section of TouchPad was pressed /// </summary> /// <param name="fromAction"></param> /// <param name="fromSource"></param> private void LeftTouchPadDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { //Return if Menu is open or Marker is currently pulled if (CurrentMenuState != MenuState.BOTH_CLOSED || startedPulling != HANDSIDE.HAND_NONE) { return; } //Check if Marker TouchPad position was touched else if (TouchPadPosition.GetLastAxis(fromSource).y < 0 && TouchPadPosition.GetLastAxis(fromSource).x > leftArraowActivationThreshold && TouchPadPosition.GetLastAxis(fromSource).x < rightArraowActivationThreshold) { OnStartMarkerPull.Invoke(HANDSIDE.HAND_LEFT); startedPulling = HANDSIDE.HAND_LEFT; CurrentMenuState = MenuState.CURRENTLY_PULLING; } //Check if Teleport TouchPad position was touched else if (TouchPadPosition.GetLastAxis(fromSource).y > 0 && TouchPadPosition.GetLastAxis(fromSource).x > leftArraowActivationThreshold && TouchPadPosition.GetLastAxis(fromSource).x < rightArraowActivationThreshold) { OnTeleportDownLeft.Invoke(HANDSIDE.HAND_LEFT); } }
// Update is called once per frame void Update() { if (clickMove.GetState(handtype) && clickAxis.GetLastAxis(handtype).y > 0) { if (IsInLimits()) { previousPosition = playerObject.transform.position; playerObject.transform.position += directionController.transform.forward * Time.deltaTime * 80.0f; } else { playerObject.transform.position = previousPosition; } } if ((clickMove.GetState(handtype) && clickAxis.GetLastAxis(handtype).y < 0)) { if (IsInLimits()) { previousPosition = playerObject.transform.position; playerObject.transform.position += directionController.transform.forward * Time.deltaTime * 30.0f; } else { playerObject.transform.position = previousPosition; } } if (Input.GetKey(KeyCode.W)) { if (IsInLimits()) { previousPosition = playerObject.transform.position; playerObject.transform.position += GetComponentInChildren <Camera>().transform.forward *Time.deltaTime * 80.0f; } else { playerObject.transform.position = previousPosition; } } if (Input.GetKey(KeyCode.S)) { if (IsInLimits()) { cage.SetActive(false); previousPosition = playerObject.transform.position; playerObject.transform.position += GetComponentInChildren <Camera>().transform.forward *Time.deltaTime * 30.0f; } else { cage.SetActive(true); playerObject.transform.position = previousPosition; } } bool verifyUnderwater = transform.position.y < water.GetComponent <Collider>().bounds.max.y; if (verifyUnderwater) { if (verifyUnderwater != lastFogCheck) { GetComponentInChildren <Kino.Fog>().enabled = true; } lastFogCheck = verifyUnderwater; } else { if (verifyUnderwater != lastFogCheck) { GetComponentInChildren <Kino.Fog>().enabled = false; } lastFogCheck = verifyUnderwater; } }