Package org.spout.math.vector

Examples of org.spout.math.vector.Vector3f


    }
    seed = WorldGeneratorUtils.getSeed(seed, 4324337, 234571, 76537, material.getId());
    elevation.setSeed((int) (seed * 101));
    shapeBase.setSeed((int) (seed * 313));
    shape.setSeed((int) (seed * 661));
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX();
    final int sizeY = GenericMath.clamp(size.getFloorY(), 0, NetherGenerator.HEIGHT);
    final int sizeZ = size.getFloorZ();
    final int scale = sizeY / 2;
    final double[][] displacements = WorldGeneratorUtils.fastNoise(elevation, sizeX, sizeZ, 4, x, 0, z);
    final double[][] values = WorldGeneratorUtils.fastNoise(shape, sizeX, sizeZ, 4, x, 0, z);
    for (int xx = 0; xx < sizeX; xx++) {
      for (int zz = 0; zz < sizeZ; zz++) {
View Full Code Here


    }

    final int numberOfCaves = random.nextInt(random.nextInt(random.nextInt(10) + 1) + 1);

    for (int caveCount = 0; caveCount < numberOfCaves; caveCount++) {
      final Vector3f target = new Vector3f(chunk.getX() + random.nextInt(16),
          random.nextInt(random.nextInt(120) + 8), chunk.getZ() + random.nextInt(16));
      int numberOfSmallCaves = 1;

      if (random.nextInt(4) == 0) {
        generateLargeCaveBranch(blockData, originChunk, target, new Random(random.nextLong()));
View Full Code Here

  }

  private void generateCaveBranch(CuboidBlockMaterialBuffer blockData, Vector3f chunk, Vector3f target, double horizontalScale, double verticalScale,
                  double horizontalAngle, double verticalAngle, int startingNode, int nodeAmount, Random random) {

    final Vector3f middle = new Vector3f(chunk.getX() + 8, 0, chunk.getZ() + 8);
    double horizontalOffset = 0;
    double verticalOffset = 0;
    random = new Random(random.nextLong());

    if (nodeAmount <= 0) {
      final int size = (OVERLAP - 1) * 16;
      nodeAmount = size - random.nextInt(size / 4);
    }

    final int intersectionNode = random.nextInt(nodeAmount / 2) + nodeAmount / 4;
    final boolean extraVerticalScale = random.nextInt(6) == 0;
    final boolean lastNode;

    if (startingNode == -1) {
      startingNode = nodeAmount / 2;
      lastNode = true;
    } else {
      lastNode = false;
    }

    for (; startingNode < nodeAmount; startingNode++) {
      final double horizontalSize = 1.5 + TrigMath.sin((float) (startingNode * Math.PI / nodeAmount)) * horizontalScale;
      final double verticalSize = horizontalSize * verticalScale;
      target = target.add(Vector3f.createDirection((float) horizontalAngle, (float) verticalAngle));

      if (extraVerticalScale) {
        verticalAngle *= 0.92;
      } else {
        verticalAngle *= 0.7;
      }

      verticalAngle += verticalOffset * 0.1;
      horizontalAngle += horizontalOffset * 0.1;
      verticalOffset *= 0.9;
      horizontalOffset *= 0.75;
      verticalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 2;
      horizontalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 4;

      if (!lastNode) {

        if (startingNode == intersectionNode && horizontalScale > 1) {
          generateCaveBranch(blockData, chunk, target, random.nextDouble() * 0.5f + 0.5f, 1, horizontalAngle - ((float) Math.PI / 2), verticalAngle / 3, startingNode, nodeAmount, new Random(random.nextLong()));
          generateCaveBranch(blockData, chunk, target, random.nextDouble() * 0.5f + 0.5f, 1, horizontalAngle + ((float) Math.PI / 2), verticalAngle / 3, startingNode, nodeAmount, new Random(random.nextLong()));
          return;
        }

        if (random.nextInt(4) == 0) {
          continue;
        }
      }

      final double xOffset = target.getX() - middle.getX();
      final double zOffset = target.getZ() - middle.getZ();
      final double nodesLeft = nodeAmount - startingNode;
      final double offsetHorizontalScale = horizontalScale + 18;

      if ((xOffset * xOffset + zOffset * zOffset) - nodesLeft * nodesLeft > offsetHorizontalScale * offsetHorizontalScale) {
        return;
      }

      if (target.getX() < middle.getX() - 16 - horizontalSize * 2
          || target.getZ() < middle.getZ() - 16 - horizontalSize * 2
          || target.getX() > middle.getX() + 16 + horizontalSize * 2
          || target.getZ() > middle.getZ() + 16 + horizontalSize * 2) {
        continue;
      }

      final Vector3f start = new Vector3f(GenericMath.floor(target.getX() - horizontalSize) - chunk.getFloorX() - 1,
          GenericMath.floor(target.getY() - verticalSize) - 1, GenericMath.floor(target.getZ() - horizontalSize) - chunk.getFloorZ() - 1);
      final Vector3f end = new Vector3f(GenericMath.floor(target.getX() + horizontalSize) - chunk.getFloorX() + 1,
          GenericMath.floor(target.getY() + verticalSize) + 1, GenericMath.floor(target.getZ() + horizontalSize) - chunk.getFloorZ() + 1);
      final NetherCaveNode node = new NetherCaveNode(blockData, chunk, start, end, target, verticalSize, horizontalSize);

      if (node.canPlace()) {
        node.place();
View Full Code Here

        && block.translate(BlockFace.TOP).isMaterial(attachTo);
  }

  @Override
  public void placeObject(World w, int x, int y, int z) {
    final Vector3f seed = new Vector3f(x, y, z);
    final List<Growth> growths = new ArrayList<Growth>();
    growths.add(new Growth(w.getBlock(seed)));
    byte count = 0;
    while (!growths.isEmpty() && count < totalSize) {
      final Growth current = growths.get(0);
View Full Code Here

      growths.remove(current);
    }
  }

  private boolean isInBounds(Vector3f seed, Vector3f target) {
    final Vector3f diff = target.sub(seed);
    return Math.abs(diff.getFloorX()) < maxXRadius && Math.abs(diff.getFloorZ()) < maxZRadius
        && diff.getFloorY() > -maxYDepth;
  }
View Full Code Here

        }
      }
    }

    private static Vector3f clamp(Vector3f point) {
      return new Vector3f(
          GenericMath.clamp(point.getFloorX(), 0, 16),
          GenericMath.clamp(point.getFloorY(), 1, 120),
          GenericMath.clamp(point.getFloorZ(), 0, 16));
    }
View Full Code Here

      holder.add(Health.class).setSpawnHealth(20);
    }
    TextModelComponent textModel = getOwner().get(TextModelComponent.class);
    if (textModel != null) {
      textModel.setSize(0.5f);
      textModel.setTranslation(new Vector3f(0, 3f, 0));
    }
    //holder.getPhysics().activate(1, new BoxShape(1f, 2.3f, 1f), false, true);

    // Add metadata associated with the amount of arrows attached to the body
    holder.add(MetadataComponent.class).addMeta(Metadata.TYPE_BYTE, 10, VanillaData.ARROWS_IN_BODY);
