Esempio n. 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    Logger.log("onCreate");
    if (master != null) {
      copy(master);
    }
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mGLView = new GLSurfaceView(getApplication());
    mGLView.setEGLConfigChooser(
        new GLSurfaceView.EGLConfigChooser() {
          public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
            // Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
            // back to Pixelflinger on some device (read: Samsung I7500)
            int[] attributes = new int[] {EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
            EGLConfig[] configs = new EGLConfig[1];
            int[] result = new int[1];
            egl.eglChooseConfig(display, attributes, configs, 1, result);
            return configs[0];
          }
        });
    mGLView.setLayoutParams(
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT));
    mGLView.setRenderer(new BRenderer());

    this.setContentView(mGLView);
    wakeLock = getWakeLock(this, TAG);
  }
Esempio n. 2
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    Logger.log("onCreate");
    super.onCreate(savedInstanceState);

    if (scene == null) scene = new RenderableScene(this);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    this.mGLView = new GLSurfaceView(this.getApplication());
    this.mGLView.setEGLConfigChooser(
        new GLSurfaceView.EGLConfigChooser() {
          @Override
          public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
            // Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
            // back to Pixelflinger on some device (read: Samsung I7500)
            final int[] attributes = new int[] {EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
            final EGLConfig[] configs = new EGLConfig[1];
            final int[] result = new int[1];
            egl.eglChooseConfig(display, attributes, configs, 1, result);
            return configs[0];
          }
        });

    this.mGLView.setRenderer(scene);

    this.setContentView(this.mGLView);
    this.addContentView(
        this.getLayoutInflater().inflate(R.layout.activity_main, null),
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  }
Esempio n. 3
0
 private void copy(Object src) {
   try {
     Logger.log("Copying data from master Activity!");
     Field[] fs = src.getClass().getDeclaredFields();
     for (Field f : fs) {
       f.setAccessible(true);
       f.set(this, f.get(src));
     }
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Esempio n. 4
0
    @Override
    public void onDrawFrame(GL10 gl) {
      //            if (touchTurn != 0) {
      //                cube.rotateY(touchTurn);
      //                touchTurn = 0;
      //            }
      //
      //            if (touchTurnUp != 0) {
      //                cube.rotateX(touchTurnUp);
      //                touchTurnUp = 0;
      //            }
      //  up++;
      if (up == 1 && cnt > 330) {
        up = -1;

      } else if (up == -1 && cnt < -130) {
        up = 1;
      }
      cnt += up;

      for (byte i = 0; i < BUBBLES; i++) {

        float x = i == 0 ? 0.08f * up : 0.0f;
        float y = i == 1 ? 0.15f * up : 0.0f;

        bubbles[i].translate(
            i == 3 ? -(0.1f * up) : x, /*translate[0] +*/ i == 2 ? -(0.15f * up) : y, 0.0f);
        // bubbles[i].scale(0.01f);
        //  bubbles[i].animate(3 * x);
      }

      fb.clear(/*back*/ );
      world.renderScene(fb);
      world.draw(fb);
      fb.display();

      if (System.currentTimeMillis() - time >= 1000) {
        Logger.log(fps + "fps");
        fps = 0;
        time = System.currentTimeMillis();
      }
      fps++;
    }
Esempio n. 5
0
  public void onDrawFrame(GL10 gl) {

    if (Util.touchTurn != 0) {
      obj1.rotateY(Util.touchTurn);
      Util.touchTurn = 0;
    }

    if (Util.touchTurnUp != 0) {
      obj1.rotateX(Util.touchTurnUp);
      Util.touchTurnUp = 0;
    }

    fb.clear(back);
    world.renderScene(fb);
    world.draw(fb);
    fb.display();

    if (System.currentTimeMillis() - time >= 1000) {
      Logger.log(fps + "fps");
      fps = 0;
      time = System.currentTimeMillis();
    }
    fps++;
  }
Esempio n. 6
0
    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
      if (fb != null) {
        fb.dispose();
      }
      fb = new FrameBuffer(gl, width, height);

      if (master == null) {

        world = new World();
        world.setAmbientLight(20, 20, 20);

        sun = new Light(world);
        sun.setIntensity(250, 250, 250);

        Texture texture =
            new Texture(BitmapHelper.convert(getResources().getDrawable(R.drawable.bublebgnd)));
        TextureManager.getInstance().addTexture("bublebgnd", texture);

        // Create a texture out of the icon...:-)
        texture =
            new Texture(
                BitmapHelper.rescale(
                    BitmapHelper.convert(getResources().getDrawable(R.drawable.icon)), 64, 64));
        TextureManager.getInstance().addTexture("tex", texture);

        bubbles = new Object3D[BUBBLES];
        for (byte i = 0; i < BUBBLES; i++) {
          Object3D bubble = Primitives.getSphere(8);
          bubble.calcTextureWrapSpherical();
          // bubble.setCulling(true);
          bubble.translate(-30 + i * 20, 30.0f, 0.0f);
          bubble.setTransparency(70);
          //  bubble.rotateX(-(float) Math.PI / Math.abs(r.nextInt()/3));
          bubble.setTexture("tex");
          bubble.strip();
          bubble.build();

          bubbles[i] = bubble;
        }

        background = Primitives.getPlane(1, 110f);
        // background.$
        // background.calcTextureWrapSpherical();
        background.setTexture("bublebgnd");
        background.strip();
        background.build();

        world.addObject(background);

        // world.
        world.addObjects(bubbles);

        Camera cam = world.getCamera();
        cam.moveCamera(Camera.CAMERA_MOVEOUT, 70);
        cam.lookAt(background.getTransformedCenter());
        //  cam.lookAt(bubbles.getTransformedCenter());

        SimpleVector sv = new SimpleVector();
        sv.set(background.getTransformedCenter());
        sv.y -= 100;
        sv.z -= 100;
        sun.setPosition(sv);
        MemoryHelper.compact();

        if (master == null) {
          Logger.log("Saving master Activity!");
          master = BubblesActivity.this;
        }
      }
    }