Search in sources :

Example 16 with Vector2d

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;
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) Vector2d(javax.vecmath.Vector2d) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 17 with Vector2d

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());
            }
        }
    }
}
Also used : Random(java.util.Random) Vector2d(javax.vecmath.Vector2d) BlockPos(net.minecraft.util.math.BlockPos)

Example 18 with Vector2d

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);
    }
}
Also used : Vector2d(javax.vecmath.Vector2d) Vector3d(javax.vecmath.Vector3d)

Example 19 with Vector2d

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;
}
Also used : Vector2d(javax.vecmath.Vector2d) Vector3d(javax.vecmath.Vector3d)

Example 20 with Vector2d

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()][]));
        }
    }
}
Also used : Vector2d(javax.vecmath.Vector2d) Point2d(javax.vecmath.Point2d) ArrayList(java.util.ArrayList)

Aggregations

Vector2d (javax.vecmath.Vector2d)29 Point2d (javax.vecmath.Point2d)15 Vector3d (javax.vecmath.Vector3d)12 ArrayList (java.util.ArrayList)9 Point3d (javax.vecmath.Point3d)8 List (java.util.List)7 Line (org.twak.utils.Line)7 SuperLine (org.twak.viewTrace.SuperLine)6 Line3d (org.twak.utils.geom.Line3d)5 LinearForm3D (org.twak.utils.geom.LinearForm3D)5 Material (com.jme3.material.Material)4 Geometry (com.jme3.scene.Geometry)4 Mesh (com.jme3.scene.Mesh)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 ColorRGBA (com.jme3.math.ColorRGBA)3 Node (com.jme3.scene.Node)3 VertexBuffer (com.jme3.scene.VertexBuffer)3 Graphics2D (java.awt.Graphics2D)3 Collection (java.util.Collection)3