Navigation map file format?

Navigation map file format?

Postby Cale Vinson » Sat May 01, 2010 10:41 am

Worked through the "Moving your Iam" section of the wiki - was a lot of fun to watch the bot following me, filling in the navigation map as it went. :)

But as you note in the wiki, this is going to be a pretty slow way to generate a navigation map. What I'd like to do is write some sort of utility that takes, say, a list of (potentially quite spatially-large) connected triangles that mark the accessible areas, and converts it into the map-format you use.

I've had a quick poke inside "map.txt", and one sees stuff like:

Code: Select all
(3109.5 3342 34.5)=34.5345 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0


From that, and the javadocs, I'm guessing that we have a dictionary arrangement of <key>=<value> pairs.

The keys seem to be quantized locations, with a granularity of 0.5m?
The first number in the value vector is presumably the accurate z?
The remaining values are presumably direction-masks, as to whether we can move in a particular direction? There are 26 such masks. Compass directions are divided into 45 degree-chunks, so there are eight of those (E, NE, N, NW, etc). We can also simultaneously move up, down, or stay level, so that's 8 x 3 = 24 directions, plus "pure up" and "pure down", making 26. (Or now, that I finally think about it, simply 3^3 - 1. :D )

So, two questions:

a) Have I understood the format correctly?
b) In the sample-line above, what order are the directions laid out in?

- Cale
Cale Vinson
 
Posts: 25
Joined: Sun Mar 21, 2010 5:21 am

Re: Navigation map file format?

Postby admin » Tue May 04, 2010 12:54 am

a) Have I understood the format correctly?
b) In the sample-line above, what order are the directions laid out in?


Yes, you have understood correctly. The easiest way to think about it is to picture your Iam in the center-block of a Rubik's cube. And then you can move to any of the 26 adjacent blocks. The order of the directions is: N, S, W, E, NW, NE, SW, SE, UN, US, UW, UE, UNW, UNE, USW, USE, DN, DS, DW, DE, DNW, DNE, DSW, DSE, U, D

The naming is based on a compass, where N=North S=South E=East and W=West. U=Up and D=Down. So UNW stands for up-north-west
This is defined in the Location class. So Location.UNW is a constant equal to the vector (0.5, -0.5, 0.5)

I stalled in the Wiki when it came to maps. The situation currently is that I have a Lua script that automatically makes maps. It works quite well, but unfortunately, for some silly technical reasons, it's very slow. The map of Iam Town was generated with this script. I was going to work with one of our developers to build map-making into the CryEngine, so that it will become much, much faster. But that developer still has a few higher priority tasks to finish first. I'm expecting he'll become available upon finishing the next release, which is by the end of this month.

So your options are:
- Use my Lua script. Which is rather user-unfriendly, but not real hard. If all you need is mark a few areas it's definitely an option to consider.
- Wait for us to improve map-making.
- Build your own. I'm always open to suggestions how we can do this and always willing to help.

Mark Boon
admin
Site Admin
 
Posts: 69
Joined: Thu Feb 18, 2010 9:54 pm

Re: Navigation map file format?

Postby Cale Vinson » Tue May 04, 2010 2:33 am

Many thanks for your speedy response Mark.

admin wrote:So your options are:
- Use my Lua script. Which is rather user-unfriendly, but not real hard. If all you need is mark a few areas it's definitely an option to consider.
- Wait for us to improve map-making.
- Build your own. I'm always open to suggestions how we can do this and always willing to help.


Option One.

I'd certainly like to at least try the Lua script. If it was "slow" in the sense that you needed to leave the PC running all night to generate the map, that wouldn't be a problem for me.

Option Two.

I work with Des (Desmond Shang). He's like a big puppy dog, and equally hard to disappoint. :D

Option Three.

Well, here's what I was doodling around with in the back of my mind. It may be stoopid, feel free to say so. :) It also deals only with the 2D "quasi-flat" case (which is probably all we need *initially* for the central shopping area in Caledonia).

