@Override protected void onStart(HitTestResult hitTestResult, MotionEvent motionEvent) { debugLog("Started: " + pointerId); position.set(GesturePointersUtility.motionEventToPosition(motionEvent, pointerId)); gesturePointersUtility.retainPointerId(pointerId); }
@Override protected boolean updateGesture(HitTestResult hitTestResult, MotionEvent motionEvent) { int actionId = motionEvent.getPointerId(motionEvent.getActionIndex()); int action = motionEvent.getActionMasked(); if (action == MotionEvent.ACTION_MOVE) { Vector3 newPosition = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId); if (!Vector3.equals(newPosition, position)) { delta.set(Vector3.subtract(newPosition, position)); position.set(newPosition); debugLog("Updated: " + pointerId + " : " + position); return true; } } else if (actionId == pointerId && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP)) { complete(); } else if (action == MotionEvent.ACTION_CANCEL) { cancel(); } return false; }
@Override protected boolean updateGesture(HitTestResult hitTestResult, MotionEvent motionEvent) { int actionId = motionEvent.getPointerId(motionEvent.getActionIndex()); int action = motionEvent.getActionMasked(); if (action == MotionEvent.ACTION_CANCEL) { cancel(); return false; } boolean touchEnded = action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP; if (touchEnded && (actionId == pointerId1 || actionId == pointerId2)) { complete(); return false; } if (action != MotionEvent.ACTION_MOVE) { return false; } Vector3 newPosition1 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId1); Vector3 newPosition2 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId2); deltaRotationDegrees = calculateDeltaRotation(newPosition1, newPosition2, previousPosition1, previousPosition2); previousPosition1.set(newPosition1); previousPosition2.set(newPosition2); debugLog("Update: " + deltaRotationDegrees); return true; }
@Override public boolean canStartTransformation(DragGesture gesture) { Node targetNode = gesture.getTargetNode(); if (targetNode == null) { return false; } BaseTransformableNode transformableNode = getTransformableNode(); if (targetNode != transformableNode && !targetNode.isDescendantOf(transformableNode)) { return false; } if (!transformableNode.isSelected() && !transformableNode.select()) { return false; } Vector3 initialForwardInWorld = transformableNode.getForward(); Node parent = transformableNode.getParent(); if (parent != null) { initialForwardInLocal.set(parent.worldToLocalDirection(initialForwardInWorld)); } else { initialForwardInLocal.set(initialForwardInWorld); } return true; }
rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta)); Vector3 normal = position.normalized(); position.set(Vector3.add(position, influencePoint));
localPosition.set(-0.5f * image.getExtentX(), 0.0f, -0.5f * image.getExtentZ()); cornerNode = new Node(); cornerNode.setParent(this); localPosition.set(0.5f * image.getExtentX(), 0.0f, -0.5f * image.getExtentZ()); cornerNode = new Node(); cornerNode.setParent(this); localPosition.set(0.5f * image.getExtentX(), 0.0f, 0.5f * image.getExtentZ()); cornerNode = new Node(); cornerNode.setParent(this); localPosition.set(-0.5f * image.getExtentX(), 0.0f, 0.5f * image.getExtentZ()); cornerNode = new Node(); cornerNode.setParent(this);
Quaternion.rotateVector(rotationFromAToB, Vector3.right()).normalized(); Vector3 upDirection = Quaternion.rotateVector(rotationFromAToB, Vector3.up()).normalized(); desiredUp.set(upDirection);
initialForwardInLocal.set(anchorNode.worldToLocalDirection(initialForwardInWorld));