public void Load() {
    mCamera = new Camera(GetGameWindow());

    Light.Load(mGameWindow.Width(), mGameWindow.Height());
    ComplexPolygon.Load(mGameWindow.Width(), mGameWindow.Height());

    mShadowMask = new Texture(mGameWindow.Width(), mGameWindow.Height());

    try {
      mShadowMaskObject = new FrameBufferObject(mShadowMask);
    } catch (Exception e) {
      e.printStackTrace();
    }

    mCamera.ForceScaleFocus((mGameWindow.Width() / 1600.0f + mGameWindow.Height() / 900.0f) / 2);

    mAmbientLighting = 0.0f;
  }
Example #2
0
  public void addTexture(BufferedImage img, Vector2f[] v) {
    subimages.add(img);

    coordinates.add(v[0]);
    coordinates.add(v[1]);
    coordinates.add(v[2]);

    Vector2f drawloc = new Vector2f();

    for (boolean done = false; !done; ) {
      try {
        drawloc = tg.nearestSpace(img);
        done = true;
      } catch (Exception e) {
        if (e.getLocalizedMessage() == "enlarge") {
          atlas =
              new BufferedImage(
                  atlas.getWidth() * 2, atlas.getHeight() * 2, BufferedImage.TYPE_INT_ARGB);
          tg.enlarge(atlas);
          for (int i = 0; i < drawingcoords.size(); i++) {
            tg.useup(drawingcoords.get(i), subimages.get(i));
          }
        }
      }
    }
    drawingcoords.add(drawloc);

    atlasgraphics = atlas.getGraphics();

    atlasgraphics.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    atlasgraphics.fillRect(0, 0, atlas.getWidth(), atlas.getHeight());

    for (int i = 0; i < drawingcoords.size(); i++) {
      atlasgraphics.drawImage(
          (Image) subimages.get(i),
          (int) drawingcoords.get(i).x,
          (int) drawingcoords.get(i).y,
          null);
    }

    realtexcoods.clear();

    for (int i = 0; i < subimages.size(); i++) {
      Vector2f vec = new Vector2f();

      vec =
          converttoimagesizes(
              coordinates.get(i * 3), drawingcoords.get(i), subimages.get(i), atlas);
      realtexcoods.add(vec);

      vec =
          converttoimagesizes(
              coordinates.get((i * 3) + 1), drawingcoords.get(i), subimages.get(i), atlas);
      realtexcoods.add(vec);

      vec =
          converttoimagesizes(
              coordinates.get((i * 3) + 2), drawingcoords.get(i), subimages.get(i), atlas);
      realtexcoods.add(vec);
    }

    tg.useup(drawloc, img);

    TextureUtils util = new TextureUtils();
    util.binddata(atlas, texID);

    //		File outputfile = new File("saved @ " + this.hashCode() + ".png");
    //	    try {
    //			ImageIO.write(atlas, "png", outputfile);
    //		} catch (IOException e) {
    //			e.printStackTrace();
    //		}
  }