Page 1 of 1

Map Viewer

Posted: Sat Apr 14, 2012 3:02 pm
by hblok
Greetings developers,

I've played Andor's Trails for a while now, and started to look at the source, editors, and the forum posts. A common theme seems to be that writing the dialogues is a bit slow. Possibly because the dialogue editor is a bit uninspiring? I don't know, but I still though it would be neat to spice it up a bit, so I wanted to add a view of the area where the dialogue is taking place. And so this map viewer was born. Please see it as fruit for discussion, rather than a final contribution.

Since the intention was to have the map show as part of the HTML/JS editor, the original idea was a HTML5 Canvas implementation. However, I ran into problems with the zlib compression, and ended up in Java instead. There's a Java Applet example, but that's not very convenient because of the Security Permission setup. I might still port to JS, if there is interest. Please see NOTES.txt in the Jar file for details.

The viewer can stitch multiple maps together, and show large sections of the world. Although, the current implementation is memory heavy, and about 20 maps will easily take 1 GB of memory. Here's an example of a view of the areas between Crossglen, Fallhaven, Vilegard, Flagstone and the Crossroads: http://hblok.net/big_stitch.jpg (3.5 MB)


If your interested, download this archive which combines binary and source code:

http://hblok.net/mapviewer.jar (3.3 MB)


* To run
You probably have to change the path to the Andor's Trail source.

- From Jar
java -jar mapviewer.jar /usr/local/andor/andors-trail-read-only/AndorsTrail

- From Ant (after unpacking jar)
jar xvf mapviewer.jar
ant -DandorSrcPath=/usr/local/andor/andors-trail-read-only/AndorsTrail


Please see README.txt for more details.


I'm looking forward to your comments and ideas.

Regards,
Havard

Re: Map Viewer

Posted: Wed May 16, 2012 8:51 pm
by oskarwiksten
Hello hblok, welcome to the forums!

Sorry for the extremely late update on this. I should have commented on this ages ago when you posted it.

Wow, nice work!

This looks like a really neat application, and really something that could be useful as a stand-alone tool for the game. The worldmap we will have in-game will require a whole different approach, to not consume as much memory, since our aim is at around 16MB(!) allocated memory on the device. But as a stand-alone tool, this is really interesting. For example, for the upcoming worldmap I think we'll need to assign something like "world-coordinates" to each map, to make the process of stitching them together a bit more efficient, and a tool like this could really help with that!

It may not be as obvious, but we have an early version of a sort of world-map in a tmx-file that we use when developing new maps, to remember the names of each map:
http://code.google.com/p/andors-trail/s ... ld_map.tmx
Maybe this tool can be adapted into generating such a map automatically? Could be really nice, and would save a lot of work in maintaining that file.

I should also add that your idea of a javascript/html5 worldmap sounds really interesting. If you are interested in continuing on that, and want to get over the zlib compression obstacle, I have heard that the "jsxcompressor" library can do zlib and deflate decompression in pure javascript:
http://jsxgraph.uni-bayreuth.de/wp/jsxcompressor/

Again, nice work! Looking forward to seeing what we can make of this!

Re: Map Viewer

Posted: Wed May 16, 2012 9:46 pm
by hblok
Hi Oskar,

Thanks for your reply. I assumed people here were very busy, or very quiet. :)

Yeah, generating this kind of map on the phone is a no-go. It would have to be pre-processed somehow, and possibly tiled up itself, just as the game view is tiled and split.

World co-ordinates sounds interesting, and would of course simplify the rendering job. However, what do you do with maps which overlap each other? For example inside buildings, or rooms and coridors at different levels. Don't include them at all, or keep only a "place holder represntation"; e.g. lots of grey rock to represent the insides of Blackwater Mountain?

I hadn't seen the "unfinished_world_map.tmx" file. If you think this application would help in auto-generating something, I'd be happy to look into that. Maybe that file also answers my questions above.

