@Override public void onAnimationLoaded(GVRAvatar avatar, GVRAnimator animation, String filePath, String errors) { if (animation != null) { animation.setRepeatMode(GVRRepeatMode.ONCE); animation.setSpeed(1f); } }
@Override public void onAnimationLoaded(GVRAvatar avatar, GVRAnimator animation, String filePath, String errors) { if (animation == null) { return; } animation.setRepeatMode(GVRRepeatMode.ONCE); animation.setSpeed(1f); loadNextAnimation(); }
@Override public void onAnimationLoaded(GVRAvatar avatar, GVRAnimator animation, String filePath, String errors) { animation.setRepeatMode(GVRRepeatMode.ONCE); animation.setSpeed(1f); if (!avatar.isRunning()) { avatar.startAll(GVRRepeatMode.REPEATED); } else { avatar.start(animation.getName()); } mAvManager.loadNextAnimation(); }
@Override public void onInit(GVRContext gvrContext) { mGVRContext = gvrContext; mAnimationEngine = gvrContext.getAnimationEngine(); GVRScene mainScene = gvrContext.getMainScene(); try { mCharacter = gvrContext.getAssetLoader().loadModel(mModelPath, mainScene); mCharacter.getTransform().setPosition(0.0f, -10.0f, -10.0f); mCharacter.getTransform().setRotationByAxis(40.0f, 1.0f, 0.0f, 0.0f); mCharacter.getTransform().setScale(1.5f, 1.5f, 1.5f); mAssimpAnimation = (GVRAnimator) mCharacter.getComponent(GVRAnimator.getComponentType()); mAssimpAnimation.setRepeatMode(GVRRepeatMode.REPEATED); mAssimpAnimation.setRepeatCount(-1); } catch (IOException e) { e.printStackTrace(); mActivity.finish(); mActivity = null; Log.e(TAG, "One or more assets could not be loaded."); } mAssimpAnimation.start(); }
private GVRAnimator setupAnimation(GVRSceneObject root) { GVRSceneObject baseObject = mObjectRoot.getSceneObjectByName("Sloth_face"); GVRMeshMorph morph = (GVRMeshMorph)baseObject.getComponent(GVRMeshMorph.getComponentType()); int numBlendShapes = morph.getBlendShapeCount(); float [] keys = generateAnimationKeys(numBlendShapes, animDuration); GVRAnimator animator = (GVRAnimator) root.getComponent(GVRAnimator.getComponentType()); if (animator == null) { animator = new GVRAnimator(root.getGVRContext()); root.attachComponent(animator); } GVRMorphAnimation morphAnim = new GVRMorphAnimation(morph, keys, numBlendShapes + 1); animator.addAnimation(morphAnim); animator.setRepeatMode(GVRRepeatMode.PINGPONG); animator.setRepeatCount(1000); return animator; }
private GVRScene createRenderToTextureScene() { final GVRScene newScene = new GVRScene(getGVRContext()); final GVRPerspectiveCamera centerCamera = newScene.getMainCameraRig().getCenterCamera(); centerCamera.setBackgroundColor(0.7f, 0.4f, 0, 1); try { final GVRSceneObject model = getGVRContext().getAssetLoader().loadModel("astro_boy.dae", newScene); model.getTransform() .setRotationByAxis(45.0f, 0.0f, 1.0f, 0.0f) .setScale(2, 2, 2) .setPosition(0.0f, -0.15f, -0.3f); GVRAnimator animations = (GVRAnimator) model.getComponent(GVRAnimator.getComponentType()); if (animations != null) { animations.setRepeatMode(GVRRepeatMode.REPEATED); animations.setRepeatCount(-1); animations.start(); } } catch (final IOException e) { Log.e(TAG, "Failed to load a model: %s", e); getGVRContext().getActivity().finish(); } return newScene; }