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:
@@ -32,6 +32,7 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.artisanlogiciel.games.*;
|
||||
import org.artisanlogiciel.games.stl.Maze3dParams;
|
||||
import org.artisanlogiciel.games.stl.Wall3d;
|
||||
import org.artisanlogiciel.games.stl.Wall3dStream;
|
||||
import org.artisanlogiciel.util.UTF8Control;
|
||||
@@ -57,6 +58,8 @@ public class Display extends JFrame {
|
||||
|
||||
MazeParams params = null;
|
||||
|
||||
Maze3dSettings stlsettings;
|
||||
|
||||
Display(LabyModel model, int W, int H, MazeParams params) {
|
||||
super(labels.getString("title"));
|
||||
if (params != null) {
|
||||
@@ -367,17 +370,19 @@ public class Display extends JFrame {
|
||||
System.out.println("save stl");
|
||||
setMazeName(saveName.getText());
|
||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||
saveStl(p, model);
|
||||
saveStl(p, model,stlsettings.createParams());
|
||||
}
|
||||
};
|
||||
saveStlButton.addActionListener(saveStlAction);
|
||||
|
||||
stlsettings = new Maze3dSettings(new Maze3dParams());
|
||||
|
||||
JMenu saveMenu = new JMenu("Save");
|
||||
saveMenu.add(saveName);
|
||||
saveMenu.add(saveSvgButton);
|
||||
saveMenu.add(savePngButton);
|
||||
saveMenu.add(saveButton);
|
||||
saveMenu.add(stlsettings);
|
||||
saveMenu.add(saveStlButton);
|
||||
saveMenu.add(saveImcButton);
|
||||
|
||||
@@ -1011,13 +1016,13 @@ public class Display extends JFrame {
|
||||
Display display = new Display(model, W, H, params);
|
||||
}
|
||||
|
||||
public static void saveStl(MazeParamsFixed params, LabyModel model) {
|
||||
public static void saveStl(MazeParamsFixed params, LabyModel model, Maze3dParams wallparams) {
|
||||
File outfile = new File(params.getSaveDir(), params.getName() + ".stl");
|
||||
if (!outfile.exists()) {
|
||||
System.out.println("Saving to " + outfile + " ...");
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(outfile);
|
||||
new Wall3dStream(params.getName(), model, out, false).stream(10,10,10);
|
||||
new Wall3dStream(params.getName(), model, out, wallparams).stream();
|
||||
out.close();
|
||||
System.out.println("... Done.");
|
||||
} catch (IOException io) {
|
||||
|
||||
72
java/org/artisanlogiciel/games/maze/gui/Maze3dSettings.java
Normal file
72
java/org/artisanlogiciel/games/maze/gui/Maze3dSettings.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package org.artisanlogiciel.games.maze.gui;
|
||||
|
||||
import org.artisanlogiciel.games.MazeParams;
|
||||
import org.artisanlogiciel.games.stl.Maze3dParams;
|
||||
import org.artisanlogiciel.games.stl.Wall3d;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class Maze3dSettings
|
||||
extends JPanel
|
||||
{
|
||||
// grid size
|
||||
JTextField xl;
|
||||
JTextField yl;
|
||||
JTextField zl;
|
||||
|
||||
JTextField w;
|
||||
JTextField lg;
|
||||
JTextField hg;
|
||||
|
||||
JCheckBox reverse;
|
||||
|
||||
Maze3dParams params;
|
||||
|
||||
public Maze3dSettings(Maze3dParams params) {
|
||||
super();
|
||||
this.params = params;
|
||||
createSettingsGui();
|
||||
}
|
||||
|
||||
void createSettingsGui() {
|
||||
if (params != null) {
|
||||
JLabel widthLabel = new JLabel(Display.labels.getString("width"));
|
||||
xl = new JTextField("0" + params.getXl());
|
||||
add(widthLabel);
|
||||
add(xl);
|
||||
JLabel heightLabel = new JLabel(Display.labels.getString("height"));
|
||||
zl = new JTextField("0" + params.getZl());
|
||||
add(heightLabel);
|
||||
add(zl);
|
||||
JLabel depthLabel = new JLabel(Display.labels.getString("depth"));
|
||||
yl = new JTextField("0" + params.getYl());
|
||||
add(depthLabel);
|
||||
add(yl);
|
||||
|
||||
reverse = new JCheckBox("reverse",params.isReverse());
|
||||
add(reverse);
|
||||
|
||||
w = new JTextField("0" + params.getW());
|
||||
add(w);
|
||||
|
||||
// lowground hightground
|
||||
lg = new JTextField("0" + params.getLg());
|
||||
add(lg);
|
||||
hg = new JTextField("0" + params.getHg());
|
||||
add(hg);
|
||||
}
|
||||
}
|
||||
|
||||
Maze3dParams createParams()
|
||||
{
|
||||
return new Maze3dParams(
|
||||
Integer.parseInt(xl.getText()),
|
||||
Integer.parseInt(yl.getText()),
|
||||
Integer.parseInt(zl.getText()),
|
||||
Integer.parseInt(w.getText()),
|
||||
Integer.parseInt(lg.getText()),
|
||||
Integer.parseInt(hg.getText()),
|
||||
reverse.isSelected());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user