How to create labyrinth

first, hello all.

I'm new in Java things, and i have a problem…

I'm trying to make a game, it should be model moving in labyrinth… but how to make labyrinth? i have world, i have moving model (actually, gray box now, but it doesn't matter). do i need to make a labyrinth model? or is there any way to make a txt file with matrix, and then use it,  just add box with texture where 1 in matrix is? how can i do something like that?

It's easy if you use a matrix.

lab = { {0,0,0,0}, {0,0,0,0}, {0,0,0,0} …}

0 = false

1 = true

Every block has 4 walls plus a floor. Easy structure and with a loop you can create every wall.

More difficult is to find a algorithm which creates you a working labyrinth. There are some outside in the internet.

An easy solution:

Random creation with 2 walls every block --> working Labyrinth, of course not perfect

Another problem. Because each blocks is next to each other, every block need only two walls -->x and -->y direction

lab = { {0,0}, {0,0}, {0,0} …}

Or if you want to use a static labyrinth you can create a 3D model and load it inside jME.

thanks a lot.

i think i'll do static model, because of time… i need to finish project soon (it's school project). i still have some problems with import 3ds files, but i'm running through forum for solve.

PS i was thinking about matrix with whole blocks like

lab={

block, clear, block, clear, block, block, clear;

block, block, block, clear, clear, clear, clear;}

but it's wasting memory, right?

I see 4 0/1's hmmmm… WHAT in the world is LIKE that it seems SO familiar

(You could use BYTES and do some bit math, then there is ZERO memory waste :D)

Check these also:

http://www.glimt.dk/code/labyrinth.htm

Think Labyrinth: Maze Algorithms

(^ the stuff on hypermazes blows my mind…)

k, i did static lab, it's faster ( /me slacker).

but i can't add it into my project…

base is from flagrush tutorial. but i wanna add lab on whole terrain (stretch it). is there any tip for that?

i can add any 3ds model into my project… using flagrush tut, also using other methods from forum, like:

```MaxToJme maxtojme = new MaxToJme();  //the converter         ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); //For loading the raw file                  // File Path for the model (dump file in toplevel of classpath)         //URL url = Main.class.getClassLoader().getResource(new File(name)).toURI().toURL());         URL url =  Sheep.class.getClassLoader().getResource("src/moje/PUMP.3ds");         try {          url = (new File("src/moje/PUMP.3ds")).toURI().toURL();         } catch (Exception err) {            System.out.println("Error loading 3ds model:"+err);                 }         //System.out.println(url);                        InputStream is=null;         try {             is=url.openStream();         } catch(Exception err)  {             System.out.println("Could not open Model file: "+err);         }         try {                      // Converts the file into a jme usable file             maxtojme.convert(is, bytearrayoutputstream);                      // Used to convert the jme usable file to a TriMesh             BinaryImporter binaryImporter = new BinaryImporter();             ByteArrayInputStream in=new ByteArrayInputStream(bytearrayoutputstream.toByteArray());                      //importer returns a Loadable, cast to Node             model = (Node)binaryImporter.load(in);         } catch(Exception err)  {             System.out.println("Error loading md3 model:"+err);         }```

yap, it's from this forum.
error:
WARNING: Your export has been saved with an incorrect encoding for it's String fields which means it might not load correctly due to encoding issues. You should probably re-export your work. See ISSUE 276 in the jME issue tracker.
2008-12-15 18:47:31 com.jme.scene.Node <init>
INFO: Node created.
WARNING: Your export has been saved with an incorrect encoding for it's String fields which means it might not load correctly due to encoding issues. You should probably re-export your work. See ISSUE 276 in the jME issue tracker.

and i dunno where to find solve...

thx a lot, as i said - it was tutorial based thing, so dont mind about textures etc…

check mailbox, its from problemski@gmail.com

regards

You got POST

good morning.

so…

i can add my models now:)

i had screwed jme, it wasn't jme1, neither jme2… something between:P

now it's jme2, and i rewrite some parts of code, and it's working.

but still - i can't see my labyrinth… is there a way to use model instead of terrain block?

or how add it on terrain block to see it?

