예제 #1
0
  @Override
  public void onInit(GVRContext gvrContext) {
    this.gvrContext = gvrContext;
    random = new Random();
    mainScene = gvrContext.getNextMainScene();
    shaderManager = new CustomShaderManager(gvrContext);
    mainScene.getMainCameraRig().getLeftCamera().setBackgroundColor(1.0f, 1.0f, 1.0f, 1.0f);
    mainScene.getMainCameraRig().getRightCamera().setBackgroundColor(1.0f, 1.0f, 1.0f, 1.0f);

    addSurroundings(gvrContext, mainScene);

    // set up the input manager for the main scene
    GVRInputManager inputManager = gvrContext.getInputManager();

    inputManager.addCursorControllerListener(this);

    for (GVRCursorController cursor : inputManager.getCursorControllers()) {
      onCursorControllerAdded(cursor);
    }

    // set the default text
    setTextOnMainThread(SELECT_TEXT);

    GVRViewSceneObject text =
        new GVRViewSceneObject(gvrContext, textView, gvrContext.createQuad(30.0f, 20.0f));
    text.getTransform().setPosition(0.0f, 17.0f, -35.0f);
    text.getRenderData().setRenderingOrder(10002);

    mainScene.addSceneObject(text);

    GVRSceneObject cube1 = new Cube(gvrContext, "Cube 1", shaderManager);
    cube1.getTransform().setPosition(0.0f, 1.0f, -10.0f);
    mainScene.addSceneObject(cube1);
    // add the sensor to the cube
    addSensor(cube1);

    GVRSceneObject cube2 = new Cube(gvrContext, "Cube 2", shaderManager);
    cube2.getTransform().setPosition(0.0f, 1.0f, -12.0f);
    cube2.getTransform().rotateByAxisWithPivot(-15.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
    cube2.getTransform().setRotation(1.0f, 0.0f, 0.0f, 0.0f);
    mainScene.addSceneObject(cube2);
    // add the sensor to the cube
    addSensor(cube2);

    GVRSceneObject cube3 = new Cube(gvrContext, "Cube 3", shaderManager);
    cube3.getTransform().setPosition(0.0f, 1.0f, -15.0f);
    cube3.getTransform().rotateByAxisWithPivot(15.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
    cube3.getTransform().rotateByAxisWithPivot(15.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
    cube3.getTransform().setRotation(1.0f, 0.0f, 0.0f, 0.0f);
    mainScene.addSceneObject(cube3);
    // add the sensor to the cube
    addSensor(cube3);
  }
예제 #2
0
 void close() {
   gvrContext.getInputManager().removeCursorControllerListener(this);
 }