reinterpretcat / utymap

Highly customizable library for procedural world generation based on real map data
Apache License 2.0
964 stars 151 forks source link

c++ portion -- UtyMap.Shared linking #100

Closed brucechase closed 7 years ago

brucechase commented 7 years ago

Great work! Very, very nice coding...
I would like to look at adding a few features. --improve each individual tile elevation change/integration with neighbor tiles (the individual tiles appear to essentially be "flat" ground except for a few meters that slope to adjoining tiles). --predictive path for tile instantiation... if one is following a road for instance at at a given speed... --3d Bezier curves along roads with integrated slopes with surrounding terrain. -- allow buildings foundations to run below grade

BUT.. I cannot get UtyMap.Shared to link correctly in VS 2015 x64. I feel like I am missing some setting. utymap compiles nicely as a static library. When it is included into utymap.shared, utymap.shared compiles, but does not link. I am using /MDd on both. I am using the very latest of Boost, ProtoBuf, and ZLib (all x64). I am using your CMake files to build the sln. Any ideas?

Thanks for your fine work, Bruce bruce.r.chase @ gmail

reinterpretcat commented 7 years ago

Thanks for feedback!

--improve each individual tile elevation change/integration with neighbor tiles (the individual tiles appear to essentially be "flat" ground except for a few meters that slope to adjoining tiles).

The seam between tiles appears because of elevation noise applied to every vertex except on tile borders. I think proper solution is to apply noise on all vertices. This can be done when there will be guarantee that neighbor tiles don't have unique vertices on borders (should be implemented already, but I'm going to check this for terrain modification feature).

--predictive path for tile instantiation... if one is following a road for instance at at a given speed...

This should not be difficult: which tile to load is decided on C# code level and there is already API in ITileController:

       /// <summary> Loads all tiles for given region and level of details. </summary>
       void OnRegion(Rectangle boundaries, int levelOfDetails);
       void OnRegion(BoundingBox boundaries, int levelOfDetails);
       void OnRegion(IEnumerable<QuadKey> quadKeys);

There is one bottle neck: all tiles are loaded synchronously, one by one. Main reasons:

--3d Bezier curves along roads with integrated slopes with surrounding terrain.

Can you expand your idea? So far, roads are processed as regular terrain layer using line offsetting algorithms provided by clipper library. This approach simplifies a lot solution for road intersections, but has some problems (connection artifacts). I have story to improve this: https://github.com/reinterpretcat/utymap/issues/93

-- allow buildings foundations to run below grade

Also would be nice to have some details here as well :) BTW, I have elevation support via SRTM already in place (mostly inherited from first iteration of this project called ActionStreetMap), but have not decided how to fix problem with elevation differences for buildings part (e.g one corner of the building is on 37 meters above sea, another - 40 meters).

I cannot get UtyMap.Shared to link correctly in VS 2015 x64

I don't use any specific options. Here described how I used to build the project from scratch with VS2013 x64: https://github.com/reinterpretcat/utymap/wiki/Install-on-Windows My guess there is the problem with zlib/protobuf dependencies. Can you post your link error here? I'm curious what is the problem.

There is second way with "cheating." which I'm using to build library on android to avoid building dependencies for armeabi-v7a architecture (I spent couple of hours and failed, so decided to do it later). The main idea is to remove all dependencies to protobuf/zlib in code. These libs are used only to parse osm pbf files. Boost is not needed to be built: I limited myself from excess usage of Boost: header-only functionality is allowed for production code (but you need to build it for unit tests). Here you can see steps needed to remove dependent code: https://github.com/reinterpretcat/utymap/wiki/Install-on-Android

brucechase commented 7 years ago

Ilya,

Thanks so much for the reply.

Let me explain first what I am trying to do. I handcycle to stay in shape. I ended up designing and building my handcycle out of carbon fiber... and after doing that I decided I needed a way to workout during the winter. So I want to build a way to ride in virtual reality (via the handcycle on a trainer). And I want to be able to ride anyplace in the world (like the mountains in Switzerland!). For me, traveling is really difficult So your whole project caught my eye.

I have a predetermined path before the start of the workout. The path is put through a preprocessor to smooth the path. The preprocessor takes the path's lat/long through Google servers to gather elevation. It then smooths the path in 3D (since Google servers do not do a very good job). If this is not done, the changes along the path in Unity3d can be jerky.

Here is more detail.

You are right about Protobuf I think. Here is an example of the linking error:

Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol "private: static int __cdecl google::protobuf::io::CodedOutputStream::VarintSize32Fallback(unsigned int)" (?VarintSize32Fallback@CodedOutputStream@io@protobuf@google@@CAHI@Z) UtyMap.Shared D:\Unity\Terrains\utymap\core_build\shared\UtyMap.lib(osmfo rmat.pb.obj) 1

I have tried with both Visual Studio 12 Win64 and Visual Studio 14 Win64. I am using newer versions of boost and protobuf. Maybe I have to move back to an older version of ProtoBuf.

Bezier curves on roads:

You can see the difference between my preprocessor's path (in red) and the road's configuration. I would like to bring them together and apply nice curves to the road: [image: Inline image 1]

After smoothing the road curves (in Y direction as well), then maybe the terrain-to-road changes can be improved to be more realistic: [image: Inline image 2][image: Inline image 4]

Elevation:

