private void less() { if (canScaleLess()) { if(scaleWorms(-WORM_SCALE_FACTOR)) new GVRRelativeMotionAnimation(worm, .1f, -0.015f, 0.015f, 0).start(getGVRContext() .getAnimationEngine()); } }
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()); }
public void collapseFrame() { if (isOpen) { stopAnimations(); scaleCollapse = new GVRScaleAnimation(pivot, ANIMATION_TIME, 1, 0, 1); scaleCollapse.setRepeatMode(GVRRepeatMode.ONCE); scaleCollapse.start(getGVRContext().getAnimationEngine()); rmCollapse = new GVRRelativeMotionAnimation(this, ANIMATION_TIME, 0, ANIMATION_FRAME_RESIZE, 0); rmCollapse.setRepeatMode(GVRRepeatMode.ONCE); rmCollapse.setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { mMenuFrame.getRenderData().getMaterial().setOpacity(0); getTransform().setPosition(0f, MenuBox.FRAME_INITITAL_POSITION_Y, FRAME_POSITION_Z); } }); rmCollapse.start(getGVRContext().getAnimationEngine()); isOpen = false; } }
public void handlerButtonStates(boolean pressed) { if (pressed) { buttonHover.getRenderData().getMaterial().setOpacity(0.5f); if (!isDown) { GVRRelativeMotionAnimation eventDown = new GVRRelativeMotionAnimation(this, DOWN_SIMPLE_BUTTON_TIME, this.getTransform().getPositionX(), this.getTransform().getPositionY(), this.getTransform().getPositionZ() - DOWN_SIMPLE_BUTTON); eventDown.setRepeatMode(GVRRepeatMode.ONCE); eventDown.setRepeatCount(1); eventDown.start(this.getGVRContext().getAnimationEngine()); isDown = true; } } else { buttonHover.getRenderData().getMaterial().setOpacity(0.f); if (isDown) { GVRRelativeMotionAnimation evDown = new GVRRelativeMotionAnimation(this, DOWN_SIMPLE_BUTTON_TIME, this.getTransform().getPositionX(), this.getTransform().getPositionY(), evPositionZ - this.getTransform().getPositionZ()); evDown.setRepeatMode(GVRRepeatMode.ONCE); evDown.setRepeatCount(1); evDown.start(this.getGVRContext().getAnimationEngine()); isDown = false; } } }
public void expandFrame(final MenuHeader menuHeader) { if (!isOpen) { stopAnimations(); mMenuFrame.getRenderData().getMaterial().setOpacity(0.5f); scaleExpand = new GVRScaleAnimation(pivot, ANIMATION_TIME, 1, FRAME_EXPAND_SCALE_X, 1); scaleExpand.setRepeatMode(GVRRepeatMode.ONCE); scaleExpand.start(this.getGVRContext().getAnimationEngine()); rmExpand = new GVRRelativeMotionAnimation(this, ANIMATION_TIME, 0, -ANIMATION_FRAME_RESIZE, 0); rmExpand.setRepeatMode(GVRRepeatMode.ONCE); rmExpand.start(this.getGVRContext().getAnimationEngine()).setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { menuHeader.show(); } }); isOpen = true; } else { menuHeader.show(); } }
public void playAnimation(GVRContext gvrContext) { GVRAnimation anim = new GVRRelativeMotionAnimation(this, AnimationsTime.getDropTime(), 0, -Constants.APPLE_INICIAL_YPOS - 1, 0); anim.setInterpolator(defineInterpolator(motion)); anim.start(gvrContext.getAnimationEngine()); playShadowAnimation(); playOpacityAnimation(gvrContext); }
private void resetPositionParts() { GVRRelativeMotionAnimation headAnimation = WormApplyTransformAnims.moveWormPartReset( Main.worm.getHead().getParent(), Main.worm.getMiddle()); headAnimation.start(getGVRContext().getAnimationEngine()).setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { WormApplyTransformAnims.moveWormPartToClose(getGVRContext(), Main.worm .getHead().getParent(), Main.worm.getMiddle()); } }); GVRRelativeMotionAnimation endAnimation = WormApplyTransformAnims.moveWormPartReset( Main.worm.getEnd(), Main.worm.getMiddle()); endAnimation.start(getGVRContext().getAnimationEngine()).setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { WormApplyTransformAnims.moveWormPartToClose(getGVRContext(), Main.worm.getEnd(), Main.worm.getMiddle()); } }); }
public void animateFloating() { if (!isFloatingSphere) { isFloatingSphere = true; float intensity = 1; float randomValue = 0.7f + ((float) Math.random() * 1.0f); floatingAnimation = new GVRRelativeMotionAnimation (getParent(), intensity * 3 * randomValue, 0, getParent().getTransform() .getPositionY() - intensity * 2 * randomValue, 0); floatingAnimation.setInterpolator(new FloatEffectInterpolator()); floatingAnimation.setRepeatMode(GVRRepeatMode.PINGPONG); floatingAnimation.setRepeatCount(-1); floatingAnimation.start(gvrContext.getAnimationEngine()); } }
private void plus() { if (canScaleMore()) { if(scaleWorms(WORM_SCALE_FACTOR)) new GVRRelativeMotionAnimation(worm, .1f, 0.015f, -0.015f, 0).start(getGVRContext() .getAnimationEngine()); } } }
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 static GVRRelativeMotionAnimation moveWormPartReset(GVRSceneObject moveablePart, GVRSceneObject basePart) { float scaleRatio = ScaleWorm.getLastSize()[0] / basePart.getTransform().getScaleX(); float distance = (float) Util.distance(basePart, moveablePart) * scaleRatio; float[] newPosition = Util .calculatePointBetweenTwoObjects(basePart, moveablePart, distance); float newX = newPosition[0] - moveablePart.getTransform().getPositionX(); float newZ = newPosition[2] - moveablePart.getTransform().getPositionZ(); return new GVRRelativeMotionAnimation(moveablePart, 0f, newX, 0, newZ); } }
private void moveWormPart(GVRSceneObject part, float scaleFactor) { float currentScale = part.getTransform().getScaleX(); float ratio = (currentScale + scaleFactor) / currentScale; float currentPartPositionX = part.getTransform().getPositionX(); float newPartPositionX = ratio * currentPartPositionX; new GVRRelativeMotionAnimation(part, 0.1f, newPartPositionX - currentPartPositionX, 0, 0).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()); }
public void playMoveAnimation(GVRContext gvrContext, GVRSceneObject returnTarget) { getTransform().setPosition(returnTarget.getTransform().getPositionX(), returnTarget.getTransform().getPositionY(), returnTarget.getTransform().getPositionZ()); getTransform().setRotationByAxis( 0, 1, 1, 1); getTransform().rotateByAxis( MathUtils.getYRotationAngle(this, gvrContext.getMainScene().getMainCameraRig()), 0, 1, 0); GVRAnimation anim = new GVRRelativeMotionAnimation(this, ANIMATION_DURATION, 0, Y_ANIMATION_DELTA, 0); anim.start(gvrContext.getAnimationEngine()); playOpacityAnimation(gvrContext); }
public static void moveWormPart(GVRContext gvrContext, GVRSceneObject part, float scaleFactor) { float currentScale = part.getTransform().getScaleX(); float ratio = (currentScale + scaleFactor) / currentScale; float currentPartPositionX = part.getTransform().getPositionX(); float newPartPositionX = ratio * currentPartPositionX; new GVRRelativeMotionAnimation(part, AnimationsTime.getScaleTime(), newPartPositionX - currentPartPositionX, 0, 0).start(gvrContext .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(); } }); }
public void snapSphere(float[] hit) { if (isUnsnappingSphere) { gvrContext.getAnimationEngine().stop(snapAnimation); isUnsnappingSphere = false; } if(hit != null) snapAnimation = new GVRRelativeMotionAnimation(this, 1.2f, hit[0] - getTransform().getPositionX(), hit[1] - getTransform().getPositionY(), 0f).start(gvrContext.getAnimationEngine()); }
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 static void moveWormPartToClose(GVRContext gvrContext, GVRSceneObject moveablePart, GVRSceneObject basePart) { float scaleRatio = ScaleWorm.getWorm().getHead().getTransform().getScaleX() / ScaleWorm.getLastSize()[0]; float distance = (float) Util.distance(basePart, moveablePart) * scaleRatio; float[] newPosition = Util .calculatePointBetweenTwoObjects(basePart, moveablePart, distance); float newX = newPosition[0] - moveablePart.getTransform().getPositionX(); float newZ = newPosition[2] - moveablePart.getTransform().getPositionZ(); new GVRRelativeMotionAnimation(moveablePart, AnimationsTime.getScaleTime(), newX, 0, newZ) .start(gvrContext.getAnimationEngine()); }
@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);