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:
104
java/org/artisanlogiciel/games/stl/Maze3dParams.java
Normal file
104
java/org/artisanlogiciel/games/stl/Maze3dParams.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package org.artisanlogiciel.games.stl;
|
||||
|
||||
public class Maze3dParams {
|
||||
|
||||
// grid size
|
||||
int xl;
|
||||
int yl;
|
||||
int zl;
|
||||
|
||||
int w;
|
||||
int lg;
|
||||
int hg;
|
||||
|
||||
Wall3d south;
|
||||
Wall3d west;
|
||||
Wall3d north;
|
||||
Wall3d east;
|
||||
Wall3d highGround;
|
||||
Wall3d lowGround;
|
||||
|
||||
// reverse : means that resolved path will be HighGround actual making maze more difficult to play with
|
||||
boolean reverse;
|
||||
|
||||
// default
|
||||
public Maze3dParams()
|
||||
{
|
||||
this(10,10,10, 1 , 1, 3, false);
|
||||
}
|
||||
|
||||
// w width is wall thickness
|
||||
public Maze3dParams(int xl, int yl, int zl, int w, int lg, int hg, boolean reverse)
|
||||
{
|
||||
this.xl = xl;
|
||||
this.yl = yl;
|
||||
this.zl = zl;
|
||||
this.reverse = reverse;
|
||||
int h = zl;
|
||||
|
||||
this.w = w;
|
||||
this.lg = lg;
|
||||
this.hg = hg;
|
||||
|
||||
south = new Wall3d(xl, w, h, 0, 0, 0);
|
||||
west = new Wall3d(w, yl, h, 0, 0, 0);
|
||||
north = new Wall3d(xl, w, h, 0, yl, 0);
|
||||
east = new Wall3d(w, yl, h, xl, 0, 0);
|
||||
highGround = new Wall3d(xl, yl, hg, 0, 0, 0);
|
||||
lowGround = new Wall3d(xl, yl, lg, 0, 0, 0);
|
||||
}
|
||||
|
||||
public boolean isReverse() {
|
||||
return reverse;
|
||||
}
|
||||
|
||||
public int getXl() {
|
||||
return xl;
|
||||
}
|
||||
|
||||
public int getYl() {
|
||||
return yl;
|
||||
}
|
||||
|
||||
public int getZl() {
|
||||
return zl;
|
||||
}
|
||||
|
||||
public Wall3d getSouth() {
|
||||
return south;
|
||||
}
|
||||
|
||||
public Wall3d getWest() {
|
||||
return west;
|
||||
}
|
||||
|
||||
public Wall3d getNorth() {
|
||||
return north;
|
||||
}
|
||||
|
||||
public Wall3d getEast() {
|
||||
return east;
|
||||
}
|
||||
|
||||
public Wall3d getHighGround() {
|
||||
return highGround;
|
||||
}
|
||||
|
||||
public Wall3d getLowGround() {
|
||||
return lowGround;
|
||||
}
|
||||
|
||||
public int getLg() {
|
||||
return lg;
|
||||
}
|
||||
|
||||
public int getHg() {
|
||||
return hg;
|
||||
}
|
||||
|
||||
public int getW() {
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user