Пример #1
0
  public void render(Screen screen, Camera camera) {
    matrix.idt();
    matrix.setToTranslation(camera.x, camera.y, 0);
    screen.spriteBatch.setTransformMatrix(matrix);
    screen.spriteBatch.begin();
    // g.translate(-camera.x, -camera.y);

    int xo = 0;
    int yo = 0;
    for (int x = xo; x <= xo + camera.width / 10; x++) {
      for (int y = yo; y <= yo + camera.height / 10; y++) {
        if (x >= 0 && y >= 0 && x < width && y < height) {
          int ximg = 0;
          int yimg = 0;
          byte w = walls[x + y * width];
          if (w == 0) yimg = 1;
          if (w == 1) ximg = 0;
          if (w == 2) ximg = 2;
          if (w == 3) ximg = 1;
          if (w == 9) ximg = 7;
          if (w == 8) {
            ximg = 4;
            yimg = 1;
          }
          if (w == 5) {
            ximg = 1;
            yimg = 1;
          }
          if (w == 6) {
            ximg = (tick / 4 + x * 2) & 3;
            yimg = 2;
          }
          if (w == 7) {
            ximg = (-tick / 4 + x * 2) & 3;
            yimg = 3;
          }
          if (w == 4) {
            if (walls[x + (y - 1) * width] == 1) {
              yimg++;
            }
            ximg = 3;
          }

          if (w == 0) continue;

          screen.draw(Art.walls[ximg][yimg], x * 10, y * 10);
        }
      }
    }
    for (int i = entities.size() - 1; i >= 0; i--) {
      Entity e = entities.get(i);
      e.render(screen, camera);
    }

    screen.spriteBatch.end();
  }
Пример #2
0
  public void scale(float x, float y, float z, boolean updateLocal) {
    activate();
    // Set unit scale
    Matrix4 t = modelInstance.transform;
    Matrix4 mat_scale = new Matrix4();
    Vector3 s = new Vector3();
    t.getScale(s);
    mat_scale.scl(1 / s.x, 1 / s.y, 1 / s.z);
    t.mul(mat_scale);

    // Set target scale
    mat_scale.idt();
    mat_scale.scl(x, y, z);
    t.mul(mat_scale);

    // Relevant bullet body update
    CollisionShape cs = body.getCollisionShape();
    cs.setLocalScaling(new Vector3f(x, y, z));
    if (body.isInWorld() && body.isStaticOrKinematicObject()) scene.world.updateSingleAabb(body);

    // Child propagation
    Vector3f ps = scale();
    Matrix4f pt = transform();
    Matrix4f ct = new Matrix4f();
    Matrix4f ms = new Matrix4f();
    ms.setIdentity();
    ms.m00 = ps.x;
    ms.m11 = ps.y;
    ms.m22 = ps.z;
    pt.mul(ms);

    for (GameObject c : children) {
      c.scale(scale().mul(c.localScale), false);
      ct.mul(pt, c.localTransform);
      c.transform(ct, false);
    }

    if (parent != null && updateLocal) {
      updateLocalScale();
    }
  }
Пример #3
0
 @Override
 public void sphere(
     float width,
     float height,
     float depth,
     int divisionsU,
     int divisionsV,
     float angleUFrom,
     float angleUTo,
     float angleVFrom,
     float angleVTo) {
   sphere(
       matTmp1.idt(),
       width,
       height,
       depth,
       divisionsU,
       divisionsV,
       angleUFrom,
       angleUTo,
       angleVFrom,
       angleVTo);
 }
Пример #4
0
 /** Sets the transformation matrix to identity. */
 public void identity() {
   transform.idt();
   matrixDirty = true;
 }