a) In the city-editor, place four markers that define the corners of the rectangle of interest, in our case the Caledonia central shopping area. Note the x,y coords of those markers.

b) Zoom the camera up, and take a screenshot of the ROI (can one do an orthographic view in the city-editor?).

c) Fire up Blender or your other 3D editor of choice. Just need anything that supports obj format (I'm picking that format because its an easy one to parse). Create a cube/plane/whatever of the same x,y coords as the ROI, and texture it with the image from (b). This is your "reference map" (RM).

d) With the (RM) as a guide, inside Blender construct a triangular mesh that defines the area where Iams can walk. Yes, this is manual work, but for the Caledonia shopping area I don't think it'd take that long to do. Save this triangular mesh as an obj file.

e) Convert the triangular mesh to a Iam map.

e.1) Generate nodes on a dx = 0.5, dy = 0.5 meter grid. Reject nodes that don't lie within any of the triangles.

e.2) Two adjacent nodes can be navigated from one to the other (have their associated direction masks set) if:

e.2.a) They lie inside the same triangle, or,
e.2.b) They lie in different triangles on opposite sides of a shared-edge.

f) I haven't considered the z coordinate yet. :)

f.1) For the Caledonia shopping area, which is basically flat with the odd raised walkway/platform, it wouldn't be that onerous a task to group-select vertices in Blender and assign them the correct Z values.

or

f.2) Once the (x,y) coords of the triangular mesh from (d) are known, one could have a Lua script that determined the associated z values by doing a pick-function down from some height (again, the 2D assumption).

---------

A crude brute-force implementation of (e) would be very slow, but I don't really care. Moreover, it could potentially be sped-up by going to some sort of "line-drawing" algorithm, ie., project a horizontal (running E to W) line across a triangle, clip it by the triangle edges to create a line-segment, then two adjacent nodes on that line-segment are known to be walkable from E to W.

========

If, as i guess, you're focussed on purely automatic methods for Iam map generation, then, clearly, my suggested Option three is of no interest. Heck, it will be of little interest to me if the "cost" of Option One is simply extra computer number-crunching. :)

- Cale
Cale Vinson
 
Posts: 25
Joined: Sun Mar 21, 2010 5:21 am

Re: Navigation map file format?

Postby admin » Tue May 04, 2010 2:45 am

Option One.

I'd certainly like to at least try the Lua script. If it was "slow" in the sense that you needed to leave the PC running all night to generate the map, that wouldn't be a problem for me.


