public Vector3 getPosition() { return new Vector3(position); }
public Vector3 getDelta() { return new Vector3(delta); }
public static Vector3 motionEventToPosition(MotionEvent me, int pointerId) { int index = me.findPointerIndex(pointerId); return new Vector3(me.getX(index), me.getY(index), 0.0f); } }
public TwistGesture( GesturePointersUtility gesturePointersUtility, MotionEvent motionEvent, int pointerId2) { super(gesturePointersUtility); pointerId1 = motionEvent.getPointerId(motionEvent.getActionIndex()); this.pointerId2 = pointerId2; startPosition1 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId1); startPosition2 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId2); previousPosition1 = new Vector3(startPosition1); previousPosition2 = new Vector3(startPosition2); debugLog("Created"); }
public PinchGesture( GesturePointersUtility gesturePointersUtility, MotionEvent motionEvent, int pointerId2) { super(gesturePointersUtility); pointerId1 = motionEvent.getPointerId(motionEvent.getActionIndex()); this.pointerId2 = pointerId2; startPosition1 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId1); startPosition2 = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId2); previousPosition1 = new Vector3(startPosition1); previousPosition2 = new Vector3(startPosition2); debugLog("Created"); }
public DragGesture( GesturePointersUtility gesturePointersUtility, HitTestResult hitTestResult, MotionEvent motionEvent) { super(gesturePointersUtility); pointerId = motionEvent.getPointerId(motionEvent.getActionIndex()); startPosition = GesturePointersUtility.motionEventToPosition(motionEvent, pointerId); position = new Vector3(startPosition); delta = Vector3.zero(); targetNode = hitTestResult.getNode(); debugLog("Created: " + pointerId); }
/** Returns an ObjectAnimator that makes this node rotate. */ private static ObjectAnimator createAnimator() { // Node's setLocalRotation method accepts Quaternions as parameters. // First, set up orientations that will animate a circle. Quaternion orientation1 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 0); Quaternion orientation2 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 120); Quaternion orientation3 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 240); Quaternion orientation4 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 360); ObjectAnimator orbitAnimation = new ObjectAnimator(); orbitAnimation.setObjectValues(orientation1, orientation2, orientation3, orientation4); // Next, give it the localRotation property. orbitAnimation.setPropertyName("localRotation"); // Use Sceneform's QuaternionEvaluator. orbitAnimation.setEvaluator(new QuaternionEvaluator()); // Allow orbitAnimation to repeat forever orbitAnimation.setRepeatCount(ObjectAnimator.INFINITE); orbitAnimation.setRepeatMode(ObjectAnimator.RESTART); orbitAnimation.setInterpolator(new LinearInterpolator()); orbitAnimation.setAutoCancel(true); return orbitAnimation; } }
@Override public void onContinueTransformation(PinchGesture gesture) { currentScaleRatio += gesture.gapDeltaInches() * sensitivity; float finalScaleValue = getFinalScale(); Vector3 finalScale = new Vector3(finalScaleValue, finalScaleValue, finalScaleValue); getTransformableNode().setLocalScale(finalScale); if (currentScaleRatio < -ELASTIC_RATIO_LIMIT || currentScaleRatio > (1.0f + ELASTIC_RATIO_LIMIT)) { gesture.cancel(); } }
@SuppressWarnings("FutureReturnValueIgnored") private void addMenuToNode(Node node, Vector3 localPosition) { ViewRenderable.builder() .setView(this, R.layout.material_options_view) .build() .thenAccept( viewRenderable -> { node.setRenderable(viewRenderable); node.setEnabled(false); node.setLocalPosition(localPosition); node.setWorldScale(new Vector3(.65f, .65f, .5f)); setupMaterialMenu(viewRenderable, node); }) .exceptionally( throwable -> { displayError(throwable); throw new CompletionException(throwable); }); }
private Node createPlanet( String name, Node parent, float auFromParent, float orbitDegreesPerSecond, ModelRenderable renderable, float planetScale) { // Orbit is a rotating node with no renderable positioned at the sun. // The planet is positioned relative to the orbit so that it appears to rotate around the sun. // This is done instead of making the sun rotate so each planet can orbit at its own speed. RotatingNode orbit = new RotatingNode(solarSettings, true); orbit.setDegreesPerSecond(orbitDegreesPerSecond); orbit.setParent(parent); // Create the planet and position it relative to the sun. Planet planet = new Planet(this, name, planetScale, renderable, solarSettings); planet.setParent(orbit); planet.setLocalPosition(new Vector3(auFromParent * AU_TO_METERS, 0.0f, 0.0f)); return planet; }
@Override public void onUpdated(Node node, FrameTime frameTime) { if (isTransforming()) { return; } float t = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1); currentScaleRatio = MathHelper.lerp(currentScaleRatio, getClampedScaleRatio(), t); float finalScaleValue = getFinalScale(); Vector3 finalScale = new Vector3(finalScaleValue, finalScaleValue, finalScaleValue); getTransformableNode().setLocalScale(finalScale); }
boxRenderable = ShapeFactory.makeCube( CUBE_SIZE_METERS, new Vector3(0, CUBE_SIZE_METERS.y / 2, 0), boxMaterial); }) .exceptionally( anchorNode, shaderModel1, new Vector3(0.2f, MODEL_CUBE_HEIGHT_OFFSET_METERS, 0.0f)); modelNode1.setLocalRotation(ROTATION_180_DEGREES); anchorNode, shaderModel2, new Vector3(-0.2f, MODEL_CUBE_HEIGHT_OFFSET_METERS, 0.0f)); modelNode2.setLocalRotation(ROTATION_180_DEGREES); createMenuNode(modelNode1, new Vector3(0.0f, 0.35f, 0.0f)); createMenuNode(modelNode2, new Vector3(0.0f, 0.35f, 0.0f)); createShapeNode(anchorNode, boxRenderable, new Vector3(0.0f, 0.0f, 0.0f));
private void setUpLights() { Light.Builder lightBuilder = Light.builder(Type.POINT) .setFalloffRadius(LIGHT_FALLOFF_RADIUS) .setShadowCastingEnabled(false) .setIntensity(intensityBar.getProgress()); for (int i = 0; i < 4; i++) { // Sets the color of and creates the light. lightBuilder.setColor(ColorConfig.getColor(pointlightColorConfig, i)); Light light = lightBuilder.build(); // Create node and set its light. Vector3 localPosition = new Vector3(-0.4f + (i * .2f), POINTLIGHT_CUBE_HEIGHT_OFFSET_METERS, 0.0f); RotatingNode orbit = new RotatingNode(); orbit.setParent(anchorNode); Node lightNode = new Node(); lightNode.setParent(orbit); lightNode.setLocalPosition(localPosition); lightNode.setLight(light); // Check if lights are currently switched on or off, and update accordingly. lightNode.setEnabled(toggleLights.isChecked()); pointlightNodes.add(lightNode); } isLightingInitialized = true; }
float videoHeight = mediaPlayer.getVideoHeight(); videoNode.setLocalScale( new Vector3( VIDEO_HEIGHT_METERS * (videoWidth / videoHeight), VIDEO_HEIGHT_METERS, 1.0f));
Vector3 localPosition = new Vector3(); Node cornerNode;
Plane plane = (Plane) trackable; if (plane.isPoseInPolygon(pose) && allowedPlaneTypes.contains(plane.getType())) { desiredLocalPosition = new Vector3(pose.tx(), pose.ty(), pose.tz()); desiredLocalRotation = new Quaternion(pose.qx(), pose.qy(), pose.qz(), pose.qw()); Node parent = getTransformableNode().getParent();