View Full Code Here

    final double impulseForce = 0.3;
    final float maxXZForce = 0.02f;
    final float maxYForce = 0.1f;

    // Create a velocity vector using the transform, apply (random) force
    Vector3f impulse = dropFrom.getRotation().getDirection().mul(impulseForce);

    // Random rotational offset to avoid dropping at the same position
    Random rand = GenericMath.getRandom();
    float xzLength = maxXZForce * rand.nextFloat();
    float yLength = maxYForce * (rand.nextFloat() - rand.nextFloat());
    impulse = impulse.add(Vector2f.createRandomDirection(rand).mul(xzLength).toVector3(yLength));

    // Slightly dropping upwards
    impulse = impulse.add(0.0, 0.1, 0.0);

    // Conversion factor, some sort of unit problem
    //TODO: This needs an actual value and this value might change when gravity changes!
    impulse = impulse.mul(100);

    // Finally drop using a 4 second pickup delay
    Item spawnedItem = Item.drop(dropFrom.getPosition(), item, impulse);
    spawnedItem.setUncollectableDelay(4000);
  }
View Full Code Here

  public Block getBlock(int xx, int yy, int zz) {
    return position.getWorld().getBlock(transform(xx, yy, zz));
  }

  public BlockMaterial getBlockMaterial(int xx, int yy, int zz) {
    final Vector3f transformed = transform(xx, yy, zz);
    return position.getWorld().getBlockMaterial(transformed.getFloorX(), transformed.getFloorY(), transformed.getFloorZ());
  }
View Full Code Here

  public void setBlockMaterial(int xx, int yy, int zz, BlockMaterial material) {
    setBlockMaterial(xx, yy, zz, material, material.getData());
  }

  public void setBlockMaterial(int xx, int yy, int zz, BlockMaterial material, short data) {
    final Vector3f transformed = transform(xx, yy, zz);
    position.getWorld().setBlockMaterial(transformed.getFloorX(), transformed.getFloorY(), transformed.getFloorZ(),
        material, data, null);
    if (material instanceof Directional) {
      final Directional directional = (Directional) material;
      final Block block = position.getWorld().getBlock(transformed);
      final BlockFace face = directional.getFacing(block);
View Full Code Here

TOP

Related Classes of org.spout.math.vector.Vector3f

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.