Tomorrow I'll see if I can make the script available. And I'll include instructions on the Wiki. "Slow" means that running it all night maps maybe an area of 25mx25m. (I'm not sure exactly how much.) And it rarely makes it through the night, the CryEngine often freezes somewhere after midnight for as yet unidentified reasons. At least it works incrementally, so all you need to do is start it again and it will continue where it left off.

Mark Boon
admin
Site Admin
 
Posts: 69
Joined: Thu Feb 18, 2010 9:54 pm

Re: Navigation map file format?

Postby admin » Tue May 04, 2010 8:32 pm

Today I've added an advanced topic to the Wiki about map-making using our Lua script. Before trying it out, please make sure you download the IamFramework (again) first and put it in your workspace.

As usual, let me know if you have any suggestions or run into problems following the instructions on the Wiki.

Mark Boon
admin
Site Admin
 
Posts: 69
Joined: Thu Feb 18, 2010 9:54 pm

Re: Navigation map file format?

Postby Cale Vinson » Thu May 06, 2010 3:19 pm

Thanks for that Mark.

Its late and I may be doing something dumb, but I'm having problem with this part of the wiki instructions:

It should contain a 'Game' directory. Inside that directory there is a 'Scripting.pak' file. You need to rename this file to 'Scripting.zip' and use an archiving tool to extract the contents.


The file is there, I rename it to a zip file, but none of the archivers I tried (WinZip, WinRar, or 7-zip) were able to read or extract the contents.

I have the vaguest of memories of reading a post at the main BM forums which indicated that the Scripts, which had previously been open to all, had been compiled and encrypted late last year.

- Cale
Cale Vinson
 
Posts: 25
Joined: Sun Mar 21, 2010 5:21 am

Re: Navigation map file format?

Postby admin » Thu May 06, 2010 8:25 pm

Rats, I didn't know about that.

Scripts are still accessible, you can download them separately from the download section of the My Developer Page. It contains scripts for the Bowling and Golf games and such. But only a limited API is supported to prevent misbehavior. The mapping script wouldn't work because it writes to the local file-system...

So I'm a little at a loss how we can share this Lua script at the moment, that's not something I had counted on.

I'll continue to think what we can do for map-building. But unfortunately it may take me a little while to work it through the decision-making process here.

Mark
admin
Site Admin
 
Posts: 69
Joined: Thu Feb 18, 2010 9:54 pm

Re: Navigation map file format?

Postby Cale Vinson » Fri May 07, 2010 2:30 pm

admin wrote:Scripts are still accessible, you can download them separately from the download section of the My Developer Page. It contains scripts for the Bowling and Golf games and such.


Sorry to be a pest, but are you sure about that? I have the sample city data (which I assume is what you're referring to), and its does have some scripts (for golf and bowling as you say), but I don't see a "newcoexample.lua", which is one of the 'missing' errors I got when I tried to run the mapping script.

admin wrote:So I'm a little at a loss how we can share this Lua script at the moment, that's not something I had counted on.

I'll continue to think what we can do for map-building. But unfortunately it may take me a little while to work it through the decision-making process here.


Fair enough, understood.

In that case, I *might* try my horribly-kludgy, manual, restricted-to-2D, approach outlined in Option Three above. Two quick questions on the map format if I may:

a) Does the map file need a node for every 3D location, or does the Iam just never go where it doesn't have nodes?

b) Is there an ordering of nodes in the map file that has to be satisfied? I ask because it might be useful to be able to paste one (portion of) a map file, into another. If two users have the same shop, one might be able to generate the navigation map for the first shop, have a utility to "translate" that to get the second shop map, then "add" them together. (I'm not suggesting you do any of this I hasten to add. :) )

- Cale
Cale Vinson
 
Posts: 25
Joined: Sun Mar 21, 2010 5:21 am

Re: Navigation map file format?

Postby admin » Fri May 07, 2010 6:32 pm

Sorry to be a pest, but are you sure about that? I have the sample city data (which I assume is what you're referring to), and its does have some scripts (for golf and bowling as you say), but I don't see a "newcoexample.lua", which is one of the 'missing' errors I got when I tried to run the mapping script.


Not all scripts are there. In particular some scripts that could be harmful have been left out, including some libraries. But the mini-game scripts are there. Since the mapping script actually acts like a mini-game, I thought it would work. But the file-IO library is not there, which it needs. Why it says "newcoexample.lua" is missing when running my script I have no idea. If there's a relation it is accidental.

a) Does the map file need a node for every 3D location, or does the Iam just never go where it doesn't have nodes?


No, of course not. The number of potential 3D locations is huge. So the Iams only take into account locations it has data for when navigating.

b) Is there an ordering of nodes in the map file that has to be satisfied? I ask because it might be useful to be able to paste one (portion of) a map file, into another. If two users have the same shop, one might be able to generate the navigation map for the first shop, have a utility to "translate" that to get the second shop map, then "add" them together. (I'm not suggesting you do any of this I hasten to add. )


There's no fixed order, they can be in any order you like. So stitching together maps is very easy, just copy-paste in a text editor. You have to take into account the possibility of overlapping areas though. Generally you should expect it only to keep the information of a location that was added last. Also, if you want to continue expanding this merged map, you also have to merge the todo.txt files and collision.txt files. The latter are actually not used yet, but they might be in the future so it's better to keep them around.

As soon as it's more clear which direction this mapping thing goes it's possible I'll make some more tools available to deal with maps. For merging multiple map-files and compacting them. But for now you just have to deal with the verbose format.

Mark Boon
admin
Site Admin
 
Posts: 69
Joined: Thu Feb 18, 2010 9:54 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron