Commit 4504b934 authored by Sergio Emanuel Rodriguez Rivera's avatar Sergio Emanuel Rodriguez Rivera
Browse files

Merge remote-tracking branch 'origin/DeformMesh' into DeformMesh

parents 5ead35c9 ea60c5b7
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ public class readFile {
    public static Map<VertexKey,Integer> vertexToIndex = new HashMap<>();
    public static Map<Integer, VertexKey> indexToVertex = new HashMap<>();

    public static float[] vertices;

    private static ArrayList<Integer> faces = new ArrayList<>();

    public static AdjacencyMatrix adjMatrix;
@@ -228,8 +230,24 @@ public class readFile {
     */
    private static String makeLine(Random random) {
        return String.format("[%f,%f,%f] [%f,%f,%f] [%f,%f,%f]",
                random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30,
                random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30,
                random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30);
                vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3],
                vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3],
                vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3]);
    }

    public static void generateRandomVertices(int numVertices) {
        float range = 30;
        Random random = new Random();
        vertices = new float[numVertices * 3];
        for (int i = 0; i < numVertices * 3; i += 3) {
            float x = (random.nextFloat() * range);
            float y = (random.nextFloat() * range);
            float z = (random.nextFloat() * range);

            // Ensures the value stays within range
            vertices[i] = Math.max(0, Math.min(range, x));
            vertices[i + 1] = Math.max(0, Math.min(range, y));
            vertices[i + 2] = Math.max(0, Math.min(range, z));
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public class GraphicsAndWindowsTest extends Application {
        };

        parameters = getParameters().getRaw().toArray(new String[getParameters().getRaw().size()]);
        readFile.generateRandomVertices(1000);
        readFile.randFileGenerator("testfile2.txt");
        readFile processInput = new readFile();
        processInput.parseCommand(parameters);