Settings for stl export

- set cells size and wall thickness
- set reverse for path :
  when reverse is set then resolved path is higher ground
  else (default) it is lower ground.
This commit is contained in:
philippe lhardy
2020-10-13 16:49:00 +02:00
parent 159f408e7f
commit 046a7767a8
4 changed files with 202 additions and 30 deletions

View File

@@ -9,39 +9,25 @@ import java.io.OutputStream;
public class Wall3dStream
{
public final static Wall3d South = new Wall3d(10, 1, 10, 0, 0, 0);
public final static Wall3d West = new Wall3d(1, 10, 10, 0, 0, 0);
public final static Wall3d North = new Wall3d(10, 1, 10, 0, 10, 0);
public final static Wall3d East = new Wall3d(1, 10, 10, 10, 0, 0);
public final static Wall3d HighGround = new Wall3d(10, 10, 3, 0, 0, 0);
public final static Wall3d LowGround = new Wall3d(10, 10, 2, 0, 0, 0);
String name;
LabyModel provider;
OutputStream stream;
boolean reverse;
Maze3dParams params;
/**
* reverse : means that resolved path will be HighGround actual making maze more difficult to play with
*
* @param name
* @param provider
* @param stream
* @param reverse
* @param params
*/
public Wall3dStream(String name, LabyModel provider, OutputStream stream, boolean reverse)
public Wall3dStream(String name, LabyModel provider, OutputStream stream, Maze3dParams params)
{
this.name = name;
this.provider = provider;
this.stream = stream;
this.reverse = reverse;
}
public static void prepare() {
System.out.println(South.toString());
System.out.println(East.toString());
System.out.println(North.toString());
System.out.println(West.toString());
this.params = params;
}
private void writeWall3D(Wall3d wall3d)
@@ -50,46 +36,51 @@ public class Wall3dStream
stream.write(wall3d.toString().getBytes());
}
public void stream(int xl, int yl, int zl) throws IOException {
public void stream() throws IOException {
int width = provider.getWidth();
int height = provider.getHeight();
int xl = params.getXl();
int yl = params.getYl();
int zl = params.getZl();
boolean reverse = params.isReverse();
// WARNING DOWN - UP reversed ( in 2D Y is oriented to lower, in 3D it
// is to upper ).
stream.write(("solid " + name + "\n").getBytes());
for (int x = 0; x < width; x++) {
short walls = provider.getWalls(x, 0);
if ((walls & Brick.UP) != 0) {
writeWall3D(new Wall3d(South, x * xl, 0, 0));
writeWall3D(new Wall3d(params.getSouth(), x * xl, 0, 0));
}
if ((walls & Brick.LEFT) != 0) {
writeWall3D(new Wall3d(West, x * xl, 0, 0));
writeWall3D(new Wall3d(params.getWest(), x * xl, 0, 0));
}
}
for (int y = 0; y < height; y++) {
short walls = provider.getWalls(0, y);
if ((walls & Brick.LEFT) != 0) {
writeWall3D(new Wall3d(West, 0, y * yl, 0));
writeWall3D(new Wall3d(params.getWest(), 0, y * yl, 0));
}
for (int x = 0; x < width; x++) {
// south and east
walls = provider.getWalls(x, y);
if ((walls & Brick.DOWN) != 0) {
writeWall3D(new Wall3d(North, x * xl, y * yl, 0));
writeWall3D(new Wall3d(params.getNorth(), x * xl, y * yl, 0));
}
if ((walls & Brick.RIGHT) != 0) {
writeWall3D(new Wall3d(East, x * xl, y * yl, 0));
writeWall3D(new Wall3d(params.getEast(), x * xl, y * yl, 0));
}
short path = provider.getPath(x, y);
// where resolved path is leaked to stl model.
Wall3d ground = reverse ? LowGround : HighGround;
Wall3d ground = reverse ? params.getLowGround() : params.getHighGround();
if ((path & LabyModel.SOLVED) == LabyModel.SOLVED)
// if ( (walls & ( Brick.GOAL | Brick.ENTRY ) ) == 0 )
{
// if ( ( (x+y) % 2) == 0 )
ground = reverse ? HighGround : LowGround;
ground = reverse ? params.getHighGround() : params.getLowGround();
}
writeWall3D(new Wall3d(ground, x * xl, y * yl, 0));
}