```    private void buildLab() {         Node lab = null;         try {            MaxToJme C1 = new MaxToJme();            ByteArrayOutputStream BO = new ByteArrayOutputStream();             URL maxFile = Sheep.class.getClassLoader().getResource("moje/lab.3ds");             C1.convert(new BufferedInputStream(maxFile.openStream()),BO);             lab = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));             lab.setModelBound(new BoundingBox());             lab.updateModelBound();                  } catch (IOException e) {             logger                     .throwing(this.getClass().toString(), "buildLab()",                             e);         }                 lab.setLocalTranslation(new Vector3f(100,0, 100));         scene.attachChild(lab);         scene.updateGeometricState(0, true);         lab.setRenderQueueMode(Renderer.QUEUE_OPAQUE);     }```

or i can't do it in that way?

If your feeling confident about loading models, then I would say it looks like it should work; if not you may want to go back to the basics and get a simple cube model into jME.  Trying to go from castle modeling to jME could be the issue (ie model flaw, exporter flaw…)

it wasn't jme1, neither jme2... something between

For some reason that makes me think of the failed Ripley clones scene in Aliens Resurrection... :)

the point is that i know how to add models like in flagrush tutorials, f.e. player model or flag, but is there a way but build terrain with model?

but is there a way but build terrain with model?

Check out any of the tests (run jME SVN project) that are under the terrain category (search for terrain).

ok, i'm a dumbass.

i have working method, and of course i had it some time ago. i couldn't see lab because… it was too big/small… now all good, i found right scale…

…is there a way but build terrain with model…

It's not a big deal, but maybe you don't know so I give you some tips.

Inside TutorialGuide are the best examples, because really easy, good working and most of the time all you need.

The other examples are candy.

If you use Node like a box, you can make things simpler.

Inside a Node "terrain" is the Terrainpage, the Trees, the House and everything static.

Working only with terrain is much more easier.

And why scaling every object, if scaling one superclass Node is all you need.

That's why I like to use

public class SUPERNODE extends Node{}

Hope it inspired you^^

public class SUPERNODE extends Node{}

Not sure what the functionality of that would be seeing as how a node can be added to node (up to infinity or RAM space...).
But having the models different from the terrain is sure the way to go ;)  (unless its just a 'quick' project or proof of concept); most people add all the objects (tree, etc) to one node then add the terrain to another, then add both of those to the RootNode.

http://img183.imageshack.us/my.php?image=maxzoomny2.jpg

that's what i have for now. of course player wont be able to do such a zoom out:)) it's just for now. now i'm working on colisions, but… yes, i don't know java yet:)

oky, even if my idea wasn't good, i think topic can be closed…

Out of curiosity why not just use a XML (or even text) document to store all the locations of boxes, and read through it to load it up (placing each box at a location).  (then you will have you collisions 1/2 done… you will KNOW where everything is ;))

Locations could easily be obtained by scratch paper: draw grid the size of your maze, then the center of each 'cell' in your maze would simply be [colcellSize, rowcellSize], to make the floor the size is just [numColscellSize, numRowscellSize].

So, basically you would create the maze with a grid on paper, then copy the coordinates into your document; and place a box (cell sized box) every place you have saved a location, put a floor under it and you are done :)…

thank you for idea:D

and why i didn't do something like that before…? because… i didn't know that i can? in first post i think i asked about something like that…

ok, back to work:D i will try to do that:d

a picture is worth a thousand words

i left it how it was, i just tryed to add collisions like in TestCollision.java or TestCollisionTree.java (from jmetest.intersection),

but when i'm trying to add lab.findCollisions(player, results); or lab.calculateCollisions(player, results); it's working sooooo slooooooow and i can't even move model, and cam is jumping randomly, and it's looking like playing quake 3 on 133mhz proc…

lab = lab Node with that full lab model from 3ds,

player = player Node with 3ds model also.

i added both nodes to the scene in initGame(), and im trying to check collisions in update() method…

is it normal? or i did something wrong?

sorry, i don't know java, it's my 'first touch'…

i have dual core 2x1,66ghz and 1gb ram if it is important…

Actually, that was one of the reasons I was suggesting you try anouther system…

Since that is just one model, the collisions solver is may think that your 'player' is ALWAYS inside of an object and might go nuts…