private void less() { if (canScaleLess()) { if(scaleWorms(-WORM_SCALE_FACTOR)) new GVRRelativeMotionAnimation(worm, .1f, -0.015f, 0.015f, 0).start(getGVRContext() .getAnimationEngine()); } }
private void plus() { if (canScaleMore()) { if(scaleWorms(WORM_SCALE_FACTOR)) new GVRRelativeMotionAnimation(worm, .1f, 0.015f, -0.015f, 0).start(getGVRContext() .getAnimationEngine()); } } }
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()); }
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 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()); }
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 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()); }
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 unsnapSphere(float duration) { if (!isUnsnappingSphere) { if (snapAnimation != null) { gvrContext.getAnimationEngine().stop(snapAnimation); } isUnsnappingSphere = true; snapAnimation = new GVRRelativeMotionAnimation(this, duration, -getTransform() .getPositionX(), -getTransform().getPositionY(), 0f).start(gvrContext.getAnimationEngine()) .setInterpolator(new InterpolatorExpoEaseInOut()) .setOnFinish(new GVROnFinish() { @Override public void finished(GVRAnimation arg0) { isUnsnappingSphere = false; if (answerState == SphereStaticList.MOVEABLE) { animateFloating(); } } }); } }
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 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; } } }
if (isActive) { new GVRRelativeMotionAnimation(this, duration, newPosition[0] - initialPosition[0], newPosition[1] - initialPosition[1], newPosition[2] - initialPosition[2]).start(getGVRContext().getAnimationEngine()) .setInterpolator(InterpolatorBackEaseOut.getInstance()).setOnFinish(new GVROnFinish() { } else { new GVRRelativeMotionAnimation(this, duration, newPosition[0] - initialPosition[0], newPosition[1] - initialPosition[1], newPosition[2] - initialPosition[2]).start(getGVRContext().getAnimationEngine()) .setInterpolator(InterpolatorBackEaseOut.getInstance()).setOnFinish(new GVROnFinish() {
public void moveAlongCameraVector(float duration, float movement) { if (wormParentAnimation != null) { getGVRContext().getAnimationEngine().stop(wormParentAnimation); } GVRCameraRig cameraObject = getGVRContext().getMainScene().getMainCameraRig(); float distance = (float) Util.distance(wormParent.getTransform(), cameraObject.getTransform()) + movement; float[] newPosition = Util.calculatePointBetweenTwoObjects(cameraObject.getTransform(), wormParent.getTransform(), distance); if (movement < 0 && MathUtils.distance(cameraObject.getTransform(), newPosition) < Constants.MIN_WORM_MOVE_DISTANCE) return; if (movement > 0 && MathUtils.distance(cameraObject.getTransform(), wormParent.getTransform()) > Constants.MAX_WORM_MOVE_DISTANCE) return; wormParentAnimation = new GVRRelativeMotionAnimation(wormParent.getTransform(), duration, newPosition[0] - wormParent.getTransform().getPositionX(), 0, newPosition[2] - wormParent.getTransform().getPositionZ()) .start(getGVRContext().getAnimationEngine()); }