My idea is very simple... add a meter or two to the base of the building's (and tree trunks) in order to ensure that the bottom of the base is below grade.

[image: Inline image 3]

The other idea is to give a smoother change from one tile to another. This is an example of the problem in plan and 3D view: [image: Inline image 5][image: Inline image 6]

And:

[image: Inline image 7][image: Inline image 8]

Preload: You made the point that I can use C# to load tiles predicatively along the path. As I think about it, I could run a process to load the whole path's tiles into the cache before the "rider" goes into Unity3d to "ride".

Smoothing very close tiles vs. "far away" tiles: If I want to climb the Swiss Alps, then I would want to view far-away tiles (such as at the top of the mountain) as well as the close tiles -- but in different detail. In order to speed-up the FPS in Unity, then there would have to be quite different detail level.

... just some of the things I am thinking about.

Thanks again,

Bruce

On Sat, Oct 8, 2016 at 4:53 AM, Ilya Builuk notifications@github.com wrote:

Thanks for feedback!

--improve each individual tile elevation change/integration with neighbor tiles (the individual tiles appear to essentially be "flat" ground except for a few meters that slope to adjoining tiles).

The seam between tiles appears because of elevation noise applied to every vertex except on tile borders. I think proper solution is to apply noise on all vertices. This can be done when there will be guarantee that neighbor tiles don't have unique vertices on borders (should be implemented already, but I'm going to check this for terrain modification feature).

--predictive path for tile instantiation... if one is following a road for instance at at a given speed... This should not be difficult: which tile to load is decided on C# code level and there is already API in ITileController:

   /// <summary> Loads all tiles for given region and level of details. </summary>
   void OnRegion(Rectangle boundaries, int levelOfDetails);
   void OnRegion(BoundingBox boundaries, int levelOfDetails);
   void OnRegion(IEnumerable<QuadKey> quadKeys);

There is one bottle neck: all tiles are loaded synchronously, one by one. Main reasons:

  • OSM server is quite slow and may reject requests (I consider to use another osm provider, e.g. mapzen)
  • There were some issues in core related to StringTable class with multiple requests. In general, loadQuadKeys function in core is designed to be thread safe. So, it should work, but it is not tested.

--3d Bezier curves along roads with integrated slopes with surrounding terrain. Can you expand your idea? So far, roads are processed as regular terrain layer using line offsetting algorithms provided by clipper library. This approach simplifies a lot solution for road intersections, but has some problems (connection artifacts). I have story to improve this: #93 https://github.com/reinterpretcat/utymap/issues/93

-- allow buildings foundations to run below grade Also would be nice to have some details here as well :) BTW, I have elevation support via SRTM already in place (mostly inherited from first iteration of this project called ActionStreetMap), but have not decided how to fix problem with elevation differences for buildings part (e.g one corner of the building is on 37 meters above sea, another - 40 meters).

I cannot get UtyMap.Shared to link correctly in VS 2015 x64 I don't use any specific options. Here described how I used to build the project from scratch with VS2013 x64: https://github.com/reinterpretcat/utymap/wiki/Install-on-Windows My guess there is the problem with zlib/protobuf dependencies. Can you post your link error here? I'm curious what is the problem.

There is second way with "cheating." which I'm using to build library on android to avoid building dependencies for armeabi-v7a architecture (I spent couple of hours and failed, so decided to do it later). The main idea is to remove all dependencies to protobuf/zlib in code. These libs are used only to parse osm pbf files. Boost is not needed to be built: I limited myself from excess usage of Boost: header-only functionality is allowed for production code (but you need to build it for unit tests). Here you can see steps needed to remove dependent code: https://github.com/reinterpretcat/utymap/wiki/Install-on-Android

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reinterpretcat/utymap/issues/100#issuecomment-252412628, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqR987Dfijm1MENOMtoycWt4oBVXumiks5qx1odgaJpZM4KRlsG .


Bruce Chase 413 Inglewood Drive Westerville, OH 43081

(614) 638-8094 (cell) (614) 890-0006 (home)

reinterpretcat commented 7 years ago

Hi Bruce! Unfortunately I cannot see images: there is something like [image: Inline image 3] instead. I think you can upload them directly in message on github or on some image hosting.

Maybe I have to move back to an older version of ProtoBuf.

I guess the problem is how protobuf was built and/or referenced. Quick googling showed this link: http://stackoverflow.com/questions/13733604/visual-studio-2010-c-w-google-protocol-buffers-cannot-find-60-externals-can

And I want to be able to ride anyplace in the world (like the mountains in Switzerland!).

I like your idea :) however, it is not easy to implement if you want to get realistic picture. I would say it is not even possible if you don't have access to 3D images and tools to process them. That's why I decided to use flat shading style where you can have some kind of simplified world rendered from vector data. It has some benefits against raster tile data: you always now what is there. This is quite important when you want to interact with objects in scene (e,g, modify mesh).

BTW, have you seen this game: https://www.youtube.com/watch?v=fPk3gxVWV_I https://play.google.com/store/apps/details?id=com.withgoogle.verne Looks really interesting for exploring world.

In order to speed-up the FPS in Unity, then there would have to be quite different detail level.

Yes, utymap already supports different zoom levels: you can see itin demo. Dynamic switching between them - it is separate task. I have plans to work on it in the future.

Thanks, Ilya

reinterpretcat commented 7 years ago

Closed as answered