示例#1
0
  static {
    // static initializer that creates a mesh blueprint and loads the
    // textures.
    try {
      SimpleStream ss = new SimpleStream("data/weapon.jpg");
      TextureManager.getInstance().addTexture("weapon", new Texture(ss.getStream()));
      ss.close();

      ss = new SimpleStream("data/snork.md2");
      bluePrint = new ClientObject(Loader.loadMD2(ss.getStream(), 0.22f)); // 0.32f
      bluePrint.translate(0, 4.5f, 0);
      bluePrint.translateMesh();
      bluePrint.getTranslationMatrix().setIdentity();
      bluePrint.translate(100000, 100000, 100000);

      sphereBluePrint = Primitives.getSphere(9, 6);
      sphereBluePrint.build();
      sphereBluePrint.setTexture("shield");

      sphereBluePrint.calcTextureWrapSpherical();

      ss.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
    @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;
        }
      }
    }
示例#3
0
  static {
    try {
      SimpleStream ss = new SimpleStream("data/crate.3ds");
      bluePrint = new ClientObject(Loader.load3DS(ss.getStream(), 0.09f)[0]);
      ss.close();
      bluePrint.translate(0, -4.3f, -5);
      bluePrint.translateMesh();
      bluePrint.getTranslationMatrix().setIdentity();
      TextureInfo ti = null;
      if (!Globals.normalMapping) {
        bluePrint.setTexture("crate");
      } else {
        ti = new TextureInfo(TextureManager.getInstance().getTextureID("crate"));
        ti.add(
            TextureManager.getInstance().getTextureID("cratenormals"), TextureInfo.MODE_MODULATE);
        bluePrint.setTexture(ti);
      }

      bluePrint.getMesh().compress();
      bluePrint.build();

      Object3D child = null;
      Animation anim = new Animation(6);
      anim.setClampingMode(Animation.USE_CLAMPING);
      anim.createSubSequence("explosion");

      Loader.setVertexOptimization(false);

      for (int i = 1; i < 6; i++) {
        String name = "data/crate" + i + ".3ds";
        ss = new SimpleStream(name);
        Object3D obj = Loader.load3DS(ss.getStream(), 4.4050189f)[0];
        ss.close();
        obj.translate(0, -5f, -0.6f);
        obj.translateMesh();
        obj.getTranslationMatrix().setIdentity();
        if (!Globals.normalMapping) {
          obj.setTexture("crate");
        } else {
          obj.setTexture(ti);
        }
        obj.build();

        if (i == 1) {
          child = obj;
          child.setMesh(child.getMesh().cloneMesh(true));
        }
        obj.getMesh().compress();
        anim.addKeyFrame(obj.getMesh());
      }
      child.setAnimationSequence(anim);

      Loader.setVertexOptimization(true);

      childBluePrint = child;

      /*
       * for (int i=0; i<child.getMesh().getBoundingBox().length; i++) {
       * System.out.print(child.getMesh().getBoundingBox()[i]);
       * System.out.println("="+bluePrint.getMesh().getBoundingBox()[i]);
       * }
       */
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#4
0
文件: Car.java 项目: embix/Tectonicus
 static {
   /** Load all the textures required by this entity */
   Texture spot = new Texture("textures" + File.separatorChar + "spot.jpg");
   TextureManager.getInstance().addTexture("car", spot);
 }