private void transformSingleAnchor(LeapPinchDetector singlePinch) { _anchor.position = singlePinch.Position; switch (_oneHandedRotationMethod) { case RotationMethod.None: break; case RotationMethod.Single: Vector3 p = singlePinch.Rotation * Vector3.right; p.y = _anchor.position.y; _anchor.LookAt(p); break; case RotationMethod.Full: _anchor.rotation = singlePinch.Rotation; break; } _anchor.localScale = Vector3.one; }
private void transformSingleAnchor(LeapPinchDetector singlePinch) { _anchor.position = singlePinch.Position; switch (_oneHandedRotationMethod) { case RotationMethod.None: break; case RotationMethod.Single: Vector3 p = singlePinch.Rotation * Vector3.right; p.y = _anchor.position.y; _anchor.LookAt(p); break; case RotationMethod.Full: _anchor.rotation = singlePinch.Rotation; break; } _anchor.localScale = Vector3.one; }
private void transformSingleAnchor(LeapPinchDetector singlePinch) { //Debug.Log("gripping " + gripping + " grippingObject" + singlePinch.grippingObject + " _pinchDetectorCurrent.grippingObject " + _pinchDetectorCurrent.grippingObject); if (gripping) { //used to make sure this is the only object being grabbed singlePinch.grippingObject = this.name; //listing the hand being used as the current hand for other funtions to access it's values _pinchDetectorCurrent = singlePinch; if (isDrawer) { float drawerLocation = singlePinch.Position.z; if (drawerLocation > anchorDrawerOrigin + 0.5f) { drawerLocation = anchorDrawerOrigin + 0.5f; } if (drawerLocation < anchorDrawerOrigin) { drawerLocation = anchorDrawerOrigin; } //Debug.Log("drawerLocation " + drawerLocation); transform.position = new Vector3(transform.position.x, transform.position.y, drawerLocation); } else { //get relevant data for processing where the cabinet should be angled Vector3 currentRotation = _anchor.eulerAngles; Vector3 difference = singlePinch.Position - anchorPosOrigin; //calculate what the angle of the cabinet should be in relation to pinch point float diffAngle = Mathf.Rad2Deg * Mathf.Atan2(difference.z, difference.x); float finalAngle = -diffAngle - AngleOffset; //make sure it isn't out of bounds //this code is kinda hacky if (AngleOffset > 0) { if (finalAngle < 0) { finalAngle += 360; } if (anchorAngleOrigin > finalAngle) { finalAngle = anchorAngleOrigin; } if (finalAngle < 0) { finalAngle += 360; } if (finalAngle > anchorAngleOrigin + AngleOffset) { finalAngle = anchorAngleOrigin + AngleOffset; } } else { if (anchorAngleOrigin < finalAngle) { finalAngle = anchorAngleOrigin; } if (finalAngle < anchorAngleOrigin + AngleOffset) { finalAngle = anchorAngleOrigin + AngleOffset; } } //set the angle of the object //Debug.Log("finalAngle " + finalAngle); _anchor.eulerAngles = new Vector3(currentRotation.x, finalAngle, currentRotation.z); } } }