Package org.spout.math.vector

Examples of org.spout.math.vector.Vector3f


      event.getMessages().add(pspMsg);
      first = false;
    }
    Point p = event.getTransform().getPosition();
    Quaternionf rot = event.getTransform().getRotation();
    final Vector3f axesAngles = rot.getAxesAngleDeg();
    PlayerPositionLookMessage PPLMsg = new PlayerPositionLookMessage(p.getX(), p.getY() + STANCE, p.getZ(), p.getY(), axesAngles.getY(), axesAngles.getX(), true, VanillaBlockDataChannelMessage.CHANNEL_ID, getRepositionManager());
    event.getMessages().add(PPLMsg);
  }
View Full Code Here


    }
    CuboidBlockMaterialBuffer b = buffers[xi][yi][zi];
    if (buffers[xi][yi][zi] == null) {
      return null;
    }
    Vector3f base = b.getBase();
    return b.get(x + base.getFloorX(), y + base.getFloorY(), z + base.getFloorZ());
  }
View Full Code Here

  }

  @Override
  protected void generateTerrain(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomes, long seed) {
    PERLIN.setSeed((int) seed);
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX();
    final int sizeY = size.getFloorY();
    final int sizeZ = size.getFloorZ();
    final double[][][] noise = WorldGeneratorUtils.fastNoise(NOISE, sizeX, sizeY, sizeZ, 4, x, y, z);
    final BiomeSelector selector = getSelector();
    final TIntPairObjectHashMap<NormalBiome> biomeCache = new TIntPairObjectHashMap<NormalBiome>();
    for (int xx = 0; xx < sizeX; xx++) {
      for (int zz = 0; zz < sizeZ; zz++) {
View Full Code Here

  private static interface LightGenerator {
    public int getEmittedLight(int x, int y, int z);
  }

  private static void log(String message, int x, int y, int z, CuboidBlockMaterialBuffer[][][] material, VanillaCuboidLightBuffer[][][] light, BlockMaterial[][][] localMaterials, int[][][] localLight) {
    Vector3f base = material[1][1][1].getBase();
    x += base.getFloorX();
    y += base.getFloorY();
    z += base.getFloorZ();
    Spout.getLogger().info(message + " at " + x + ", " + y + ", " + z);
    Spout.getLogger().info(getCuboid(localLight, localMaterials));
  }
View Full Code Here

  @Override
  public void populate(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomes, long seed) {
    final int cx = x >> Chunk.BLOCKS.BITS;
    final int cz = z >> Chunk.BLOCKS.BITS;
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX() >> Chunk.BLOCKS.BITS;
    final int sizeZ = size.getFloorZ() >> Chunk.BLOCKS.BITS;
    final Random worldRandom = new Random(seed);
    final long firstSeed = worldRandom.nextLong();
    final long secondSeed = worldRandom.nextLong();
    for (int cxx = 0; cxx < sizeX; cxx++) {
      for (int czz = 0; czz < sizeZ; czz++) {
        int dcx = cx + cxx;
        int dcz = cz + czz;
        for (int cxxx = -OVERLAP; cxxx <= OVERLAP; cxxx++) {
          for (int czzz = -OVERLAP; czzz <= OVERLAP; czzz++) {
            int dcxx = dcx + cxxx;
            int dczz = dcz + czzz;
            populate(blockData,
                new Vector3f(dcxx << Chunk.BLOCKS.BITS, y, dczz << Chunk.BLOCKS.BITS),
                new Vector3f(dcx << Chunk.BLOCKS.BITS, y, dcz << Chunk.BLOCKS.BITS),
                new Random((dcxx * firstSeed) ^ (dczz * secondSeed) ^ seed));
          }
        }
      }
    }
View Full Code Here

    if (random.nextInt(50) != 0) {
      return;
    }

    final Vector3f target = new Vector3f(chunk.getX() + random.nextInt(16),
        random.nextInt(random.nextInt(40) + 8) + 20, chunk.getZ() + random.nextInt(16));
    final double randomHorizontalAngle = random.nextDouble() * Math.PI * 2;
    final double randomVerticalAngle = ((random.nextDouble() - 0.5) * 2) / 8;
    final double horizontalScale = (random.nextDouble() * 2 + random.nextDouble()) * 2;
    generateRavineNodes(blockData, originChunk, target, horizontalScale, 3, randomHorizontalAngle, randomVerticalAngle, 0, 0, random);
View Full Code Here

  }

  private void generateRavineNodes(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 boolean lastNode;

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

    final double[] horizontalScales = new double[128];

    for (short y = 0; y < 128; y++) {
      final double xzScale = y == 0 || random.nextInt(3) == 0 ? 1 + random.nextDouble() * random.nextDouble() : 1;
      horizontalScales[y] = xzScale * xzScale;
    }

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

      horizontalSize *= random.nextDouble() * 0.25 + 0.75;
      verticalSize *= random.nextDouble() * 0.25 + 0.75;

      verticalAngle *= 0.7;
      verticalAngle += verticalOffset * 0.05;
      horizontalAngle += horizontalOffset * 0.05;
      verticalOffset *= 0.8;
      horizontalOffset *= 0.5;
      verticalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 2;
      horizontalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 4;

      if (!lastNode && 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 RavineNode node = new RavineNode(blockData, chunk, start, end, target, verticalSize, horizontalSize, horizontalScales);

      if (node.canPlace()) {
        node.place();
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

  }

  @Override
  protected void generateTerrain(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager manager, long seed) {
    PERLIN.setSeed((int) seed * 31);
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX();
    final int sizeY = size.getFloorY();
    final int sizeZ = size.getFloorZ();
    final double[][][] noise = WorldGeneratorUtils.fastNoise(NOISE, sizeX, sizeY, sizeZ, 4, x, y, z);
    for (int xx = 0; xx < sizeX; xx++) {
      for (int yy = 0; yy < sizeY; yy++) {
        for (int zz = 0; zz < sizeZ; zz++) {
          double density = noise[xx][yy][zz];
View Full Code Here

  @Override
  public void populate(CuboidBlockMaterialBuffer blockData, int x, int y, int z, BiomeManager biomes, long seed) {
    if (y < 0 || y >= NormalGenerator.HEIGHT) {
      return;
    }
    final Vector3f size = blockData.getSize();
    final int sizeX = size.getFloorX();
    final int sizeY = GenericMath.clamp(size.getFloorY(), 0, NormalGenerator.HEIGHT);
    final int sizeZ = size.getFloorZ();
    SHIELD_BASE.setSeed((int) seed * 73);
    SHIELD.setSeed((int) seed * 79);
    final double[][] noise = WorldGeneratorUtils.fastNoise(SHIELD, sizeX, sizeZ, 4, x, 63, z);
    for (int xx = 0; xx < sizeX; xx++) {
      for (int zz = 0; zz < sizeZ; zz++) {
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.