示例#1
0
  @Override
  public void initScene() {
    mMainQuadMaterial = new Material();
    mMainQuadMaterial.setColorInfluence(0);

    mMiniQuadMaterial = new Material();
    mMiniQuadMaterial.setColorInfluence(0);

    mMainQuad = new WorkaroundScreenQuad();
    mMainQuad.setMaterial(mMainQuadMaterial);
    mMainQuad.setTransparent(true);

    // Set-up viewport dimensions of mini quad for touch event processing
    setupMiniTouchLimits();

    mMiniQuad = new WorkaroundScreenQuad();
    // Set the size of the mini view using a scale factor (mPipScale times the main view)
    mMiniQuad.setScale(mPipScale);
    // Position the mini view in the top right corner
    // For X and Y, the position is:
    //   50% screen shift to the right/top minus half the size of the minimap to bring it back
    //   left/bottom into full view plus a little bit more left/bottom to leave margin
    mMiniQuad.setX(.5d - mPipScale / 2d - mPipMarginX / mDefaultViewportWidth);
    mMiniQuad.setY(.5d - mPipScale / 2d - mPipMarginY / mDefaultViewportHeight);
    mMiniQuad.setMaterial(mMiniQuadMaterial);

    mMainRenderTarget =
        new RenderTarget("pipMainRT", mDefaultViewportWidth, mDefaultViewportHeight);
    mMainRenderTarget.setFullscreen(false);
    mMiniRenderTarget =
        new RenderTarget("pipMiniRT", mDefaultViewportWidth, mDefaultViewportHeight);
    mMiniRenderTarget.setFullscreen(false);

    addRenderTarget(mMainRenderTarget);
    addRenderTarget(mMiniRenderTarget);

    mCompositeScene = getCurrentScene();
    mCompositeScene.addChild(mMainQuad);
    mCompositeScene.addChild(mMiniQuad);

    try {
      mMiniQuadMaterial.addTexture(mMiniRenderTarget.getTexture());
      mMainQuadMaterial.addTexture(mMainRenderTarget.getTexture());
    } catch (ATexture.TextureException e) {
      e.printStackTrace();
    }
    // Init main scene
    mMainRenderer.initScene();

    // Init mini scene
    mMiniRenderer.initScene();
  }
示例#2
0
  @Override
  public void onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    // If the event falls into the mini scene, forward the event to the mini renderer
    // TODO(adamantivm) See if there is a way to delegate the calculation of whether a click
    // falls inside a Quad or not, so that we don't have to do the calculation ourselves
    if (x > mMiniXmin && x < mMiniXmax && y > mMiniYmin && y < mMiniYmax) {
      mMiniRenderer.onTouchEvent(event);
      // Otherwise dispatch it to the main renderer
    } else {
      mMainRenderer.onTouchEvent(event);
    }
  }
示例#3
0
  @Override
  protected void onRender(final long ellapsedTime, final double deltaTime) {
    try {
      // Render mini scene into mini quad
      switchSceneDirect(mMiniRenderer.getCurrentScene());
      mMiniRenderer.doRender();
      setRenderTarget(mMiniRenderTarget);
      render(ellapsedTime, deltaTime);

      // Render main scene into main quad
      switchSceneDirect(mMainRenderer.getCurrentScene());
      mMainRenderer.doRender();
      setRenderTarget(mMainRenderTarget);
      render(ellapsedTime, deltaTime);

      // Render everything into the surface
      switchSceneDirect(mCompositeScene);
      setRenderTarget(null);
      render(ellapsedTime, deltaTime);
    } catch (Throwable t) {
      Log.e(TAG, "Exception in render loop.", t);
    }
  }