Simulate google maps with Terrain component

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Simulate google maps with Terrain component

Post by Ezerg » Mon Apr 24, 2017 7:25 pm

Hello everyone!
Need some advice regarding a new game that I'm designing:
- My game will use "real world" textures i.e satellite images provided by services such as Google Maps. This means that my "ground" will consists only of 2D textures (no height maps), so my first approach would be using the Terrain component, build a TerrainGroup and use the satellites images as textures for each grid.

1 - So, my main concern is if using the Terrain component is my best option?

I'll also need that when the camera becomes farther (or closer) to the ground, textures should be replaced by the ones corresponding at that camera height, in the same way as Google Maps app.

2 - Is this possible to achieve using Terrain?

Thanks a lot for sharing your knowledge ! :D
0 x

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Sun Apr 30, 2017 12:35 am

i did'nt quite get what you're trying to do...
if you dont have a height map/data then how do you plan on building the terrain?

but anyway ogre-terrain component is not very good/efficient from far view
its more focused on rendering a terrain from close view, taking care of creating/stiching the viewable polygons and calculating occlusion/light/shadow at real time, it also have 8 blend layers( texture/normal maps ) that can be mixed
changing blend maps at real-time is a bit slow and tricky, afaik terrain/camera-LOD is for polygons and not for textures
ogre-terrain is very general purpose and actually there are about at least 5 other terrain plugins( from the community )
e.g: https://bitbucket.org/ogreaddons/scape

i'm sure the web is filled with samples for whatever it is your'e trying to achieve that can be ported to ogre
i think you'll have better results by just implementing your own custom shader/stuff
btw...you can still use the paging component its indiependent of the terrain component
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Re: Simulate google maps with Terrain component

Post by Ezerg » Wed May 03, 2017 3:02 pm

Thanks frostbyte for replying!
What I'm trying to do is a map visualizer (almost like Google Earth), currently I have lots of 256X256 jpeg files for texturing the Terrain tiles, so mi prior intention is using several "Terrain group" and load the textures into each Terrain.
My concern is if the Terrain Component is an over-kill for my app and if another (simpler) approach exists to achieve this, since I'm a noob in Ogre I can't figure out another method than using the Terrain Component.

Hope it's a little bit clearer now
0 x

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Thu May 04, 2017 9:31 am

sorry but i have not knowledge of using google earth geo-spatial data if thats what you mean...
but from what i understand* and the poor description you gave than "over-kill" is a gentle way to describe using ogres terrain component to present jpeg textures , afaik it also doesn't support texture-lods

