mapzen pokemongo unity3d layers openstreetmap

PokemonGo clone using Mapzen – Part 5: Layers

Hey everyone, it has been a while but here I am with a huge update; single mesh layers, continuous roads, water&parks and more!

First of all, yea I know I shouldn’t be doing such huge updates and refactoring but I couldn’t help it this time. I got greedy and keep adding stuff. I’ll try to post smaller stuff more frequently from now on. I’m also sorry for the huge refactoring going on, it’s probably break everything if you built your stuff on previous versions but, trust me, totally worth it!

So what do we have here; (by here I mean; https://github.com/brnkhy/MapzenGo please do follow the github page as well, you can find latest fixes and stuff there.)

1) Single mesh layers is easily the biggest thing in this post. As you may remember, every single entity was a separate GameObject before which caused horrible performance and fps.  I was having issues even with 9 crowded tiles (see Paris) using that method.

What I did was simply merging meshes of same type entities under one single gameobject. For example, all buildings in a tile is single GameObject now. Or all roads, or parks. So instead thousands of small gameobject in every single tile, we have 4 now; Buildings, Roads, Water, Parks.

What’s the catch? Well you won’t be able to click&select buildings anymore. If you were planning anything like that, it might be better not to use layers (or handle click position and building relations differently in the background). And the tile creation is NOT threaded yet so it’ll stutter a little during the initial loading process. I’ll look into that as soon as possible as well.

Oh and you can activate/deactivate this thing from World Settings so you can still stick with the old system if you want!

mapzen pokemongo openstreetmap layersSee? This was pretty much impossible in previous versions but now you can enjoy the view in 70+ fps no problem (hopefully)

2) Continuous roads. Well not too continuous though. Let me explain; Mapzen road data is kinda hard to work with, it’s not a graph, not even properly connected. It’s just a bunch of, disconnected, unrelated road segments. So about continuous roads, yea it’s quite easy to make those road segments continuous, sure but almost impossible to create a connect all those segments, create a graph and smooth all together. OK, not impossible but not an easy task either so I’ll skip that for now.

mapzen pokemongo openstreetmap layers
As you can see, segments are continuous now but connections between segments still looks ugly. And yea it’s not smoothed either but it’ll be quite easy now that we have them in one piece.

3) Major refactoring. I really hate making big refactoring sessions like this but I really had to this time, mainly for layer things. Right now, building, water, road class are just keeping data. Removed all mesh generation code from those and moved them to factories. Admittedly it should have been like them from the beginning… my bad. But anyway, this new structure should be much better now. There is still some stuff to do there, but hopefully, won’t be this big.

4) Landuse layer! I almost forgot that but yea, we have a landuse/park layer now. Landuse layer has quite different stuff in there, bridges, parks, residential zones etc. I decided just to go with parks at the moment, as others made the general look messy. You can tweak it as you like, please let me know what about your work as well!

5) Also fixed some issues from Github Issues page. You can always post your reports/requests there as well. I’m actively using it!

mapzen pokemongo openstreetmap layers roads
Guess that’s it for now. Just run the sample and walk around Paris, you’ll see it’s soo much better than previous versions. I really hope you’ll like it as well.

Sooo what’s next? Not sure really, threading, visual improvements, more layers, custom objects, GPS, android build…. There is soo much to do and I’m quite sure I’m forgetting lots of other stuff. I’ll try to decide&post what’s next as soon as possible.

Please let me know what you think of this series, if you like it or not, if it’s useful for you, anything really.
Cheers,
Baran

Github Page
Download PokemonGO Clone Part 5: Layers

