Package org.spout.math.vector

Examples of org.spout.math.vector.Vector3f


    Player player = (Player) getOwner();
    Transform ts = player.getPhysics().getTransform();
    PlayerInputState inputState = player.input();
    PhysicsComponent sc = player.getPhysics();

    Vector3f offset = Vector3f.ZERO;
    float speed = 50;
    if (inputState.getForward()) {
      offset = offset.sub(ts.forwardVector().mul(speed * dt));
    }
    if (inputState.getBackward()) {
      offset = offset.add(ts.forwardVector().mul(speed * dt));
    }
    if (inputState.getLeft()) {
      offset = offset.sub(ts.rightVector().mul(speed * dt));
    }
    if (inputState.getRight()) {
      offset = offset.add(ts.rightVector().mul(speed * dt));
    }
    if (inputState.getJump()) {
      offset = offset.add(ts.upVector().mul(speed * dt));
    }
    if (inputState.getCrouch()) {
      offset = offset.sub(ts.upVector().mul(speed * dt));
    }

    player.get(EntityHead.class).setOrientation(Quaternionf.fromAxesAnglesDeg(inputState.pitch(), inputState.yaw(), ts.getRotation().getAxesAngleDeg().getZ()));
    player.getPhysics().translate(offset);
    player.getPhysics().setRotation(Quaternionf.fromAxesAnglesDeg(inputState.pitch(), inputState.yaw(), ts.getRotation().getAxesAngleDeg().getZ()));
View Full Code Here


        final int by = -3 + branchLengthCount / 2;
        final int bz = (int) (randomOffset.getY() * branchLengthCount + 1.5f);
        final Block block = w.getBlock(x + bx, y + yy + by, z + bz);
        block.setMaterial(VanillaMaterials.LOG);
        block.setData(logMetadata);
        VanillaMaterials.LOG.setFacing(block, BlockFace.fromYaw(MathHelper.getLookAtYaw(new Vector3f(bx, by, bz))));
      }
    }
    for (byte yy = -1; yy < totalHeight - 1; yy++) {
      for (byte xx = 0; xx < 2; xx++) {
        for (byte zz = 0; zz < 2; zz++) {
View Full Code Here

    }

    final int numberOfCaves = random.nextInt(random.nextInt(random.nextInt(40) + 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;

    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 && nodeAmount > 0) {
          generateCaveBranch(blockData, chunk, target, random.nextDouble() * 0.5 + 0.5, 1, horizontalAngle - Math.PI / 2, verticalAngle / 3, startingNode, nodeAmount, new Random(random.nextLong()));
          generateCaveBranch(blockData, chunk, target, random.nextDouble() * 0.5 + 0.5, 1, horizontalAngle + 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 CaveNode node = new CaveNode(blockData, chunk, start, end, target, verticalSize, horizontalSize);

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

    }
    if (addCocoaPlants) {
      if (totalHeight >= 6 && random.nextInt(5) == 0) {
        for (byte yy = 0; yy < 2; yy++) {
          final byte odd = (byte) (4 - yy);
          final Vector3f position = new Vector3f(x, y + yy + totalHeight - 5, z);
          for (BlockFace face : BlockFaces.NSEW) {
            if (random.nextInt(odd) != 0) {
              continue;
            }
            final Block block = w.getBlock(position.add(face.getOffset()));
            block.setMaterial(VanillaMaterials.COCOA_PLANT);
            VanillaMaterials.COCOA_PLANT.setAttachedFace(block, face.getOpposite(), null);
            VanillaMaterials.COCOA_PLANT.setGrowthStage(block, random.nextInt(3));
          }
        }
View Full Code Here

    setBlockMaterial(10, -10, 13, Sandstone.DECORATIVE);
    setBlockMaterial(10, -11, 13, Sandstone.SMOOTH);
    // Place the loot chests
    chestObject.setRandom(getRandom());
    for (BlockFace face : BlockFaces.NSEW) {
      final Vector3f chestPos = face.getOffset().mul(2).add(10, -11, 10);
      placeObject(chestPos.getFloorX(), chestPos.getFloorY(), chestPos.getFloorZ(), chestObject);
    }
  }
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

public class BedrockBoundPopulator implements GeneratorPopulator {
  private final List<BedrockBound> bounds = new ArrayList<BedrockBound>();

  @Override
  public void populate(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomes, long seed) {
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX();
    final int sizeY = size.getFloorY();
    final int sizeZ = size.getFloorZ();
    final int bufferStart = y;
    final int bufferEnd = bufferStart + sizeY;
    for (BedrockBound bound : bounds) {
      final int bedrockStart = bound.getStart();
      final int bedrockEnd = bound.getEnd();
View Full Code Here

  private void generateBranches(World world, int x, int y, int z, List<PointBase> groups) {
    for (PointBase group : groups) {
      final int baseY = group.getBase();
      if (baseY - y >= totalHeight * 0.2) {
        final Point base = new Point(world, x, baseY, z);
        final Vector3f angles = Quaternionf.fromRotationTo(Vector3f.FORWARD, group.sub(base)).getAxesAngleDeg();
        final BlockFace facing;
        if (angles.getX() < 135) {
          facing = BlockFace.fromYaw(angles.getY());
        } else {
          facing = BlockFace.TOP;
        }
        final BlockIterator branch = new BlockIterator(base, group);
        while (branch.hasNext()) {
View Full Code Here

  public double getZ() {
    return z;
  }

  public Vector3f getPosition() {
    return new Vector3f(x, y, z);
  }
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.