As for JS zlib decompressers, I made some notes about that in the "NOTES.txt" included in the linked jar. The quick summary: I tried three different JS libs, including the one you linked, and none of them could read the zlib compressed data in the TMX files (although they could process data they generated themselves). So to implment a JS version of the map viewer, we'd have to find a work-around for that. Maybe a stand-alone pre-processor which uncompress the layer data is an option.

Regards,
Havard

Re: Map Viewer

Posted: Wed May 16, 2012 10:11 pm
by oskarwiksten
Hi again,

about the world-map, we recently added a <property> to the <map> element, that sets "outside"="1" for all maps that we consider to be outside. The thought for that was that all maps that have "outside"="1" should be rendered on the worldmap, which in effect would exclude all indoor maps. Maybe we'll have to tweak that for some special maps that are connected through cave systems, to consider them indoors even though they are outside (for example, "wild14_clearing.tmx").

And about Blackwater mountain, I would really like to have them on a separate worldmap and not show up on the main outdoor worldmap since they overlap with what we have planned for the road to Carn Tower. Maybe something like a larger map of a whole dungeon, but used for the whole of BWM even though they are outdoors? It might be possible to encode this in the <property> tags of each maps. Maybe one property stating which "overview map" they belong to, and one property stating the map's relative coordinates on that particular overview map, with one of the overview maps being the actual outdoors world map.

My general though for a world-map in-game is that we generate down-scaled png files that we store on the sd-card for each map that the player visits, and then create a html fragment that links all these png files together with absolute positioning. That way, we can make use of a html view that all Android devices have, which would have the benefit of giving pinch-to-zoom and all those nice features that Android users are accustomed to, without having to code it ourselves.

Re: Map Viewer

Posted: Tue Jun 05, 2012 1:35 pm
by debragon
Hi, hblok. You've done a great job. Actually, i like the idea of generating maps automatically. Can this be realized?

Re: Map Viewer

Posted: Tue Jun 05, 2012 2:41 pm
by Sarumar
+1 Great news here

Re: Map Viewer

Posted: Sun Jun 10, 2012 5:39 pm
by hblok
Hi again,

I hope you will like this update. A second version of the MapViewer, now including map generation, CLI rendering, and a small web server to serve maps in a "AJAX" like application (the idea was all along to put the maps next to the conversation editor).

I've removed the previous file, and replaced with:
http://hblok.net/andor/mapviewer_0.2.zip (3.4 MB)

Despite its name, it is still a Java jar, so you can enjoy all the functionality without unpacking. If your Andor SVN is not in the same location as mine, you have to specify another path, as shown below. I hope I've avoided *nix specific path separators throughout the code, but feel free to report issues.


* For the native Java App
(New: Save TMX button)

Code: Select all

java -jar mapviewer_0.2.zip /usr/local/andor/andors-trail-read-only/AndorsTrail

* For the web server / client

Code: Select all

java -jar mapviewer_0.2.zip server /usr/local/andor/andors-trail-read-only/AndorsTrail
Use the browser client at
http://localhost:8088


* Command Line Tools

Here are some convenience tools, which can be used from the command line. Please note, the path to AndorsTrail source code is hard coded here. Please change the source (net.hblok.andor.application.Cli) if this does not match your system. Also, all tools write to a hard coded file in the current directory (world.png, or world.tmx).

Also, notice that the relative paths in the world maps were a bit awkward, so in the end I created a symblink from within AndorsTrail to itself (i.e. "cd AndorsTrail; ln -s ../AndorsTrail").

Finally, notice the memory requirement for rendering of the large world maps. Initially, it took 10 GB (!) to render the unfinished_world_map.tmx, but I improved it down to "only" 3 GB.

Code: Select all

    java -Xmx3000m -jar mapviewer_0.2.zip tmx2png /usr/local/andor/andors-trail-read-only/ProjectPage/maps/blackwater_mountain_dungeons.tmx

    java -jar mapviewer_0.2.zip render wild12,wild13

    java -jar mapviewer_0.2.zip maps2tmx wild12,wild13

Have fun! Let me know how it goes.

Regards,
Havard