you may want to check out the PAGED-GEOMETRY plugin
it has texture-lods and paging, my guess is that with some effort( of learning how the plugin works ) you can probably achieve what you need with good performance
https://bitbucket.org/ogreaddons/pagedgeometry
http://www.ogre3d.org/addonforums/viewf ... e0dedf1019
you can also check out clipmap terrain which looks interesting( reminder: i'm clueless on what you want to achieve )
http://hhoppe.com/proj/geomclipmap/
https://bitbucket.org/ogreaddons/clipmapterrain

beside that a project that jumped to my mind is nasa's WorldWIND
https://en.wikipedia.org/wiki/NASA_World_Wind
you can try to check what they are doing underhood since its open-source
maybe there's a half finished ogre-clone somewhere, it may be worth investigating...

*as i understand you only need a bird-view 90degrees down to your so called "terrain"( its not called terrain in terms of 3d graphics engines unless it contains at least a height field or the need to render it in 3d... )
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Re: Simulate google maps with Terrain component

Post by Ezerg » Sat May 06, 2017 2:55 am

I've made some progress using the Terrain component, maybe a screenshoot of what I have so far will clarify my idea and what I'm trying to achieve
I've setted up a simple Terrain group of size 16x16, as textures I've used tiles retrieved from Google Maps (via google´s api) which are 256x256px. Textures are somehow not aligned correctly and I think that's why the grid can be seen,
The game I'm developing is a kind of a car racing game, and my ground should be textured using real world data (maybe I'll add height data to get a proper terrain, but for now I'm ok with a flat one).
What I still have some big doubts is how to implement an efficient tilling engine that goes easy on system resources, I don't want to keep adding a large amount of tiles as the vehicle goes accross them, this is was what I refered in a previous post as "similar engine as google maps" which I believe the amount of tiles that are shown on screen are fixed (the necessary amount to fill the viewport)?.

How can I make this to work efficiently?

Thanks again!
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 1

Re: Simulate google maps with Terrain component

Post by syedhs » Sat May 06, 2017 7:37 am

Ezerg wrote:Hello everyone!
1 - So, my main concern is if using the Terrain component is my best option?
As there is no need of heightmap, and therefore the terrain will be flat then just use set of planes placed adjacent to each other as I think it will be far more efficient this way. However, you may have to do custom grid-management where you only show the nearest grid to camera and hide the grids which are out of view. This will always get updated every time you move the camera. You also need to make sure the texture get properly unloaded/loaded from GPU accordingly (Ogre doesnt do this for you automatically).
I'll also need that when the camera becomes farther (or closer) to the ground, textures should be replaced by the ones corresponding at that camera height, in the same way as Google Maps app.
Perhaps the simplest solution is to simply use material with diffuse only textures that get texture-lod adjusted automatically according to distance?
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Re: Simulate google maps with Terrain component

Post by Ezerg » Sun May 07, 2017 3:00 am

Hi syedhs,
As there is no need of heightmap, and therefore the terrain will be flat then just use set of planes placed adjacent to each other as think it will be far more efficient this way. However, you may have to do custom grid-management where you only show the nearest grid to camera and hide the grids which are out of view. This will always get updated every time you move the camera. You also need to make sure the texture get properly unloaded/loaded from GPU accordingly (Ogre doesnt do this for you automatically).
Ok, that's seems to be the right thing to do, but let's suppose that I stick with the Terrain Component and let's say that mi Terrain Group will have 9 individual terrain (each one with a 256x256 image as layer texture), how can I manage my terrain group to behave exactly like this :
Image

I know that it looks trivial but I cannot think in a way to correctly achieve this :(

thanks again
0 x

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Sun May 07, 2017 8:36 am

but let's suppose that I stick with the Terrain Component
i rather not :wink: ...from what you describe Paged-geometry plugin is perfect for you, you just need to master it...

you might be mislead by Paged-geometry examples to think it is only used for grass and forest rendering but...
Paged-geometry can page-in-out massive amount of your entitys/"tiles" with lots of user control and very fast( also from drive )
Paged-geometry also allows you to use billboard imposters( flat quads ) with camera distance based texture LOD support
so here you have in Paged-geometry both requirments:
1)paging large amount of tiles and
2)flat textures( jpeg-tiles from google ) with camera based texture LOD support

ok now...actually i came here to offer another terrain solution( more of a hack... )
since WorldWind is open sourcehttps://worldwindcentral.com/wiki/index.php?title=NOSA
and renders to openGL/DirectX you can just use it and let it render into ogre-window or maybe even an ogre-scene
http://www.ogre3d.org/tikiwiki/tiki-ind ... stem+Calls

but if you still insist of using ogres-terrain than ogitor's source code is the best place to learn( copy/paste :wink: ) about ogres paged terrain component and also about paged-geometry plugin( although ogitor focus on using it for grass rendering )
Ogitor main branch: https://bitbucket.org/ogitor/ogitor
and this fork maintained by ogre team-member paroj: https://github.com/OGRECave/ogitor
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 1

Re: Simulate google maps with Terrain component

Post by syedhs » Sun May 07, 2017 1:41 pm

If you are sure there is no heightmap involved, then why are you still trying to use terrain and its corresponding tiles - it is just more complicated with possible fps drop (unnecessary overhead).

The grid image you mentioned is exactly what I have done with my own setup - it is far simpler this way, and the only tricky thing (which I had mentioned in the previous post) is to properly unload entities/planes as you move as Ogre doesn't unload resources in obvious way. Otherwise you will keep loading objects and will soon hit memory full error message.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Re: Simulate google maps with Terrain component

Post by Ezerg » Mon May 08, 2017 2:05 am

Thanks everyone for answering!

@frostbyte: I've had some issues using paged geometry a few days back (mem alloc errors when instantiating it), I'll give it another try. I really liked your "hack" idea but it seems a little bit too complicated, that made me think if I just could embed a Qt qml window inside Ogre that implements the QTLocation module (that works exactly as I want) and use that as my "floor/terrain" it would be a total win.