15 thoughts on “PokemonGo clone using Mapzen – Part 5: Layers

  1. Baran, you have done a very great job.
    Thank you for that.
    Do not turn off the ability to use the old system of generation facilities.

    I advise you to develop graphical component of the project: the trees and the grass in the park, the generation roofs, the use of colors of buildings from OSM data, using height and initial position of buildings, separate textures for different types of roads (asphalt road, dirt road, path, etc. ) generation bridges etc.

    Kindly requested, will no longer spend as much sharp refactoring, this complicates the update is applied to the working project.

    1. Hey Alexey, thanks man!
      You’re absolutely right about the refactoring thing, I hate breaking changes but I felt like I had to do it. I’ll avoid it as much as possible in the future.
      About visual stuff, I’m hoping to try BuildR some day, looks like a great script and would be a great addition to my project. I’ll look into other stuff as well but there is so much to do there and I feel like it’ll never be enough & look good. So it might be a better idea to keep visuals (models) abstract.

  2. Hi again Baran. Great work!
    During the initial load, all the tiles are being loaded all at once. Maybe it could be loaded one by one beginning from player’s current tile and then 8 outer tiles, then the other tiles.
    Also integrating weather from some API could be nice. Although that is a different scope, it could be a good mash-up.
    Do you plan to release this in Unity Asset Store after improvements and adding some options? It could be an Instant hit. Options could include colors, layers, tile size, number of tiles etc.
    Two questions 🙂 can you estimate how much data would OSM API would consume for an hour of walk in streets of Paris? Definitely less than Google’s static Image API :).
    Second question is on OSM’s capability. Do you thing it can compansate Google Maps ? I have seen that it is pretty detailed and better than Google for some parts of the largest cities. But in smaller towns it lacks Google Maps’ details. But still it has a nice coverage of roads. What do you think ?

    1. Hey Kadir,
      Yea it’s definitely possible to improve that loading part, especially the initial load. I’ll try threads and stuff there I guess, then maybe something like moving from center towards outer tiles etc.
      Weather is a totally different thing as you said. I’ll concentrate more on map at the moment but please let me know if you do that, would be great!
      I also want to release it on asset store, yea but there is soo much to do, I can hardly catch up with bug reports and all the feedback these days 🙂 Damn busy days.

      About data usage, it’s quite easy to calculate that. Paris for example is one of the best mapped places and each tile seems to take something like 250-300kb with four layers (building, water, road, landuse). Surely you can cache that and it’ll only go down in other, not so detailed, places. But I guess that’s enough for a quick estimate. It may not be less than simply pulling images (especially if they are low quality) but images doesn’t give you any data to work with so that’s a totally different thing.

      I have no experience with google data really, but if I’m not mistaken, it’s not free right? That alone pretty much kills it for me. I’m pretty sure it’s worlds better than osm, I mean osm doesn’t even have Istanbul mapped properly but…. it’s free 🙂 And yea, even though road data structure isn’t good, coverage seems great.

  3. Great work BRNKHY! Can we change the location to the United States? How do I enter a longitude latitude or address? .. the only google data that is free that I’m aware of is Google API, but does not include Building information, only mapping. Thanks!

    1. Hey Steven, glad you like it!
      You can find the lat/long settings under the “World” object. It should be ready to go after that!

  4. Hola @BRNKHY, espero que entienda el español XD

    He seguido su trabajo desde su primera publicación y me parece magnifico, especialmente en su rendimiento, pensé que no seria posible visualizar tantas geometrías sin que cayeran los frames por el suelo.

    Bueno en mi humilde opinión me gustaría ver un par de cosas:

    1. Guardar o cargar los archivos .osm para poder visualizarlos de manera offline.
    2. Un buscador para localizar calles, edificios o lugares, como lo hace google maps.

    Yo seria feliz con esas dos mejoras, pero solo véalo como una petición.

    Muchas gracias por compartir.

    Tal ves no lo conozca y podría ayudar un poco, es un proyecto similar al suyo y también es de código abierto.
    http://forum.unity3d.com/threads/dynamic-3d-world-rendering-using-offline-openstreetmap-data.281711/

    1. No hablo español, pero puedo usar el traductor de google!

      First of all, glad you like it! And yea I’m planning to start working on offline mode pretty soon (probably this week). I’ll do some very basic stuff at first, might extend that later on if necessary.
      Locating streets and stuff is also a very good idea. But it might not be that important for the majority so guess it’ll be low priority for now. Still I’ll definitely look into that!
      Thanks for your feedback man, means a lot!

  5. brnkhy..i like your great work….this version is better…….but i cant load tiles dinamic…….maybe i forgot something….or this version dont use it?………sorry for my bad english again…….

    1. Hey Kano!
      Dynamic Loader is still there and should be working normally. Are you sure you have the DynamicTileLoader script on the World object, not the TileLoader?

  6. thanks brnkhy…..thats it……..its working now….i dont see both scripts in the same object……..maybe i need sleep more……….thaks again.

  7. Hey bro great work!!! I really need this for my project!! I have one problem. The third person is not moving and how can I change the location by using gps of the person using it so it can locate the user real time

    1. Hey Bryce, thanks man!
      It’ll be difficult to explain here like this but I’ll look into the gps thing soon. It’s holiday here next week so hopefully (and finally), I’ll have time for that!

Leave a Reply