public void translateSelection(Vector3 begin, Vector3 end) { if (currentSelection) { Vector3 finalTranslation = initRotation * Vector3.Scale(inverseInitRotation * (end - begin), axisLocker) + initPosition; if (axisLocker != new Vector3(0, 1, 1) && axisLocker != new Vector3(1, 0, 1) && axisLocker != new Vector3(1, 1, 0)) { lineRenderer.positionCount = 2; lineRenderer.SetPosition(0, currentSelection.position); lineRenderer.SetPosition(1, currentSelection.position + initRotation * axisLocker * 10000); } else { lineRenderer.positionCount = 0; } if (currentSceneObject) { currentSceneObject.translate(finalTranslation); } else { KeyframeScript keyframeScript = currentSelection.GetComponent <KeyframeScript>(); if (keyframeScript) { currentSelection.transform.position = finalTranslation; currentSelection.GetComponent <KeyframeScript>().updateKeyInCurve(); } } } }
//! //! translate currently selected object //! @param translation relative translation beeing applied on current selection //! public void translateSelection(Vector3 translation) { if (currentSelection) { Vector3 finalTranslation = Vector3.Scale(translation, axisLocker); if (currentSceneObject) { currentSceneObject.translate(finalTranslation); } else { KeyframeScript keyframeScript = currentSelection.GetComponent <KeyframeScript>(); if (keyframeScript) { currentSelection.transform.position = finalTranslation; currentSelection.GetComponent <KeyframeScript>().updateKeyInCurve(); } } } }
public void translateSelection(Vector3 begin, Vector3 end) { if (currentSelection) { lineRenderer.positionCount = 0; float scaleCompansation = Vector3.Distance(Camera.main.transform.position, end) * (Camera.main.fieldOfView); Vector3 finalTranslation = initRotation * Vector3.Scale(inverseInitRotation * end, axisLocker) - begin; if (currentSceneObject) { currentSceneObject.translate(finalTranslation); } else { KeyframeScript keyframeScript = currentSelection.GetComponent <KeyframeScript>(); if (keyframeScript) { currentSelection.transform.position = finalTranslation; currentSelection.GetComponent <KeyframeScript>().updateKeyInCurve(); } } } }
//! //! translate currently selected object with joystick //! @param translation absolute translation beeing applied on current selection //! public void translateSelectionJoystick(Vector3 translation) { if (currentSelection) { /*if (translation.x == 0 && translation.y == 0) * axisLocker = new Vector3(0, 0, 1); * else if (translation.x == 0 && translation.z == 0) * axisLocker = new Vector3(0, 1, 0); * else if (translation.y == 0 && translation.z == 0) * axisLocker = new Vector3(1, 0, 0); * else * axisLocker = new Vector3(1, 0, 1); * * Vector3 finalTranslation = currentSelection.rotation * Vector3.Scale(Quaternion.Inverse(currentSelection.rotation) * (translation*VPETSettings.Instance.controllerSpeed), axisLocker) + currentSelection.position; */ Vector3 xTrans = translation.z * Vector3.Scale(Camera.main.transform.forward, (Vector3.forward + Vector3.right)).normalized; Vector3 yTrans = new Vector3(0, translation.y, 0); Vector3 zTrans = translation.x * Vector3.Scale(Camera.main.transform.right, (Vector3.forward + Vector3.right)).normalized; float scaleFactor = (8f * Vector3.Distance(Camera.main.transform.position, currentSelection.position) / VPETSettings.Instance.maxExtend); Vector3 finalTranslation = scaleFactor * (xTrans + yTrans + zTrans) + currentSelection.position; if (currentSceneObject) { currentSceneObject.translate(finalTranslation); } else { KeyframeScript keyframeScript = currentSelection.GetComponent <KeyframeScript>(); if (keyframeScript) { currentSelection.transform.position = finalTranslation; currentSelection.GetComponent <KeyframeScript>().updateKeyInCurve(); } } } }