Esempio n. 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();
  }
 @Override
 protected void initScene() {
   getCurrentCamera().setFarPlane(1000);
   /** Skybox images by Emil Persson, aka Humus. http://www.humus.name [email protected] */
   try {
     getCurrentScene()
         .setSkybox(
             R.drawable.posx,
             R.drawable.negx,
             R.drawable.posy,
             R.drawable.negy,
             R.drawable.posz,
             R.drawable.negz);
   } catch (ATexture.TextureException e) {
     e.printStackTrace();
   }
 }
    @Override
    protected void initScene() {
      mLight = new DirectionalLight(1.0, 0.2, -1.0); // set the direction
      mLight.setColor(1.0f, 1.0f, 1.0f);
      mLight.setPower(2);

      getCurrentScene().addLight(mLight);

      try {
        Material material = new Material();
        material.addTexture(new Texture("earthColors", R.drawable.earthtruecolor_nasa_big));
        material.setColorInfluence(0);
        mSphere = new Sphere(1, 24, 24);
        mSphere.setMaterial(material);
        getCurrentScene().addChild(mSphere);
      } catch (ATexture.TextureException e) {
        e.printStackTrace();
      }

      getCurrentCamera().setLookAt(0, 0, 0);
      getCurrentCamera().setZ(6);
    }
    @Override
    protected void initScene() {
      DirectionalLight light = new DirectionalLight(0, 0, 1.0);
      light.setPower(2.0f);
      getCurrentScene().addLight(light);

      mPointLight = new PointLight();
      mPointLight.setPower(1.5f);

      getCurrentScene().addLight(mPointLight);

      // -- create sky sphere
      mSphere = new Sphere(400, 8, 8);
      Material sphereMaterial = new Material();
      try {
        sphereMaterial.addTexture(new Texture("skySphere", R.drawable.skysphere));
        sphereMaterial.setColorInfluence(0);
      } catch (ATexture.TextureException e1) {
        e1.printStackTrace();
      }
      mSphere.setMaterial(sphereMaterial);
      mSphere.setDoubleSided(true);
      getCurrentScene().addChild(mSphere);

      mRaptor = new Sphere(1.0f, 24, 24);
      Material raptorMaterial = new Material();
      SpecularMethod.Phong phongMethod = new SpecularMethod.Phong();
      phongMethod.setShininess(180);
      sphereMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
      sphereMaterial.setSpecularMethod(phongMethod);
      sphereMaterial.enableLighting(true);
      mRaptor.setMaterial(raptorMaterial);
      mRaptor.setColor(0xffff00ff);
      getCurrentScene().addChild(mRaptor);

      // -- create a bunch of cubes that will serve as orientation helpers

      mCubes = new Object3D[30];

      mRootCube = new Cube(1);
      Material rootCubeMaterial = new Material();
      rootCubeMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
      rootCubeMaterial.enableLighting(true);
      try {
        rootCubeMaterial.addTexture(new Texture("camouflage", R.drawable.camouflage));
        rootCubeMaterial.setColorInfluence(0);
      } catch (ATexture.TextureException e) {
        e.printStackTrace();
      }
      mRootCube.setMaterial(rootCubeMaterial);
      mRootCube.setY(-1f);
      // -- similar objects with the same material, optimize
      mRootCube.setRenderChildrenAsBatch(true);
      getCurrentScene().addChild(mRootCube);
      mCubes[0] = mRootCube;

      for (int i = 1; i < mCubes.length; ++i) {
        Object3D cube = mRootCube.clone(true);
        cube.setY(-1f);
        cube.setZ(i * 30);
        mRootCube.addChild(cube);
        mCubes[i] = cube;
      }

      // -- create a chase camera
      // the first parameter is the camera offset
      // the second parameter is the interpolation factor
      ChaseCamera chaseCamera = new ChaseCamera(new Vector3(0, 3, 16));
      // -- tell the camera which object to chase
      chaseCamera.setLinkedObject(mRaptor);
      // -- set the far plane to 1000 so that we actually see the sky sphere
      chaseCamera.setFarPlane(1000);
      getCurrentScene().replaceAndSwitchCamera(chaseCamera, 0);
    }