public void startAppleAnimation() { apple.getTransform().setPositionY(APPLE_INITIAL_POSITION_Y); apple.getRenderData().getMaterial().setOpacity(1f); appleAnimation = new GVRRelativeMotionAnimation(apple, AnimationsTime.getDropTime(), 0, Y_ANIMATION_DELTA, 0) .setInterpolator(animationInterpolator) .setRepeatMode(GVRRepeatMode.REPEATED) .setRepeatCount(-1) .start(getGVRContext() .getAnimationEngine()); }
private GVRAnimation createSpotAnimation() { GVRCameraRig cameraObject = gvrContext.getMainScene().getMainCameraRig(); float distance = (float) Math.max( 0.7 * Util.distance(getInitialPositionVector(), cameraObject.getTransform()), Constants.MINIMUM_DISTANCE_FROM_CAMERA); float[] newPosition = Util.calculatePointBetweenTwoObjects(cameraObject.getTransform(), getParent(), distance); float scaleFactor = Util.getHitAreaScaleFactor(distance); scaleParentAnimation = new GVRScaleAnimation(getParent(), 1.2f, scaleFactor) .start(gvrContext .getAnimationEngine()); scaleThisAnimation = new GVRScaleAnimation(this, 1.2f, 1 / scaleFactor).start(gvrContext .getAnimationEngine()); return new GVRRelativeMotionAnimation(getParent(), 1.2f, newPosition[0] - getParent().getTransform().getPositionX(), newPosition[1] - getParent().getTransform().getPositionY(), newPosition[2] - getParent().getTransform().getPositionZ()) .setInterpolator(new InterpolatorExpoEaseOut()); }
private GVRAnimation createUnspotAnimation(float scaleFactor) { scaleParentAnimation = new GVRScaleAnimation(getParent(), 1.2f, scaleFactor) .start(gvrContext .getAnimationEngine()); scaleThisAnimation = new GVRScaleAnimation(this, 1.2f, 1 / scaleFactor).start(gvrContext .getAnimationEngine()); return new GVRRelativeMotionAnimation(getParent(), 1.2f, (float) getInitialPositionVector() .getX() - getParent().getTransform().getPositionX(), (float) getInitialPositionVector().getY() - getParent().getTransform().getPositionY(), (float) getInitialPositionVector().getZ() - getParent().getTransform().getPositionZ()) .setInterpolator(new InterpolatorExpoEaseOut()); }
public void moveToCursor() { if (followCursorAnimation != null) { getGVRContext().getAnimationEngine().stop(followCursorAnimation); } GVRCameraRig cameraObject = getGVRContext().getMainScene().getMainCameraRig(); float desiredDistance = (float) Math.max( 0.7 * Util.distance(getParent(), cameraObject.getTransform()), Constants.MINIMUM_DISTANCE_FROM_CAMERA); float[] lookAt = getGVRContext().getMainScene().getMainCameraRig().getLookAt(); Vector3D lookAtVector = new Vector3D(lookAt[0], lookAt[1], lookAt[2]); final float desiredX = (float) lookAtVector.getX() * desiredDistance; final float desiredY = (float) lookAtVector.getY() * desiredDistance + CURSOR_POSITION_OFFSET_Y; final float desiredZ = (float) lookAtVector.getZ() * desiredDistance; float x = desiredX - getParent().getTransform().getPositionX(); float y = desiredY - getParent().getTransform().getPositionY(); float z = desiredZ - getParent().getTransform().getPositionZ(); followCursorAnimation = new GVRRelativeMotionAnimation(getParent(), 0.8f, x, y, z) .setInterpolator(new InterpolatorExpoEaseOut()).start( getGVRContext().getAnimationEngine()); }
public void restoreSpherePosition(float duration) { if (followCursorAnimation != null) { getGVRContext().getAnimationEngine().stop(followCursorAnimation); } float x = (float) getInitialPositionVector().getX() - getParent().getTransform().getPositionX(); float y = (float) getInitialPositionVector().getY() - getParent().getTransform().getPositionY(); float z = (float) getInitialPositionVector().getZ() - getParent().getTransform().getPositionZ(); followCursorAnimation = new GVRRelativeMotionAnimation(getParent(), duration, x, y, z) .setInterpolator(new InterpolatorExpoEaseInOut()) .start(getGVRContext().getAnimationEngine()).setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { answerState = SphereStaticList.MOVEABLE; animateFloating(); } }); }
@Override public void run() { float duration = 0.71f; unsnapSphere(duration); GVRCameraRig cameraObject = getGVRContext().getMainScene().getMainCameraRig() ; float distance = Constants.SPHERE_SELECTION_DISTANCE; float[] newPosition = Util.calculatePointBetweenTwoObjects( cameraObject.getTransform(), getInitialPositionVector(), distance); float scaleFactor = Util.getHitAreaScaleFactor(distance); scaleParentAnimation = new GVRScaleAnimation(getParent(), duration, scaleFactor).start(getGVRContext() .getAnimationEngine()); scaleThisAnimation = new GVRScaleAnimation(sphereFlag, duration, 1 / scaleFactor).start(getGVRContext() .getAnimationEngine()); new GVRRelativeMotionAnimation(getParent(), duration, newPosition[0] - getParent().getTransform().getPositionX(), newPosition[1] - getParent().getTransform().getPositionY(), newPosition[2] - getParent().getTransform().getPositionZ()) .setInterpolator(new InterpolatorExpoEaseInOut()) .start(getGVRContext().getAnimationEngine()).setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { SphereFlag.this.moveTogetherDashboard = true; } }); } }, 0.5f);
public void unselectSphere() { answerState = SphereStaticList.RESTORING; stopFloatingSphere(); final SphereFlag sphereFlag = this; float duration = 1.5f; new GVRShaderAnimation(sphereFlag, SphereShader.BLUR_INTENSITY, duration, 1) .start(getGVRContext().getAnimationEngine()); GVRCameraRig cameraObject = getGVRContext().getMainScene().getMainCameraRig(); float distance = (float) (Constants.NEAREST_NON_SELECTED_SPHERE - Constants.NEAREST_SPHERE + Util .distance(getInitialPositionVector(), cameraObject.getTransform())); float[] newPosition = Util.calculatePointBetweenTwoObjects(cameraObject.getTransform(), getParent(), distance); float scaleFactor = Util.getHitAreaScaleFactor(distance); scaleParentAnimation = new GVRScaleAnimation(getParent(), duration, scaleFactor) .start(getGVRContext() .getAnimationEngine()); scaleThisAnimation = new GVRScaleAnimation(sphereFlag, duration, 1 / scaleFactor) .start(getGVRContext() .getAnimationEngine()); new GVRRelativeMotionAnimation(getParent(), duration, newPosition[0] - getParent().getTransform().getPositionX(), newPosition[1] - getParent().getTransform().getPositionY(), newPosition[2] - getParent().getTransform().getPositionZ()) .setInterpolator(new InterpolatorExpoEaseInOut()).start( getGVRContext().getAnimationEngine()); }