@syedhs: To build that kind of grid did you use ManualObject? If you don't mind could you share a snippet of your implementation?

:D
0 x

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Mon May 08, 2017 5:46 pm

I've had some issues using paged geometry a few days back (mem alloc errors when instantiating it)
funny, iv'e never had any issue with Paged-geometry, i'm using an older 1.10 version( pre-paroj's refactor ) but afaik it not broken, maybe you have some compiler issue, try to keep the same matching compiler flags for all of your ogre related projects/libs/plugins
i've compiled my version by compiling ogitor...
Ogitor's cmake script automatically download and build the Paged-geometry plugin( along with several other plugins )
and having a working Ogitor can help you validate that Paged-geometry is working properly...
its also useful for learning on how to use, me recommend- build a working Ogitor
I really liked your "hack" idea but it seems a little bit too complicated, that made me think if I just could embed a Qt qml window inside Ogre that implements the QTLocation module (that works exactly as I want) and use that as my "floor/terrain" it would be a total win.
i dont know how you got qt involved in all of this and i'm no qt expert( i hate it ) but i would say the safest easiest and painfree path to do this is, is make worldWind render to texture and then convert/copy it to OgreTexture
anyway for qt you have qmlOgre and cuTexture plugins http://www.ogre3d.org/forums/viewtopic.php?f=4&t=61406

found some other google-earth alternatives- some of them are based on OSG( openSceneGraph ), you may consider switching to OSG if you are looking for a deep integration with the terrain app, but anyhow the render-native-calls or otherEngineRenderTargetTexture-->OgreTexture hacks are still valid in case you just need to use the rendered output ...
http://blog.sourcepole.ch/assets/2010/9 ... globes.pdf
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

Ezerg
Gnoblar
Posts: 11
Joined: Wed Oct 26, 2016 4:14 pm
x 1

Re: Simulate google maps with Terrain component

Post by Ezerg » Wed May 10, 2017 3:16 pm

Ok, based on your comments my options are:
1) Don't use terrain component, use a custom mesh for tiles and populate them with the correct textures and combine it with Paged Geometry.
2) Use an external app such as Nasa's World Wind and render it's output to a texture and use that texture as with a mesh(?).

I really liked the terrain component but it seems that it does not support a constant texture update for each tile (or is not intended to), since after updating each terrain's texture a few times, the framebuffer or something else went broken and my screen started to glitch like crazy and all images got totally corrupted.

Anyways, I prefer using option 1, since I believe that this can be achieved in pure Ogre and I'll be far more efficient than running a second app in the background and also I want to learn Ogre :D

So, I've being reading ogitor's code, first thing I tried (copy/pasted) was it's grid definition, that I think is based on this http://www.ogre3d.org/tikiwiki/tiki-ind ... rid+System,
Could I use this grid to define my tiles?
Since the grid i's a manual object, can I set a texture to each different tile?
How should I manage the grid when zoom changes?

thanks again
0 x

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Thu May 11, 2017 8:05 am

1) Don't use terrain component, use a custom mesh for tiles and populate them with the correct textures and combine it with Paged Geometry.
yes, this is what i would do if i did'nt have much Ogre skills and wanted to avoid writing a custom solution...
but now that i think of it, i'm afraid that paged-geometry also does'nt fit your needs...
i did'nt get too deep into paged-geometry code and i don't know how much textures/tiles you have
but i don't think that paged-geometry will load/unload textures from memory for you
you might run into memory/performance issues if you want to load a large amount of textures
http://www.ogre3d.org/forums/viewtopic.php?f=1&t=36346,
in which case you'll need to adapt paged-geometry to your needs...
you can search for info on resource background loading but i think it can be tricker than it sounds( when to load, how to make loading predictable etc... )
i would also suggest that ogre's implementation of back ground-loading is'nt the best fit for this task
but who knows maybe it will work out ok for your needs...
2) Use an external app such as Nasa's World Wind and render it's output to a texture and use that texture as with a mesh(?).
TBH i've never done it but i can think of many ways to present a background texture( it should be easy... )
you can find all of them on the forum-search bar just by typing "background texture" or something like that

