コード例 #1
0
  @Override
  public Set<Vector3> getInteriorPoints(IFieldInteraction projector) {
    Set<Vector3> fieldBlocks = new HashSet<Vector3>();

    Vector3 posScale = projector.getPositiveScale();
    Vector3 negScale = projector.getNegativeScale();

    int xStretch = posScale.intX() + negScale.intX();
    int yStretch = posScale.intY() + negScale.intY();
    int zStretch = posScale.intZ() + negScale.intZ();
    Vector3 translation = new Vector3(0, -0.4, 0);

    for (float x = -xStretch; x <= xStretch; x++) {
      for (float z = -zStretch; z <= zStretch; z++) {
        for (float y = 0; y <= yStretch; y++) {
          Vector3 position = new Vector3(x, y, z).add(translation);

          if (this.isInField(
              projector, Vector3.translate(position, new Vector3((TileEntity) projector)))) {
            fieldBlocks.add(position);
          }
        }
      }
    }

    return fieldBlocks;
  }
コード例 #2
0
  @Override
  public boolean isInField(IFieldInteraction projector, Vector3 position) {
    Vector3 posScale = projector.getPositiveScale().clone();
    Vector3 negScale = projector.getNegativeScale().clone();

    int xStretch = posScale.intX() + negScale.intX();
    int yStretch = posScale.intY() + negScale.intY();
    int zStretch = posScale.intZ() + negScale.intZ();

    Vector3 projectorPos = new Vector3((TileEntity) projector);
    projectorPos.add(projector.getTranslation());
    projectorPos.add(new Vector3(0, -negScale.intY() + 1, 0));

    Vector3 relativePosition = position.clone().subtract(projectorPos);
    relativePosition.rotate(-projector.getRotationYaw(), -projector.getRotationPitch());

    Cuboid region = new Cuboid(negScale.scale(-1), posScale);

    if (region.isIn(relativePosition) && relativePosition.y > 0) {
      if ((1 - (Math.abs(relativePosition.x) / xStretch) - (Math.abs(relativePosition.z) / zStretch)
          > relativePosition.y / yStretch)) {
        return true;
      }
    }

    return false;
  }
コード例 #3
0
  @Override
  public Set<Vector3> getExteriorPoints(IFieldInteraction projector) {
    final Set<Vector3> fieldBlocks = new HashSet<Vector3>();

    final Vector3 posScale = projector.getPositiveScale();
    final Vector3 negScale = projector.getNegativeScale();

    final int xStretch = posScale.intX() + negScale.intX();
    final int yStretch = posScale.intY() + negScale.intY();
    final int zStretch = posScale.intZ() + negScale.intZ();
    final Vector3 translation = new Vector3(0, -negScale.intY(), 0);

    final int inverseThickness = (int) Math.max((yStretch + zStretch) / 4f, 1);
    System.out.println(inverseThickness);

    for (float y = 0; y <= yStretch; y += 1f) {
      for (float x = -xStretch; x <= xStretch; x += 1f) {
        for (float z = -zStretch; z <= zStretch; z += 1f) {
          double yTest = (y / yStretch) * inverseThickness;
          double xzPositivePlane = (1 - (x / xStretch) - (z / zStretch)) * inverseThickness;
          double xzNegativePlane = (1 + (x / xStretch) - (z / zStretch)) * inverseThickness;

          // Positive Positive Plane
          if (x >= 0 && z >= 0 && Math.round(xzPositivePlane) == Math.round(yTest)) {
            fieldBlocks.add(new Vector3(x, y, z).add(translation));
            fieldBlocks.add(new Vector3(x, y, -z).add(translation));
          }

          // Negative Positive Plane
          if (x <= 0 && z >= 0 && Math.round(xzNegativePlane) == Math.round(yTest)) {
            fieldBlocks.add(new Vector3(x, y, -z).add(translation));
            fieldBlocks.add(new Vector3(x, y, z).add(translation));
          }

          // Ground Level Plane
          if (y == 0 && (Math.abs(x) + Math.abs(z)) < (xStretch + yStretch) / 2) {
            fieldBlocks.add(new Vector3(x, y, z).add(translation));
          }
        }
      }
    }

    return fieldBlocks;
  }