From 68d279807fada14226a98c94cf093147086c8f6c Mon Sep 17 00:00:00 2001 From: Leonardo Date: Fri, 17 Sep 2021 22:50:48 +0200 Subject: [PATCH] small fix to the vertex order --- src/main/java/com/seibel/lod/Main.java | 3 +- .../seibel/lod/builders/lodTemplates/Box.java | 56 ++++++++++--------- .../lodTemplates/CubicLodTemplate.java | 2 +- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/seibel/lod/Main.java b/src/main/java/com/seibel/lod/Main.java index 0db2495c1..6103df2f5 100644 --- a/src/main/java/com/seibel/lod/Main.java +++ b/src/main/java/com/seibel/lod/Main.java @@ -29,11 +29,12 @@ public class Main box.move(0, depth, 0); box.setAdjData(adjData); - for(Direction direction : Box.ADJ_DIRECTIONS) + for(Direction direction : Box.DIRECTIONS) { int adjIndex = 0; while (box.shouldContinue(direction, adjIndex)) { + System.out.println(direction.toString()); for (int i = 0; i < 4; i++) { System.out.println(box.getX(direction, i) + " " + box.getY(direction, i, adjIndex) + " " + box.getZ(direction, i)); diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java index 054203779..b191f5202 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java @@ -25,7 +25,11 @@ public class Box public static final Direction[] DIRECTIONS = new Direction[]{ Direction.UP, - Direction.DOWN}; + Direction.DOWN, + Direction.WEST, + Direction.EAST, + Direction.NORTH, + Direction.SOUTH}; public static final Direction[] ADJ_DIRECTIONS = new Direction[]{ Direction.WEST, @@ -38,33 +42,33 @@ public class Box put(Direction.UP, new int[][]{ {0, 1, 0}, {0, 1, 1}, - {1, 1, 0}, - {1, 1, 1}}); + {1, 1, 1}, + {1, 1, 0}}); put(Direction.DOWN, new int[][]{ - {0, 0, 0}, - {0, 0, 1}, - {1, 0, 0}, - {1, 0, 1}}); - put(Direction.EAST, new int[][]{ {1, 0, 0}, {1, 0, 1}, + {0, 0, 1}, + {0, 0, 0}}); + put(Direction.EAST, new int[][]{ {1, 1, 0}, - {1, 1, 1}}); + {1, 1, 1}, + {1, 0, 1}, + {1, 0, 0}}); put(Direction.WEST, new int[][]{ {0, 0, 0}, {0, 0, 1}, - {0, 1, 0}, - {0, 1, 1}}); - put(Direction.SOUTH, new int[][]{ - {0, 0, 1}, - {1, 0, 1}, {0, 1, 1}, - {1, 1, 1}}); + {0, 1, 0}}); + put(Direction.SOUTH, new int[][]{ + {1, 0, 1}, + {1, 1, 1}, + {0, 1, 1}, + {0, 0, 1}}); put(Direction.NORTH, new int[][]{ {0, 0, 0}, - {1, 0, 0}, {0, 1, 0}, - {1, 1, 0}}); + {1, 1, 0}, + {1, 0, 0}}); }}; public static final Map DIRECTION_NORMAL_MAP = new HashMap() @@ -153,7 +157,7 @@ public class Box if (depth > getMaxY()) {//the adj data is higher than the current data //we continue since there could be some other data that intersect the current - System.out.println("case 1 " + height + " " + depth); + //System.out.println("case 1 " + height + " " + depth); continue; } else if (height < getMinY()) {//the adj data is lower than the current data @@ -161,12 +165,12 @@ public class Box if (firstFace) { - System.out.println("case 2-1 " + height + " " + depth); + //System.out.println("case 2-1 " + height + " " + depth); adjHeightAndDepth.get(direction)[0][0] = getMaxY(); adjHeightAndDepth.get(direction)[0][1] = getMinY(); } else { - System.out.println("case 2-2 " + height + " " + depth); + //System.out.println("case 2-2 " + height + " " + depth); adjHeightAndDepth.get(direction)[faceToDraw][1] = getMinY(); } faceToDraw++; @@ -175,7 +179,7 @@ public class Box } else if (depth <= getMinY() && height >= getMaxY()) {//the adj data contains the current //we do not draw the face - System.out.println("case 3"); + //System.out.println("case 3"); adjHeightAndDepth.get(direction)[0][0] = VOID_FACE; adjHeightAndDepth.get(direction)[0][1] = VOID_FACE; break; @@ -185,12 +189,12 @@ public class Box //if there was other face we finish the last one and break if (firstFace) { - System.out.println("case 4-1 " + height + " " + depth); + //System.out.println("case 4-1 " + height + " " + depth); adjHeightAndDepth.get(direction)[0][0] = getMaxY(); adjHeightAndDepth.get(direction)[0][1] = height; } else { - System.out.println("case 4-2 " + height + " " + depth); + //System.out.println("case 4-2 " + height + " " + depth); adjHeightAndDepth.get(direction)[faceToDraw][1] = height; } firstFace = false; @@ -200,7 +204,7 @@ public class Box } else if (depth > getMinY() && height >= getMaxY()) {//the adj data intersect the higher part of the current data //we start the creation of a new face - System.out.println("case 5 " + height + " " + depth); + //System.out.println("case 5 " + height + " " + depth); adjHeightAndDepth.get(direction)[faceToDraw][0] = depth; firstFace = false; toFinish = true; @@ -209,11 +213,11 @@ public class Box {//the adj data is contained in the current data if (firstFace) { - System.out.println("case 6-1 " + height + " " + depth);; + //System.out.println("case 6-1 " + height + " " + depth);; adjHeightAndDepth.get(direction)[0][0] = getMaxY(); } else { - System.out.println("case 6-2 " + height + " " + depth); + //System.out.println("case 6-2 " + height + " " + depth); } adjHeightAndDepth.get(direction)[faceToDraw][1] = height; faceToDraw++; diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java index ac634821d..4da391d50 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java @@ -116,7 +116,7 @@ public class CubicLodTemplate extends AbstractLodTemplate addPosAndColor(buffer, box.getX(direction, vertexIndex), box.getY(direction, vertexIndex, adjIndex), - box.getX(direction, vertexIndex), + box.getZ(direction, vertexIndex), box.getColor(direction)); } adjIndex++;