you say that having another heavy app running in the background might be an overkill for your needs...
it really depends on how deep you integrate them...its a bit difficult to avoid the overhead of copying a full-screen texture at 60fps but it is possible by hacking into ogre or other engine texture code( make some sort of shared texture )
anyway building an ogre-google-earth sounds like a task i would want to avoid
the pros already did all the hard work and probably optimized it to death( worldWind exist 14 years and OSG is as fast or faster than Ogre1.x )
just consider that they probably generate the tiles on the fly so they don't need to load/unload textures
i'm not sure how time consuming this is, but it still sounds much better than hitting memory barriers created by using/loading texture tiles from disk( texture reading and decoding is a very expensive and memory consuming task )
So, I've being reading ogitor's code, first thing I tried (copy/pasted) was it's grid definition, that I think is based on this http://www.ogre3d.org/tikiwiki/tiki-ind ... rid+System,
Could I use this grid to define my tiles?
no, its just a grid-shape for debug purpose, ogitor use it to show the plane+axis of the object you manipulate( rotate, move )

option3: build your own super-optimized custom solution using Ogre and with knowledge from open-source projects...
please consider that i know nothing of your programming back-ground, skills, motivation, available time etc
this can be very tricky...what you want to achieve may be not so simple after all...
http://www.ogre3d.org/forums/viewtopic.php?t=46248
http://www.ogre3d.org/forums/viewtopic.php?f=13&t=56334

edit: check this library: http://www.gdal.org looks like everybody are using this
someone did ogre-integration but never released the code..http://www.ogre3d.org/forums/viewtopic. ... highlight=

sorry, their seems to be no easy solution for ogre on this topic so i guess its back to square one... :roll:
good-luck...
Last edited by frostbyte on Thu May 11, 2017 10:32 pm, edited 2 times in total.
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 1

Re: Simulate google maps with Terrain component

Post by syedhs » Thu May 11, 2017 2:30 pm

My situation is not exactly the same as yours but the concept is very similar.. you page in/out when the objects are near/far respectively. And in your case, this can lots of ManualObjects or Planes which are placed next to each other. And you can keep checking which objects are far/near every 1 second or so - it is really that simple.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Sun May 14, 2017 8:31 am

damm, i wrote such a long post...got wiped...i'll make this one short...
thought about it a bit, ogre1.x is not up to the task but ogre 2.1 is/will be soon
two ways of having a "almost like google-earth" terrain...
1)paging textured tiles( taken from satellite services )
this is simply undoable using ogre1.x...as someone said in the forum sarcastically...don't remember but it was funny...never mind...just don't bother, ogre1.x texture and resource loading design are simply not up to this task
but ogre2.1 is going through a complete texture component refactoring that will make it suitable for textures paging
http://www.ogre3d.org/forums/viewtopic.php?f=25&t=89127

2)use gdal and ogres terrain component to present the height data produces by gdal( ogre-earth )
this can probably be acheived using ogre1.x paged-terrain component as shown in the forum, but i think it will be a bit cumbersome
ogre1.x terrain component slowly pre-generate the terrain mesh from height-data on the cpu( but you can save it to disk in an optimized format for later use ) and then render it using shaders while using ogres paging component to overcome the high geometry data footprint ( loading/unloading terrain chunks )
ogre2.1 while not having a terrain-component does have a little sample called "terra"
"terra" renders the terrain directly from heightmap all inside the gpu very fast( few millisecs ) and in real-time
meaning that if you change the heightmap texture then the rendered terrain will automatically adjust accordingly and with no perfromance-cost at all
beside of the much better-performance and memory foot print you'll get from terra( no terrain mesh data created )
i thinks it should be an easy integration with gdal - as you'll just need get from gdal the height-map at location(x,y) and copy it to "terra"s heightmap texture
for more info check the ogre2.0 subforum

as i said i have no prior knowledge of gdal or geo-spatial data and how to produce them so take my advices with a grain of...
hope to maybe see someday gdal-ogre intergartion plugin released on the forum :wink:
anyway, thanks for making me learn a bit about geo-spatail something...time to get back to my buis :D
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 14

Re: Simulate google maps with Terrain component

Post by frostbyte » Tue Feb 27, 2018 2:00 am

just reviving this this topic, i needed a clouser... :P
https://github.com/cfmmoc/cfmmoc
0 x
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos

Post Reply