@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 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; }
@Override public void onInit(GVRContext gvrContext) { GVRScene scene = gvrContext.getMainScene(); mScene = scene; GVRCameraRig rig = scene.getMainCameraRig(); mObjectRoot = new GVRSceneObject(gvrContext); rig.getCenterCamera().setBackgroundColor(Color.BLACK); rig.getLeftCamera().setBackgroundColor(Color.BLACK); rig.getRightCamera().setBackgroundColor(Color.BLACK); String filePath = "/sloth/sloth.gltf"; GVRSceneObject light1 = createLight(gvrContext, 1, 1, 1, new Vector3f(0,1.8f, 0)); GVRSceneObject light2 = createLight(gvrContext ,1, 1, 1, new Vector3f(0,-0.8f, 0)); mObjectRoot.addChildObject(light1); mObjectRoot.addChildObject(light2); try { addModeltoScene(filePath, new Vector3f(0.05f,0.05f,0.05f), new Vector3f(0, -8.5f, -6.5f)); } catch (IOException ex) { } scene.addSceneObject(mObjectRoot); GVRAnimator animator = setupAnimation(mObjectRoot); animator.start(); }
mAnimator.start(); mMainScene.setMainCameraRig(newRig);