@Override
  protected void initScene() {
    // Remember to call super.initScene() to allow TangoRajawaliArRenderer to set-up
    super.initScene();

    // Add a directional light in an arbitrary direction
    DirectionalLight light = new DirectionalLight(1, 0.2, -1);
    light.setColor(1, 1, 1);
    light.setPower(0.8f);
    light.setPosition(3, 2, 4);
    getCurrentScene().addLight(light);

    // Set-up a material: green with application of the light
    Material material = new Material();
    material.setColor(0xff009900);
    material.enableLighting(true);
    material.setDiffuseMethod(new DiffuseMethod.Lambert());

    // Build a pyramid and place it roughly in front and a bit to the right
    Object3D object1 = new NPrism(4, 0f, 0.2f, 0.2f);
    object1.setMaterial(material);
    object1.setPosition(-0.25, 0, -1);
    getCurrentScene().addChild(object1);

    // Build a sphere and place it roughly in front and a bit to the left
    object1 = new Sphere(0.1f, 24, 24);
    object1.setMaterial(material);
    object1.setPosition(0.25, 0, -1);
    getCurrentScene().addChild(object1);
  }
    @Override
    protected void initScene() {
      try {
        DirectionalLight light = new DirectionalLight();
        light.setLookAt(1, -1, 1);
        light.enableLookAt();
        light.setPower(1.5f);
        getCurrentScene().addLight(light);

        light = new DirectionalLight();
        light.setLookAt(-1, 1, -1);
        light.enableLookAt();
        light.setPower(1.5f);
        getCurrentScene().addLight(light);

        DebugVisualizer debugViz = new DebugVisualizer(this);
        debugViz.addChild(new GridFloor());
        getCurrentScene().addChild(debugViz);

        final LoaderAWD parser =
            new LoaderAWD(mContext.getResources(), mTextureManager, R.raw.awd_suzanne);
        parser.parse();

        final Object3D monkey = parser.getParsedObject();

        Material material = new Material();
        material.enableLighting(true);
        material.setDiffuseMethod(new DiffuseMethod.Lambert());
        material.setColor(0x990000);

        monkey.setMaterial(material);
        getCurrentScene().addChild(monkey);

        material = new Material();
        material.enableLighting(true);
        material.setDiffuseMethod(new DiffuseMethod.Lambert());
        material.setColor(0x999900);

        Object3D monkey2 = monkey.clone();
        monkey2.setMaterial(material);
        monkey2.setPosition(-3, 3, 3);
        getCurrentScene().addChild(monkey2);

        ArcballCamera arcball =
            new ArcballCamera(mContext, ((Activity) mContext).findViewById(R.id.content_frame));
        arcball.setPosition(4, 4, 4);
        getCurrentScene().replaceAndSwitchCamera(getCurrentCamera(), arcball);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  @Override
  public void initScene() {
    getCurrentScene().setBackgroundColor(Color.GRAY);

    Object3D o = new Sphere(1, 10, 10);
    o.setMaterial(new Material());
    o.setColor(Color.RED);
    o.setPosition(-1, 0, 0);
    getCurrentScene().addChild(o);

    o = new Sphere(1, 10, 10);
    o.setMaterial(new Material());
    o.setColor(Color.GREEN);
    o.setPosition(0, 0, 0);
    getCurrentScene().addChild(o);

    o = new Sphere(1, 10, 10);
    o.setMaterial(new Material());
    o.setColor(Color.BLUE);
    o.setPosition(1, 0, 0);
    getCurrentScene().addChild(o);
  }
    @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);
    }
Exemplo n.º 5
0
    @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);
    }