use of javax.vecmath.Vector2d in project Solar by Martacus.
the class StructForgottenAltar method generateOverworld.
@Override
public void generateOverworld(World world, Random rand, int x, int z) {
int randomX = x + rand.nextInt(16);
int randomZ = z + rand.nextInt(16);
int randomY = 90;
int chunkX = x / 16;
int chunkZ = z / 16;
BlockPos blockpos = new BlockPos(randomX, randomY, randomZ);
Biome biome = world.getBiomeForCoordsBody(blockpos);
if (!BiomeDictionary.hasType(biome, BiomeDictionary.Type.PLAINS) && !BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY) && !BiomeDictionary.hasType(biome, BiomeDictionary.Type.SAVANNA)) {
return;
}
if (!isNumberAwayOf(5, chunkX, (int) this.lastChunkGenerated.x) || !isNumberAwayOf(5, chunkZ, (int) this.lastChunkGenerated.y)) {
return;
}
chunksNotSpawned++;
if (chunksNotSpawned < 100) {
return;
}
chunksNotSpawned = 0;
this.lastChunkGenerated = new Vector2d(chunkX, chunkZ);
for (int y = 255; y > 0; y--) {
Block block = world.getBlockState(new BlockPos(randomX, y, randomZ)).getBlock();
if (block != Blocks.AIR && block != Blocks.WATER && block != Blocks.FLOWING_WATER && block != Blocks.LEAVES && block != Blocks.LEAVES2 && block != Blocks.LAVA && block != Blocks.TALLGRASS) {
world.setBlockState(new BlockPos(randomX, y + 1, randomZ), ModBlocks.BROKEN_ALTAR.getDefaultState());
spawnAltarRuins(world, randomX, y + 1, randomZ);
return;
}
}
}
use of javax.vecmath.Vector2d in project Solar by Martacus.
the class StructForgottenAltar method spawnAltarRuins.
private void spawnAltarRuins(World world, int x, int y, int z) {
Random random = new Random();
for (Vector2d vec : this.ruinLocations) {
int yCoord = y;
BlockPos checkPos = new BlockPos(x + vec.getX(), yCoord - 1, z + vec.getY());
while (world.getBlockState(checkPos).getBlock() == Blocks.AIR || world.getBlockState(checkPos).getBlock() == Blocks.WATER || world.getBlockState(checkPos).getBlock() == Blocks.FLOWING_WATER || world.getBlockState(checkPos).getBlock() == Blocks.LEAVES || world.getBlockState(checkPos).getBlock() == Blocks.LEAVES2 || world.getBlockState(checkPos).getBlock() == Blocks.LAVA || world.getBlockState(checkPos).getBlock() == Blocks.TALLGRASS) {
yCoord--;
if (yCoord <= 0) {
yCoord = 1;
break;
}
}
int amountOfBlocks = random.nextInt(6);
for (int i = 0; i < amountOfBlocks; i++) {
if (random.nextInt(2) == 0) {
world.setBlockState(new BlockPos(x + vec.getX(), yCoord + i, z + vec.getY()), Blocks.COBBLESTONE.getDefaultState());
} else {
world.setBlockState(new BlockPos(x + vec.getX(), yCoord + i, z + vec.getY()), Blocks.MOSSY_COBBLESTONE.getDefaultState());
}
}
}
}
use of javax.vecmath.Vector2d in project narchy by automenta.
the class PlyObject method readVertices.
private static void readVertices(Scanner scanner, Element element, Vector<Vector3d> vertices, Vector<Vector3d> normals, Vector<Vector2d> textures) {
// Alle Datens�tze dieses Elements auslesen:
for (int i = 0; i < element.count; i++) {
Vector3d vertex = new Vector3d();
Vector3d normal = new Vector3d();
Vector2d texture = new Vector2d();
Iterator<Property> it = element.properties.iterator();
while (it.hasNext()) {
Property property = it.next();
if (Tokenizer.isTypeList(property.type)) {
// Alle Elemente der Liste �berspringen:
int count = scanner.nextInt();
for (int j = 0; j < count; j++) scanner.next();
} else {
double doubleValue = scanner.nextDouble();
switch(property.name) {
case "x":
vertex.x = doubleValue;
break;
case "y":
vertex.y = doubleValue;
break;
case "z":
vertex.z = doubleValue;
break;
case "nx":
normal.x = doubleValue;
break;
case "ny":
normal.y = doubleValue;
break;
case "nz":
normal.z = doubleValue;
break;
case "s":
texture.x = doubleValue;
break;
case "t":
texture.y = doubleValue;
break;
}
}
}
// Normalenvektor hinzuf�gen:
normals.add(((normal.x == 0.0) && (normal.y == 0.0) && (normal.z == 0.0)) ? null : new Vector3d(normal));
// Texturkoordinate hinzuf�gen:
textures.add(((texture.x == 0.0) && (texture.y == 0.0)) ? null : new Vector2d(texture));
// Daten hinzuf�gen:
vertices.add(vertex);
}
}
use of javax.vecmath.Vector2d in project narchy by automenta.
the class Triangle method clone.
@Override
public Triangle clone() throws CloneNotSupportedException {
Triangle clone = (Triangle) super.clone();
clone.a = new Vector3d(a);
clone.b = new Vector3d(b);
clone.c = new Vector3d(c);
clone.normal = new Vector3d(normal);
clone.normalA = (normalA == null) ? null : new Vector3d(normalA);
clone.normalB = (normalB == null) ? null : new Vector3d(normalB);
clone.normalC = (normalC == null) ? null : new Vector3d(normalC);
clone.textureA = new Vector2d(textureA);
clone.textureAB = new Vector2d(textureAB);
clone.textureAC = new Vector2d(textureAC);
clone.normalPlaneA = new Vector3d(normalPlaneA);
clone.normalPlaneB = new Vector3d(normalPlaneB);
clone.normalPlaneC = new Vector3d(normalPlaneC);
return clone;
}
use of javax.vecmath.Vector2d in project chordatlas by twak.
the class Slice method extrude.
public static void extrude(ObjDump out, LoopL<Point2d> slice, double h1, double h2) {
for (Loop<Point2d> loop : slice) {
for (Loopable<Point2d> pt : loop.loopableIterator()) {
List<double[]> pts = new ArrayList<>(), norms = new ArrayList<>();
Point2d a = pt.get(), b = pt.getNext().get();
pts.add(new double[] { a.x, h1, a.y });
pts.add(new double[] { b.x, h1, b.y });
pts.add(new double[] { b.x, h2, b.y });
pts.add(new double[] { a.x, h2, a.y });
Vector2d d = new Vector2d(b);
d.sub(a);
d.normalize();
double[] norm = new double[] { -d.y, 0, d.x };
for (int i = 0; i < 4; i++) norms.add(norm);
out.addFace(pts.toArray(new double[pts.size()][]), null, norms.toArray(new double[norms.size()][]));
}
}
}
Aggregations