Merge branch 'pi' of 192.168.1.28:artisanlogiciel/code/laby
# Conflicts: # build.xml # mybuild.xml
This commit is contained in:
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
29
.idea/laby.iml
generated
Normal file
29
.idea/laby.iml
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/lang" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/artloglaby" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/autom4te.cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/c" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/deb" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/debian" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/documentation" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/download" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/java/lab" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/java/org/artisanlogiciel/games/javafx" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/lab" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/scripts" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/workspace" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="artgaphics-0.1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
9
.idea/libraries/artgaphics_0_1_0.xml
generated
Normal file
9
.idea/libraries/artgaphics_0_1_0.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="artgaphics-0.1.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/libs/artgaphics-0.1.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/java/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/laby.iml" filepath="$PROJECT_DIR$/.idea/laby.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
9
LISEZMOI
9
LISEZMOI
@@ -5,6 +5,14 @@ Il s'agit d'un générateur de labyrinthes écrit en langage java.
|
||||
|
||||
Pour le lancer vous devez avoir installé un environnement java 8 ( avec javafx (*) )
|
||||
|
||||
racourçi :
|
||||
|
||||
sous linux ./laby.sh
|
||||
|
||||
sous windows lancez le laby.bat
|
||||
|
||||
il s'gait d'un porgramme java qui peut aussi être lancé avec l'interpréteur java ainsi :
|
||||
|
||||
java -jar artloglaby-1.0.jar
|
||||
|
||||
mail pl@artisanlogiciel.net
|
||||
@@ -14,5 +22,6 @@ vous pouvez le distribuer ou bien même le vendre
|
||||
ses sources sont sur https://github.com/artlog/labystl
|
||||
( et utilise aussi https://github.com/artlog/sharedrawweb )
|
||||
|
||||
Les labyrinthes que vous sauvegardez le sont dans le répertoire lab.
|
||||
|
||||
|
||||
|
||||
2
Makefile.am
Normal file
2
Makefile.am
Normal file
@@ -0,0 +1,2 @@
|
||||
SUBDIRS = c
|
||||
dist_doc_DATA = README
|
||||
5
README
5
README
@@ -3,7 +3,8 @@ This is a personal project to generate a 2D maze using in depth path generation.
|
||||
|
||||
Download the 'latest' laby.zip containing java jar from my blog http://blog.artisanlogiciel.net/public/tech/laby.zip
|
||||
|
||||
this can generate a stl file, overall goal was to print it with a 3D printer, i didn't test it yet ( even if i actualy have a 3D printer ).
|
||||
this can generate a stl file, overall goal was to print it with a 3D printer.
|
||||
After years i finaly printed one maze, find it at https://www.thingiverse.com/thing:2814655
|
||||
|
||||
This is the very first usable part.
|
||||
It was developped under debian 7/8 but since it is java based it might be very easily recompiled or even just copied on other platform.
|
||||
@@ -25,6 +26,8 @@ cd labystl
|
||||
./init.sh
|
||||
# will create build scripts from artlog_toolbox
|
||||
# ./doit.sh
|
||||
# depends on sharedrawweb for stl export
|
||||
./fetch_dependencies.sh
|
||||
ant dist
|
||||
source ./specificdoit.sh; create_zip_package
|
||||
unzip laby.zip; cd artloglaby ; ./laby.sh
|
||||
|
||||
23
bootstrapbuild.sh
Executable file
23
bootstrapbuild.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f configure.ac ]]
|
||||
then
|
||||
echo "[ERROR] Missing configure.ac . Please create one " >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if which autoreconf
|
||||
then
|
||||
|
||||
echo "bootstrap using automake tools"
|
||||
echo "from configure.ac will generate configure"
|
||||
|
||||
autoreconf --install
|
||||
|
||||
echo "lauch ./configure && make"
|
||||
|
||||
else
|
||||
|
||||
echo "[ERROR] Missing autoreconf script from autotools. Please install autotools ( package autotools-dev and autoreconf" >&2
|
||||
|
||||
fi
|
||||
10
build.xml
10
build.xml
@@ -10,9 +10,9 @@
|
||||
<property name="src" location="java"/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="dist" location="dist"/>
|
||||
|
||||
<!-- Fill me please / todo -->
|
||||
<property name="artgraphicslib" value="artgaphics-0.2.0"/>
|
||||
<property name="distversion" value="1.0"/>
|
||||
<property name="distversion" value="1.1"/>
|
||||
|
||||
<target name="init">
|
||||
<!-- Create the time stamp -->
|
||||
@@ -26,6 +26,7 @@
|
||||
<!-- Compile the java code from ${src} into ${build} -->
|
||||
<javac srcdir="${src}" destdir="${build}" includeantruntime="false" classpath="libs/${artgraphicslib}.jar">
|
||||
<exclude name="org/artisanlogiciel/games/javafx/*"/>
|
||||
<compilerarg value="-Xlint:deprecation,unchecked" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
@@ -37,8 +38,8 @@
|
||||
<!-- Put everything in ${build} into the artloglaby-${distversion}.jar file ( ${DSTAMP} not used yet )-->
|
||||
<jar jarfile="${dist}/lib/artloglaby-${distversion}.jar" basedir="${build}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="org.artisanlogiciel.games.Display"/>
|
||||
<attribute name="Class-Path" value="${artgraphicslib}.jar"/>
|
||||
<attribute name="Main-Class" value="org.artisanlogiciel.games.maze.gui.Display"/>
|
||||
<attribute name="Class-Path" value="libs/${artgraphicslib}.jar"/>
|
||||
</manifest>
|
||||
<fileset dir="lang" includes="**" />
|
||||
</jar>
|
||||
@@ -50,5 +51,4 @@
|
||||
<delete dir="${build}"/>
|
||||
<delete dir="${dist}"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
12
c/Makefile.am
Normal file
12
c/Makefile.am
Normal file
@@ -0,0 +1,12 @@
|
||||
# Makefile.am is REALLY where changes should be done
|
||||
# Makefile.in and Makefile are generated from this.
|
||||
|
||||
bin_PROGRAMS = laby
|
||||
|
||||
laby_SOURCES = allaby_reader.c allaby_main.c
|
||||
|
||||
laby_CPPFLAGS = $(ARTLOG_CPPFLAGS) $(ALEXPANDER_CPPFLAGS)
|
||||
|
||||
# in LDADD and not in LDFLAGS to be linked AFTER
|
||||
laby_LDADD = $(ARTLOG_LDFLAGS) $(ALEXPANDER_LDFLAGS)
|
||||
|
||||
17
c/allaby_main.c
Normal file
17
c/allaby_main.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "al_options.h"
|
||||
|
||||
// NOT YET IMPLEMENTED
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int exitcode = 1;
|
||||
struct al_options * options = al_options_create(argc,argv);
|
||||
al_options_set_debug(options,0);
|
||||
struct alhash_datablock * debugdata = al_option_get(options,"debug");
|
||||
if ( debugdata != NULL )
|
||||
{
|
||||
exitcode = 0;
|
||||
}
|
||||
al_options_release(options);
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
2
c/allaby_reader.c
Normal file
2
c/allaby_reader.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "allaby_reader.h"
|
||||
|
||||
9
c/allaby_reader.h
Normal file
9
c/allaby_reader.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef __ALLABY_READER_H__
|
||||
#define __ALLABY_READER_H__
|
||||
|
||||
/** goal : read a labyrinth/maze created
|
||||
by java laby project
|
||||
**/
|
||||
|
||||
|
||||
#endif // __ALLABY_READER_H__
|
||||
37
configure.ac
Normal file
37
configure.ac
Normal file
@@ -0,0 +1,37 @@
|
||||
# written manually, this is root entry files for automake together with Makefile.am
|
||||
# inspired from
|
||||
# http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html#Creating-amhello
|
||||
|
||||
AC_INIT([allaby], [0.1], [pl@artisanlogiciel.net])
|
||||
|
||||
# set ARTLOG_TOOLBOX where artlog_toolbox is to use it.
|
||||
[ARTLOG_TOOLBOX=`pwd`/`./locate_artlog_toolbox.sh`]
|
||||
|
||||
# non need to propagate it in .h ...
|
||||
# AC_DEFINE_UNQUOTED([ARTLOG_TOOLBOX],["$ARTLOG_TOOLBOX"],[where artog toolbox is])
|
||||
|
||||
ARTLOG_CPPFLAGS="-I${ARTLOG_TOOLBOX}/build/include"
|
||||
ARTLOG_LDFLAGS="-Wl,-Bstatic -L${ARTLOG_TOOLBOX}/build/lib -lalsave -laltest -laljson -lalstack -lalhash -laldev -Wl,-Bdynamic"
|
||||
|
||||
AC_SUBST(ARTLOG_CPPFLAGS)
|
||||
AC_SUBST(ARTLOG_LDFLAGS)
|
||||
|
||||
[if [ "$ALEXPANDER_DIR" = "" ]]
|
||||
[then]
|
||||
[ALEXPANDER_DIR=`pwd`/../sharedrawweb]
|
||||
[fi]
|
||||
ALEXPANDER_CPPFLAGS="-I${ALEXPANDER_DIR}/build/include -D CHARSPERRECORD=80"
|
||||
ALEXPANDER_LDFLAGS="-Wl,-Bstatic -L${ALEXPANDER_DIR}/build/lib -lalima -lalcommon -Wl,-Bdynamic"
|
||||
|
||||
AC_SUBST(ALEXPANDER_CPPFLAGS)
|
||||
AC_SUBST(ALEXPANDER_LDFLAGS)
|
||||
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||
AC_PROG_CC
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_DEFINE([MAX_FLAT_VIEWS],[20],[maximum number of view])
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
c/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
16
fetch_dependencies.sh
Executable file
16
fetch_dependencies.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -d ../sharedrawweb ]]
|
||||
then
|
||||
echo "[ERROR] expected a sharedrawweb project parent ( for exports )" >&2
|
||||
fi
|
||||
|
||||
if [[ ! -d libs ]]
|
||||
then
|
||||
mkdir libs
|
||||
fi
|
||||
|
||||
if [[ ! -e libs/artgaphics-0.1.0.jar ]]
|
||||
then
|
||||
ln -s ../../sharedrawweb/dist/lib/artgaphics-0.1.0.jar libs/
|
||||
fi
|
||||
@@ -11,8 +11,8 @@ $(OUT):
|
||||
# mkdir -p $(OUT)
|
||||
|
||||
clean:
|
||||
@find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null && echo "cleaned classes in source"
|
||||
@find $(OUT) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null || echo "nothing to clean"
|
||||
@find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null
|
||||
@find $(OUT) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null
|
||||
|
||||
test:
|
||||
echo "$(pwd)/$(PACKAGE_DIR)"
|
||||
|
||||
@@ -1,73 +1,56 @@
|
||||
package org.artisanlogiciel.games;
|
||||
|
||||
/**
|
||||
DirectionPosition
|
||||
|
||||
record direction and position ( direction as defined in LabyModel ).
|
||||
* DirectionPosition
|
||||
* <p>
|
||||
* record direction and position ( direction as defined in LabyModel ).
|
||||
**/
|
||||
public class DirectionPosition
|
||||
{
|
||||
public class DirectionPosition {
|
||||
private short direction;
|
||||
private Position position;
|
||||
|
||||
// (direction,position)
|
||||
DirectionPosition(short d, Position p)
|
||||
{
|
||||
direction=d;
|
||||
position=p;
|
||||
public DirectionPosition(short d, Position p) {
|
||||
direction = d;
|
||||
position = p;
|
||||
}
|
||||
|
||||
short getDirection()
|
||||
{
|
||||
public short getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
void setDirection(short d)
|
||||
{
|
||||
public void setDirection(short d) {
|
||||
direction = d;
|
||||
}
|
||||
|
||||
Position getPosition()
|
||||
{
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if (position != null)
|
||||
{
|
||||
public String toString() {
|
||||
if (position != null) {
|
||||
return position.toString();
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
// create a new DirectionPosition from this using one possible direction.
|
||||
DirectionPosition moveToAdjacentDirection()
|
||||
{
|
||||
public DirectionPosition moveToAdjacentDirection() {
|
||||
short pointingdirection = 0;
|
||||
Position p = null;
|
||||
if (LabyModel.isFlagSet(direction,LabyModel.RIGHT))
|
||||
{
|
||||
if (LabyModel.isFlagSet(direction, LabyModel.RIGHT)) {
|
||||
p = new Position(position.getX() + 1, position.getY());
|
||||
pointingdirection |= LabyModel.LEFT;
|
||||
}
|
||||
else if (LabyModel.isFlagSet(direction,LabyModel.LEFT))
|
||||
{
|
||||
p = new Position(position.getX() -1 ,position.getY());
|
||||
} else if (LabyModel.isFlagSet(direction, LabyModel.LEFT)) {
|
||||
p = new Position(position.getX() - 1, position.getY());
|
||||
pointingdirection |= LabyModel.RIGHT;
|
||||
}
|
||||
else if (LabyModel.isFlagSet(direction,LabyModel.UP))
|
||||
{
|
||||
p = new Position(position.getX(),position.getY() -1);
|
||||
} else if (LabyModel.isFlagSet(direction, LabyModel.UP)) {
|
||||
p = new Position(position.getX(), position.getY() - 1);
|
||||
pointingdirection |= LabyModel.DOWN;
|
||||
}
|
||||
else if (LabyModel.isFlagSet(direction,LabyModel.DOWN))
|
||||
{
|
||||
p = new Position(position.getX(),position.getY() + 1);
|
||||
} else if (LabyModel.isFlagSet(direction, LabyModel.DOWN)) {
|
||||
p = new Position(position.getX(), position.getY() + 1);
|
||||
pointingdirection |= LabyModel.UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p = position;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -14,25 +14,14 @@ public class Main
|
||||
return editor;
|
||||
}
|
||||
|
||||
public WallsProvider generate(int width, int height, int maxdepth, MazeResolutionListener listener)
|
||||
public LabyMap generate2(MazeParamEditor params)
|
||||
{
|
||||
LabyModel model = new LabyModel(width, height, maxdepth, new java.util.Random());
|
||||
params.setSeed(1024L);
|
||||
LabyModel model = new LabyModel(params);
|
||||
model.generateWithEntry(0, 0);
|
||||
LinkedList<Position> exits = new LinkedList<Position>();
|
||||
model.addEntryOrExit(-1, 0);
|
||||
model.addEntryOrExit(width, height - 1);
|
||||
if (!model.check())
|
||||
{
|
||||
System.out.println("Check failed");
|
||||
}
|
||||
model.resolve(width - 1, height - 1, listener);
|
||||
return model;
|
||||
}
|
||||
|
||||
public LabyMap generate2(int width, int height, int maxdepth)
|
||||
{
|
||||
LabyModel model = new LabyModel(width, height, maxdepth, new java.util.Random(1024L));
|
||||
model.generateWithEntry(0, 0);
|
||||
final int width = params.getWidth();
|
||||
final int height = params.getHeight();
|
||||
LinkedList<Position> exits = new LinkedList<Position>();
|
||||
model.addEntryOrExit(-1, 0);
|
||||
model.addEntryOrExit(width, height - 1);
|
||||
@@ -51,7 +40,7 @@ public class Main
|
||||
{
|
||||
Main m = new Main();
|
||||
MazeParamEditor editor = m.editor();
|
||||
LabyMap map = m.generate2(editor.width, editor.height, editor.maxdepth);
|
||||
LabyMap map = m.generate2(editor);
|
||||
System.out.println(map.toShortString());
|
||||
System.out.println(map.toString());
|
||||
System.out.println(Brick.getDirLine());
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.artisanlogiciel.games;
|
||||
/**
|
||||
* MazeCreationListener
|
||||
**/
|
||||
interface MazeCreationListener
|
||||
public interface MazeCreationListener
|
||||
{
|
||||
void changed(Position cornerleft, Position cornerright, WallsProvider provider);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Scanner;
|
||||
**/
|
||||
class MazeParamEditor implements MazeParams
|
||||
{
|
||||
long seed;
|
||||
int width;
|
||||
int height;
|
||||
int maxdepth;
|
||||
@@ -27,6 +28,11 @@ class MazeParamEditor implements MazeParams
|
||||
maxdepth = console.nextInt();
|
||||
}
|
||||
|
||||
public long getSeed()
|
||||
{
|
||||
return seed;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
@@ -51,6 +57,11 @@ class MazeParamEditor implements MazeParams
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setSeed(long seed)
|
||||
{
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public File getSaveDir()
|
||||
{
|
||||
return labdir;
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.io.File;
|
||||
**/
|
||||
public interface MazeParams
|
||||
{
|
||||
/** currently seed of java.util.random **/
|
||||
public long getSeed();
|
||||
|
||||
public int getWidth();
|
||||
|
||||
public int getHeight();
|
||||
|
||||
76
java/org/artisanlogiciel/games/MazeParamsFixed.java
Normal file
76
java/org/artisanlogiciel/games/MazeParamsFixed.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package org.artisanlogiciel.games;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MazeParamsFixed implements MazeParams
|
||||
{
|
||||
long seed;
|
||||
int width;
|
||||
int height;
|
||||
int maxdepth;
|
||||
File labdir;
|
||||
String name;
|
||||
|
||||
public MazeParamsFixed()
|
||||
{
|
||||
}
|
||||
|
||||
public MazeParamsFixed(MazeParams params)
|
||||
{
|
||||
setParams(params.getSaveDir(),params.getWidth(),params.getHeight(),params.getMaxDepth());
|
||||
}
|
||||
|
||||
public void setParams(File saveDir, int W, int H, int MD)
|
||||
{
|
||||
labdir = saveDir;
|
||||
width=W;
|
||||
height=H;
|
||||
maxdepth=MD;
|
||||
}
|
||||
|
||||
public MazeParamsFixed(File saveDir, int W, int H, int MD, long seed)
|
||||
{
|
||||
name = null;
|
||||
setParams(saveDir,W,H,MD);
|
||||
this.seed=seed;
|
||||
}
|
||||
|
||||
public long getSeed()
|
||||
{
|
||||
return seed;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getMaxDepth()
|
||||
{
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
public void setName(String n)
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
name = "lab" + width + "x" + height;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getSaveDir()
|
||||
{
|
||||
return labdir;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,12 @@ public interface WallsProvider
|
||||
/**
|
||||
* See Brick
|
||||
*
|
||||
* Will set bits : 3 2 1 0 (8)(4)(2)(1) ^ > v < U R D L p i o e g w f h n t
|
||||
* Will set bits :
|
||||
* 3 2 1 0
|
||||
* (8)(4)(2)(1)
|
||||
* ^ > v <
|
||||
* U R D L
|
||||
* p i o e g w f h n t
|
||||
* t
|
||||
**/
|
||||
public short getWalls(int x, int y);
|
||||
|
||||
1164
java/org/artisanlogiciel/games/maze/gui/Display.java
Normal file
1164
java/org/artisanlogiciel/games/maze/gui/Display.java
Normal file
File diff suppressed because it is too large
Load Diff
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());
|
||||
}
|
||||
|
||||
}
|
||||
56
java/org/artisanlogiciel/games/maze/gui/MazeSettings.java
Normal file
56
java/org/artisanlogiciel/games/maze/gui/MazeSettings.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package org.artisanlogiciel.games.maze.gui;
|
||||
|
||||
import org.artisanlogiciel.games.MazeParams;
|
||||
import org.artisanlogiciel.games.MazeParamsFixed;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class MazeSettings extends JPanel {
|
||||
MazeParams params;
|
||||
|
||||
JTextField textWidth = null;
|
||||
JTextField textHeight = null;
|
||||
JTextField textDepth = null;
|
||||
JTextField textSeed = null;
|
||||
|
||||
// TODO set width and height and depth of maze with gui
|
||||
public MazeSettings(MazeParams params) {
|
||||
super();
|
||||
this.params = params;
|
||||
createSettingsGui();
|
||||
}
|
||||
|
||||
void createSettingsGui() {
|
||||
if (params != null) {
|
||||
JLabel widthLabel = new JLabel(Display.labels.getString("width"));
|
||||
textWidth = new JTextField("0" + params.getWidth());
|
||||
add(widthLabel);
|
||||
add(textWidth);
|
||||
JLabel heightLabel = new JLabel(Display.labels.getString("height"));
|
||||
textHeight = new JTextField("0" + params.getHeight());
|
||||
add(heightLabel);
|
||||
add(textHeight);
|
||||
JLabel depthLabel = new JLabel(Display.labels.getString("depth"));
|
||||
textDepth = new JTextField("0" + params.getMaxDepth());
|
||||
add(depthLabel);
|
||||
add(textDepth);
|
||||
JLabel seedLabel = new JLabel(Display.labels.getString("seed"));
|
||||
textSeed = new JTextField( "" + params.getSeed(),16);
|
||||
add(seedLabel);
|
||||
add(textSeed);
|
||||
}
|
||||
}
|
||||
|
||||
public MazeParams resetParams() {
|
||||
params = new MazeParamsFixed(params.getSaveDir(),
|
||||
Integer.parseInt(textWidth.getText()),
|
||||
Integer.parseInt(textHeight.getText()),
|
||||
Integer.parseInt(textDepth.getText()),
|
||||
new Random().nextLong()
|
||||
);
|
||||
textSeed.setText("" + params.getSeed());
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -11,114 +11,134 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Wall3d to create walls in 3d for stl conversion South, West North East...
|
||||
*
|
||||
* wall3D will create a rectangular cuboid with 2 triangle vertex for each face
|
||||
**/
|
||||
public class Wall3d
|
||||
{
|
||||
public class Wall3d {
|
||||
|
||||
// 4 triangles in 2 dim space reused 3 times
|
||||
final static int BASE[][][] = { { { 0, 0 }, { 1, 0 }, { 0, 1 } }, { { 1, 0 }, { 1, 1 }, { 0, 1 } },
|
||||
{ { 0, 0 }, { 1, 0 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 }, { 0, 1 } } };
|
||||
// in facts order matters...
|
||||
final static int BASE[][][] = {
|
||||
// lower left
|
||||
{{0, 0}, {1, 0}, {0, 1}},
|
||||
// higher right
|
||||
{{1, 0}, {1, 1}, {0, 1}},
|
||||
// lower right
|
||||
{{0, 0}, {1, 0}, {1, 1}},
|
||||
// higher left
|
||||
{{0, 0}, {1, 1}, {0, 1}}};
|
||||
|
||||
final static short X = 1;
|
||||
final static short Y = 2;
|
||||
final static short Z = 4;
|
||||
|
||||
// final static short AXIS[][]= {{X,Y},{-Z,Y},{X,Y},{Z,Y},{X,-Z},{X,-Z}};
|
||||
final static short AXIS[][] = { { X, Y, 0 }, { Z, Y, 0 }, { X, Y, 1 }, { Z, Y, 1 }, { X, Z, 0 }, { X, Z, 1 } };
|
||||
|
||||
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);
|
||||
// [face][axis]
|
||||
final static short AXIS[][] = {
|
||||
// face 0 (x,y) back
|
||||
{X, Y, 0},
|
||||
// face 1 (z,y) left
|
||||
{Z, Y, 0},
|
||||
// face 2 (x,y,1)
|
||||
{X, Y, 1},
|
||||
// face 3
|
||||
{Z, Y, 1},
|
||||
// face 4
|
||||
{X, Z, 0},
|
||||
// face 5
|
||||
{X, Z, 1}};
|
||||
|
||||
final static String normalx = "1.0 0.0 0.0";
|
||||
final static String normaly = "0.0 1.0 0.0";
|
||||
final static String normalz = "0.0 0.0 1.0";
|
||||
final static String normalmx = "-1.0 0.0 0.0";
|
||||
final static String normalmy = "0.0 -1.0 0.0";
|
||||
final static String normalmz = "0.0 0.0 -1.0";
|
||||
|
||||
// final static short NORMAL[] = {Z,X,Z,X,Y,Y};
|
||||
|
||||
final static String normalstr[] =
|
||||
{ normalmz, normalx,
|
||||
normalz, normalmx,
|
||||
normaly, normalmy
|
||||
};
|
||||
|
||||
boolean reverse_vertex[] = {
|
||||
true,false,false,true,false,true
|
||||
};
|
||||
|
||||
int triangle[][][] = null;
|
||||
|
||||
public Wall3d(int t[][][])
|
||||
{
|
||||
public Wall3d(int t[][][]) {
|
||||
triangle = t;
|
||||
}
|
||||
|
||||
public Wall3d(Wall3d origin, int dx, int dy, int dz)
|
||||
{
|
||||
public Wall3d(Wall3d origin, int dx, int dy, int dz) {
|
||||
triangle = origin.translate(dx, dy, dz);
|
||||
}
|
||||
|
||||
Wall3d(int xl, int yl, int zl, int dx, int dy, int dz)
|
||||
{
|
||||
Wall3d(int xl, int yl, int zl, int dx, int dy, int dz) {
|
||||
int f = 0;
|
||||
triangle = new int[12][3][3];
|
||||
int[] factor = { xl, yl, zl };
|
||||
int[] translate = { dx, dy, dz };
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
// point in a triangle
|
||||
for (int p = 0; p < 3; p++)
|
||||
{
|
||||
int[] factor = {xl, yl, zl};
|
||||
int[] translate = {dx, dy, dz};
|
||||
for (int facet = 0; facet < 12; facet++) {
|
||||
// point in a triangle / facet
|
||||
for (int p = 0; p < 3; p++) {
|
||||
short uaxis = 0;
|
||||
for (int axis = 0; axis < 2; axis++)
|
||||
{
|
||||
short caxis = AXIS[i / 2][axis];
|
||||
if (caxis > 0)
|
||||
{
|
||||
// a square face is two facets.
|
||||
int face = facet / 2;
|
||||
// first two axis ( projected on x,y,z depending on AXIS[face][] )
|
||||
for (int axis = 0; axis < 2; axis++) {
|
||||
short caxis = AXIS[face][axis];
|
||||
if (caxis > 0) {
|
||||
f = 1;
|
||||
}
|
||||
else if (caxis < 0)
|
||||
{
|
||||
} else if (caxis < 0) {
|
||||
// wait wait in AXIS there is no negative value ...
|
||||
// so we never enter here, what was the purpose ? might be history.
|
||||
f = -1;
|
||||
caxis = (short) -caxis;
|
||||
}
|
||||
// what if caxis == 0 ? f is kept as its previous value ?
|
||||
// which is 1 in facts due to AXIS[..][0] > 0
|
||||
|
||||
// uaxis keep track of used axes for this face to find last missing axis
|
||||
uaxis |= caxis;
|
||||
if (caxis == X)
|
||||
{
|
||||
if (caxis == X) {
|
||||
caxis = 0;
|
||||
}
|
||||
else if (caxis == Y)
|
||||
{
|
||||
} else if (caxis == Y) {
|
||||
caxis = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
caxis = 2;
|
||||
}
|
||||
// if ( f == 0 )
|
||||
// {
|
||||
// System.out.println("ERROR");
|
||||
// }
|
||||
// System.out.println("i " + i + " p " + p + " a " + caxis +
|
||||
// " , " + BASE[i%4][p][axis] );
|
||||
triangle[i][p][caxis] = translate[caxis] + BASE[i % 4][p][axis] * f * factor[caxis];
|
||||
triangle[facet][p][caxis] = translate[caxis] + BASE[facet % 4][p][axis] * f * factor[caxis];
|
||||
}
|
||||
if ((uaxis & X) == 0)
|
||||
{
|
||||
// last remaining axis
|
||||
if ((uaxis & X) == 0) {
|
||||
// no X was used => X
|
||||
uaxis = 0;
|
||||
}
|
||||
else if ((uaxis & Y) == 0)
|
||||
{
|
||||
} else if ((uaxis & Y) == 0) {
|
||||
// X was used byt not Y => Y
|
||||
uaxis = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// default X, and Y were used => Z
|
||||
uaxis = 2;
|
||||
}
|
||||
triangle[i][p][uaxis] = translate[uaxis] + AXIS[i / 2][2] * factor[uaxis];
|
||||
triangle[facet][p][uaxis] = translate[uaxis] + AXIS[facet / 2][2] * factor[uaxis];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[][][] translate(int dx, int dy, int dz)
|
||||
{
|
||||
int[] translate = { dx, dy, dz };
|
||||
public int[][][] translate(int dx, int dy, int dz) {
|
||||
int[] translate = {dx, dy, dz};
|
||||
int t[][][] = new int[12][3][3];
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
for (int facet = 0; facet < 12; facet ++) {
|
||||
// point in a triangle
|
||||
for (int p = 0; p < 3; p++)
|
||||
{
|
||||
for (int axis = 0; axis < 3; axis++)
|
||||
{
|
||||
t[i][p][axis] = translate[axis] + triangle[i][p][axis];
|
||||
for (int p = 0; p < 3; p++) {
|
||||
for (int axis = 0; axis < 3; axis++) {
|
||||
t[facet][p][axis] = translate[axis] + triangle[facet][p][axis];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,22 +147,27 @@ public class Wall3d
|
||||
}
|
||||
|
||||
/**
|
||||
write triangles as stl text
|
||||
* write triangles as stl text
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
String s = "";
|
||||
for (int t = 0; t < 12; t++)
|
||||
{
|
||||
s += "facet normal 0 0 0\nouter loop\n";
|
||||
for (int p = 0; p < 3; p++)
|
||||
{
|
||||
for (int facet = 0; facet < 12; facet++) {
|
||||
int face = facet / 2;
|
||||
// most software don't care normal but just rely on vertex order ( right hand ).
|
||||
String normal = normalstr[face];
|
||||
s += "facet normal " + normal + "\nouter loop\n";
|
||||
boolean reverse = reverse_vertex[face];
|
||||
for (int p = 0; p < 3; p++) {
|
||||
s += "vertex";
|
||||
for (int a = 0; a < 3; a++)
|
||||
// p that accept right hand
|
||||
int rhp = p;
|
||||
if ( reverse )
|
||||
{
|
||||
// s+=" t "+ t + " p " + p + " a " + a + "=" +
|
||||
// triangle[t][p][a];
|
||||
s += " " + triangle[t][p][a];
|
||||
// reverse 2 and 1 ; 0 => 0, 1 => 2 , 2 => 1
|
||||
rhp = ( p * 5 ) % 3;
|
||||
}
|
||||
for (int a = 0; a < 3; a++) {
|
||||
s += " " + triangle[facet][rhp][a];
|
||||
}
|
||||
s += "\n";
|
||||
}
|
||||
@@ -151,94 +176,4 @@ public class Wall3d
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void prepare()
|
||||
{
|
||||
System.out.println(South.toString());
|
||||
System.out.println(East.toString());
|
||||
System.out.println(North.toString());
|
||||
System.out.println(West.toString());
|
||||
}
|
||||
|
||||
public static void streamWallsOut(String name, LabyModel provider, OutputStream stream) throws IOException
|
||||
{
|
||||
int width = provider.getWidth();
|
||||
int height = provider.getHeight();
|
||||
int xl = 10;
|
||||
int yl = 10;
|
||||
int zl = 10;
|
||||
|
||||
// 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)
|
||||
{
|
||||
stream.write(new Wall3d(South, x * xl, 0, 0).toString().getBytes());
|
||||
}
|
||||
if ((walls & Brick.LEFT) != 0)
|
||||
{
|
||||
stream.write(new Wall3d(West, x * xl, 0, 0).toString().getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
short walls = provider.getWalls(0, y);
|
||||
if ((walls & Brick.LEFT) != 0)
|
||||
{
|
||||
stream.write(new Wall3d(West, 0, y * yl, 0).toString().getBytes());
|
||||
}
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
// south and east
|
||||
walls = provider.getWalls(x, y);
|
||||
if ((walls & Brick.DOWN) != 0)
|
||||
{
|
||||
stream.write(new Wall3d(North, x * xl, y * yl, 0).toString().getBytes());
|
||||
}
|
||||
if ((walls & Brick.RIGHT) != 0)
|
||||
{
|
||||
stream.write(new Wall3d(East, x * xl, y * yl, 0).toString().getBytes());
|
||||
}
|
||||
short path = provider.getPath(x,y);
|
||||
if ( ( path & LabyModel.SOLVED ) == LabyModel.SOLVED )
|
||||
// if ( (walls & ( Brick.GOAL | Brick.ENTRY ) ) == 0 )
|
||||
{
|
||||
// if ( ( (x+y) % 2) == 0 )
|
||||
|
||||
stream.write(new Wall3d(LowGround, x * xl, y * yl, 0).toString().getBytes());
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.write(new Wall3d(HighGround, x * xl, y * yl, 0).toString().getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.write("endsolid wall\n\n".getBytes());
|
||||
}
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
|
||||
Scanner console = new Scanner(System.in);
|
||||
int xl = console.nextInt();
|
||||
int yl = console.nextInt();
|
||||
int zl = console.nextInt();
|
||||
|
||||
int dx = console.nextInt();
|
||||
int dy = console.nextInt();
|
||||
int dz = console.nextInt();
|
||||
|
||||
String s = "solid wall\n";
|
||||
|
||||
Wall3d instance = new Wall3d(xl, yl, zl, dx, dy, dz);
|
||||
|
||||
prepare();
|
||||
|
||||
s += "endsolid wall\n\n";
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
93
java/org/artisanlogiciel/games/stl/Wall3dStream.java
Normal file
93
java/org/artisanlogiciel/games/stl/Wall3dStream.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package org.artisanlogiciel.games.stl;
|
||||
|
||||
import org.artisanlogiciel.games.Brick;
|
||||
import org.artisanlogiciel.games.LabyModel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class Wall3dStream
|
||||
{
|
||||
|
||||
String name;
|
||||
LabyModel provider;
|
||||
OutputStream stream;
|
||||
|
||||
Maze3dParams params;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param provider
|
||||
* @param stream
|
||||
* @param params
|
||||
*/
|
||||
public Wall3dStream(String name, LabyModel provider, OutputStream stream, Maze3dParams params)
|
||||
{
|
||||
this.name = name;
|
||||
this.provider = provider;
|
||||
this.stream = stream;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
private void writeWall3D(Wall3d wall3d)
|
||||
throws IOException
|
||||
{
|
||||
stream.write(wall3d.toString().getBytes());
|
||||
}
|
||||
|
||||
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(params.getSouth(), x * xl, 0, 0));
|
||||
}
|
||||
if ((walls & Brick.LEFT) != 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(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(params.getNorth(), x * xl, y * yl, 0));
|
||||
}
|
||||
if ((walls & Brick.RIGHT) != 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 ? params.getLowGround() : params.getHighGround();
|
||||
if ((path & LabyModel.SOLVED) == LabyModel.SOLVED)
|
||||
// if ( (walls & ( Brick.GOAL | Brick.ENTRY ) ) == 0 )
|
||||
{
|
||||
// if ( ( (x+y) % 2) == 0 )
|
||||
ground = reverse ? params.getHighGround() : params.getLowGround();
|
||||
}
|
||||
writeWall3D(new Wall3d(ground, x * xl, y * yl, 0));
|
||||
}
|
||||
}
|
||||
|
||||
stream.write("endsolid wall\n\n".getBytes());
|
||||
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,5 @@ create = Create
|
||||
save = Save
|
||||
quit = Quit
|
||||
title = A Maz ing
|
||||
seed = seed
|
||||
load = Load
|
||||
@@ -10,3 +10,5 @@ create = Créer
|
||||
save = Sauver
|
||||
quit = Quitter
|
||||
title = La Bireinte
|
||||
seed = graine
|
||||
load = Charger
|
||||
10
mybuild.xml
10
mybuild.xml
@@ -10,9 +10,9 @@
|
||||
<property name="src" location="java"/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="dist" location="dist"/>
|
||||
|
||||
<!-- Fill me please / todo -->
|
||||
<property name="artgraphicslib" value="artgaphics-0.2.0"/>
|
||||
<property name="distversion" value="1.0"/>
|
||||
<property name="distversion" value="1.1"/>
|
||||
|
||||
<target name="init">
|
||||
<!-- Create the time stamp -->
|
||||
@@ -26,6 +26,7 @@
|
||||
<!-- Compile the java code from ${src} into ${build} -->
|
||||
<javac srcdir="${src}" destdir="${build}" includeantruntime="false" classpath="libs/${artgraphicslib}.jar">
|
||||
<exclude name="org/artisanlogiciel/games/javafx/*"/>
|
||||
<compilerarg value="-Xlint:deprecation,unchecked" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
@@ -37,8 +38,8 @@
|
||||
<!-- Put everything in ${build} into the artloglaby-${distversion}.jar file ( ${DSTAMP} not used yet )-->
|
||||
<jar jarfile="${dist}/lib/artloglaby-${distversion}.jar" basedir="${build}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="org.artisanlogiciel.games.Display"/>
|
||||
<attribute name="Class-Path" value="${artgraphicslib}.jar"/>
|
||||
<attribute name="Main-Class" value="org.artisanlogiciel.games.maze.gui.Display"/>
|
||||
<attribute name="Class-Path" value="libs/${artgraphicslib}.jar"/>
|
||||
</manifest>
|
||||
<fileset dir="lang" includes="**" />
|
||||
</jar>
|
||||
@@ -50,5 +51,4 @@
|
||||
<delete dir="${build}"/>
|
||||
<delete dir="${dist}"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -2,6 +2,6 @@ project_name=artloglaby
|
||||
project_default=dist
|
||||
project_basedir=$(pwd)
|
||||
project_mainpackage=org.artisanlogiciel.games
|
||||
project_mainclass=$project_mainpackage.Display
|
||||
project_version=1.0
|
||||
project_mainclass=$project_mainpackage.maze.gui.Display
|
||||
project_version=1.1
|
||||
default_args='lab/lab30x30.raw'
|
||||
|
||||
42
renamelabindir.sh
Executable file
42
renamelabindir.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
labdir=$1
|
||||
newprefix=$2
|
||||
|
||||
if [[ -z $labdir ]]
|
||||
then
|
||||
echo "[ERROR] expect a lab directory"
|
||||
echo "will rename all labxxx.* within this directory to directory name labdirxxx.*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $newprefix ]]
|
||||
then
|
||||
newprefix=$labdir
|
||||
fi
|
||||
|
||||
{
|
||||
echo "[INFO] changing lab prefix to $newprefix"
|
||||
|
||||
declare -i index=1
|
||||
|
||||
pushd $labdir
|
||||
for f in $(find . -regextype egrep -regex "./lab[0-9]+x[0-9]+\..*")
|
||||
do
|
||||
if [[ $f =~ ./lab([0-9]+)x([0-9]+)\.(.+) ]]
|
||||
then
|
||||
width=${BASH_REMATCH[1]}
|
||||
height=${BASH_REMATCH[2]}
|
||||
extension=${BASH_REMATCH[3]}
|
||||
newname="${newprefix}_${index}_${width}x${height}.$extension"
|
||||
if [[ ! -e ./$newname ]]
|
||||
then
|
||||
mv $f ./$newname
|
||||
else
|
||||
echo "[ERROR] skip $f -> ./$newname since new name already used" >&2
|
||||
fi
|
||||
fi
|
||||
index=index+1
|
||||
done
|
||||
popd
|
||||
}
|
||||
37
scripts/laby.sh
Executable file
37
scripts/laby.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
findmainjar()
|
||||
{
|
||||
for MJ in $(find . -name "*.jar")
|
||||
do
|
||||
echo "$MJ"
|
||||
if [[ $MJ =~ artloglaby-(.*)\.jar ]]
|
||||
then
|
||||
VERSION=${BASH_REMATCH[1]}
|
||||
echo "found $MJ version $VERSION"
|
||||
MAINJAR=$MJ
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
echo "Ce script a été conçu pour une distribution linux"
|
||||
echo "This script was created for linux"
|
||||
|
||||
findmainjar
|
||||
|
||||
if [[ -z $MAINJAR ]]
|
||||
then
|
||||
echo "[ERREUR] aucun jar artloglaby-xxx.jar dans ce répertoire"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if which java
|
||||
then
|
||||
java -jar $MAINJAR
|
||||
else
|
||||
echo "Aucun java/jre de trouvé"
|
||||
echo
|
||||
echo "Pour ubuntu :"
|
||||
echo "sudo apt install openjdk-8-jre"
|
||||
fi
|
||||
@@ -1,5 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
function findmainjar()
|
||||
{
|
||||
for MJ in $(find . -name "*.jar")
|
||||
do
|
||||
echo "$MJ"
|
||||
if [[ $MJ =~ (artloglaby-.*\.jar) ]]
|
||||
then
|
||||
MAINJAR=${BASH_REMATCH[1]}
|
||||
echo "found $MJ jar $MAINJAR"
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
specific_run()
|
||||
{
|
||||
local action=$1
|
||||
@@ -33,9 +47,25 @@ create_zip_package()
|
||||
mkdir $dest
|
||||
# will be used at run time to save mazes
|
||||
mkdir $dest/lab
|
||||
mkdir $dest/libs
|
||||
cp scripts/laby.sh $dest
|
||||
|
||||
MAINJAR=""
|
||||
pushd dist/lib
|
||||
findmainjar
|
||||
popd
|
||||
|
||||
if [[ -n $MAINJAR ]]
|
||||
then
|
||||
printf '%b\n' "java -jar $MAINJAR"
|
||||
printf '%b\r\n' "java -jar $MAINJAR" >$dest/laby.bat
|
||||
else
|
||||
echo "[ERROR] can't find main jar"
|
||||
fi
|
||||
|
||||
|
||||
cp LISEZMOI $dest
|
||||
cp libs/* $dest
|
||||
cp libs/* $dest/libs/
|
||||
cp dist/lib/* $dest
|
||||
zip -r $zip_package $dest
|
||||
|
||||
|
||||
1
toolbox.param
Normal file
1
toolbox.param
Normal file
@@ -0,0 +1 @@
|
||||
ARTLOG_TOOLBOX=../artlog_toolbox
|
||||
Reference in New Issue
Block a user