private static void updateEndPointUV(List<Vertex> vertices) { // Update UV coordinates of ending vertices for (int edgeIndex = 0; edgeIndex <= NUMBER_OF_SIDES; edgeIndex++) { int vertexIndex = vertices.size() - edgeIndex - 1; Vertex currentVertex = vertices.get(vertexIndex); currentVertex.setUvCoordinate( new UvCoordinate( currentVertex.getUvCoordinate().x, (Vector3.subtract( vertices.get(vertexIndex).getPosition(), vertices.get(vertexIndex - NUMBER_OF_SIDES - 1).getPosition()) .length() + vertices.get(vertexIndex - NUMBER_OF_SIDES - 1).getUvCoordinate().y))); } }
float diff = Vector3.subtract(newPosition, startPosition).length(); float slopPixels = gesturePointersUtility.inchesToPixels(SLOP_INCHES); if (diff >= slopPixels) {
@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); float newGap = Vector3.subtract(newPosition1, newPosition2).length(); if (newGap == gap) { return false; } gapDelta = newGap - gap; gap = newGap; debugLog("Update: " + gapDelta); return true; }
private void updatePosition(FrameTime frameTime) { // Store in local variable for nullness static analysis. Vector3 desiredLocalPosition = this.desiredLocalPosition; if (desiredLocalPosition == null) { return; } Vector3 localPosition = getTransformableNode().getLocalPosition(); float lerpFactor = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1); localPosition = Vector3.lerp(localPosition, desiredLocalPosition, lerpFactor); float lengthDiff = Math.abs(Vector3.subtract(desiredLocalPosition, localPosition).length()); if (lengthDiff <= POSITION_LENGTH_THRESHOLD) { localPosition = desiredLocalPosition; this.desiredLocalPosition = null; } getTransformableNode().setLocalPosition(localPosition); }
public void add(Vector3 pointInWorld) { Vector3 pointInLocal = anchorNode.worldToLocalPoint(pointInWorld); List<Vector3> points = lineSimplifier.getPoints(); if (getNumOfPoints() < 1) { lineSimplifier.add(pointInLocal); return; } Vector3 prev = points.get(points.size() - 1); Vector3 diff = Vector3.subtract(prev, pointInLocal); if (diff.length() < MINIMUM_DISTANCE_BETWEEN_POINTS) { return; } lineSimplifier.add(pointInLocal); RenderableDefinition renderableDefinition = ExtrudedCylinder.makeExtrudedCylinder(CYLINDER_RADIUS, points, material); if (shape == null) { shape = ModelRenderable.builder().setSource(renderableDefinition).build().join(); node.setRenderable(shape); } else { shape.updateFromDefinition(renderableDefinition); } }
position, vertices.get(previousSegmentVertexIndex).getPosition()) .length() + vertices.get(previousSegmentVertexIndex).getUvCoordinate().y))) .build();
final float halfHeight = difference.length() / 2; final Vector3 center = Vector3.add(firstPoint, secondPoint).scaled(.5f);