@Override
  public void onInit(GVRContext gvrContext) throws IOException {

    mAnimationEngine = gvrContext.getAnimationEngine();

    mMainScene =
        gvrContext.getNextMainScene(
            new Runnable() {

              @Override
              public void run() {
                for (GVRAnimation animation : mAnimations) {
                  animation.start(mAnimationEngine);
                }
                mAnimations = null;
              }
            });

    // Apply frustum culling
    mMainScene.setFrustumCulling(true);

    GVRCameraRig mainCameraRig = mMainScene.getMainCameraRig();
    mainCameraRig.getLeftCamera().setBackgroundColor(Color.BLACK);
    mainCameraRig.getRightCamera().setBackgroundColor(Color.BLACK);
    mainCameraRig.getTransform().setPosition(0.0f, 0.0f, 0.0f);

    // Model with texture
    GVRSceneObject astroBoyModel = gvrContext.getAssimpModel("astro_boy.dae");

    // Model with color
    GVRSceneObject benchModel = gvrContext.getAssimpModel("bench.dae");

    ModelPosition astroBoyModelPosition = new ModelPosition();

    astroBoyModelPosition.setPosition(0.0f, -0.4f, -0.5f);

    astroBoyModel.getTransform().setScale(3, 3, 3);

    astroBoyModel
        .getTransform()
        .setPosition(astroBoyModelPosition.x, astroBoyModelPosition.y, astroBoyModelPosition.z);
    astroBoyModel.getTransform().setRotationByAxis(180.0f, 0.0f, 1.0f, 0.0f);

    ModelPosition benchModelPosition = new ModelPosition();

    benchModelPosition.setPosition(0.0f, -4.0f, -30.0f);

    benchModel
        .getTransform()
        .setPosition(benchModelPosition.x, benchModelPosition.y, benchModelPosition.z);
    benchModel.getTransform().setRotationByAxis(180.0f, 0.0f, 1.0f, 0.0f);

    mMainScene.addSceneObject(astroBoyModel);
    mMainScene.addSceneObject(benchModel);

    rotateModel(astroBoyModel, 10f, astroBoyModelPosition);
  }
Esempio n. 2
0
  private void setEyeMode(EyeMode newMode, GVRCameraRig cameraRig) {
    eyeMode = newMode;

    GVRCamera leftCamera = cameraRig.getLeftCamera();
    GVRCamera rightCamera = cameraRig.getRightCamera();

    // Remove from both (even if not present) add back later
    leftCamera.removePostEffect(this);
    rightCamera.removePostEffect(this);

    if (eyeMode == EyeMode.LEFT_EYE || eyeMode == EyeMode.BOTH_EYES) {
      leftCamera.addPostEffect(this);
    }
    if (eyeMode == EyeMode.RIGHT_EYE || eyeMode == EyeMode.BOTH_EYES) {
      rightCamera.addPostEffect(this);
    }
  }