Understanding Ogre Terrain Paging

Problems building or running the engine, queries about how to use features etc.
Post Reply
CrimsonGT
Greenskin
Posts: 120
Joined: Thu Sep 20, 2007 10:13 am

Understanding Ogre Terrain Paging

Post by CrimsonGT »

I have been reading up on Ogre's latest terrain system trying to understand it better. I have working terrain in my little test project, but it was basically just copy pasting and tweaking from various threads and the sample application until it worked. So what I believe to possibly be correct and would like to confirm is...

1) Ogre::Terrain object represents one piece of terrain in the world.
2) Ogre::TerrainGroup object represents a group of these Ogre::Terrain objects. I also read that exceeding 9 or so will be about to limit as far as hardware limitations, so do most people limit each group to a certain amount?
3) Ogre::TerrainPaging is basically a larger container so to say than TerrainGroup, and instead encompasses TerrainGroup objects?
4) Ogre::PageManager is basically in charge of all TerrainPaging objects?

So I think I got most of that correct, and it seems to be a heirarchy. I like to wrap my head around things visually, so as an example, lets consider an MMO where each map is massive (I havent played in years so I will makeup a name). Lets say that the "Shire" map is actually comprised of 4 Ogre::Terrain objects (SW, NW, SE, NE). These would be put into a Ogre::TerrainGroup which for example sake we will call grpShire. So lets pretend theres 3 other maps, also each comprised of 4 Ogre::Terrain objects, etc. Basically the entire game's terrain would be one Ogre::TerrainPaging object?

That is about the best example I can give of the way I am perceiving it at the moment. I am really trying to understand each part better, and while I get ::Terrain and ::TerrainGroup for the most part, Paging has baffled me. I searched the forums, wiki and google for an hour looking for some sort of tutorial/example and found nothing. The sample application is pretty baren as far as this goes.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Understanding Ogre Terrain Paging

Post by stealth977 »

Terrain = a small group of tiles, lets say 256x256

TerrainGroup = a group of Terrains, there is no actual limit of how many terrains it can have, the ~9 Terrains hardware limit means the number of Ogre::Terrains visible/in memory at any time...

TerrainPaging = A wrapper to add/remove predetermined Ogre::Terrains on the fly (so you may have lets say 1000 Ogre::Terrains in a TerrainGroup but only the 9 of them around the player is visible at once)

PagingManager = general purpose paging handler, not limited to terrain but also supplies functions to page other elements in the scene...
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
CrimsonGT
Greenskin
Posts: 120
Joined: Thu Sep 20, 2007 10:13 am

Re: Understanding Ogre Terrain Paging

Post by CrimsonGT »

Thank you! That makes it much more clear. So lets say I have a TestTerrain.dat that I have generated that is 1024x1024. Will the engine split it up into Terrain objects or is there something I need to do to break it up? I haven't seen anything in the headers about breaking it up into pieces, but I was wondering why TerrainGroup was using the filename, not the individual Terrain's, so this makes more sense.

Is there a setting that I am missing that controls how many Terrain's are visible at one time or is this handled by the engine?

Do you know of any samples floating around as far as using TerrainPaging besides the Terrain sample that comes with Ogre? That one seems to include most of what is needed, but doesn't really seem to use it.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Understanding Ogre Terrain Paging

Post by stealth977 »

There is no automatic splitting support in Ogre::Terrain. You have to split your maps yourself.

The number of Ogre::Terrains visible at once depends on:

1 - If you are not using paging, all terrains you add to a group are visible at once
2 - If you are using paging, all terrains in the radius LOADRADIUS will be visible at once (center being the current camera position) also all terrains in the radius HOLDRADIUS will not be unloaded, so the max visible at once will be the ones in the range HOLDRADIUS.

Lets say you have multiple terrain objects all have 2000x2000 WORLDSIZE and you have 900 as LOADRADIUS and 1800 as HOLD RADIUS:
- When you first appear in the scene and if you appear in the middle of a terrain object, only that terrain object will be visible, since there are no other terrain objects in LOADRADIUS range.
- When you start to move, as soon as any other terrain object enters the LOADRADIUS range, it will also be loaded and made visible
- As soon as you are far enough from a terrain object (when it becomes more than HOLDRADIUS away, it will be unloaded)

i hope it helps...
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
CrimsonGT
Greenskin
Posts: 120
Joined: Thu Sep 20, 2007 10:13 am

Re: Understanding Ogre Terrain Paging

Post by CrimsonGT »

Thank you so much. After reading what you said, and reading the entire Terrain thread from Sinbad (again) I have a pretty good comprehension of what is going on now. I managed to get it added and compiled, but do have a couple of questions.

1) I made a new thread about this but you might have some idea. The paging system seems to change the filename and append numbers onto the one I provide for some reason which is causing issues. The thread is here incase you have some thought http://www.ogre3d.org/forums/viewtopic.php?f=2&t=60490

2) In that thread, you can see the errors I get. I am wondering though, if I use setFilenameConvention, it atleast uses the proper filename and just appends 0's to it. If I use mTerrainGroup->defineTerrain(0, 0, filename); to manually lay the terrain's out in a grid, it doesn't seem to recognize it. Is there a different way your supposed to define Terrain when using paging?

3) I am using a scene loader (similar to the dot scene loader) but at the moment I just manually call in what to load. Is there a callback or something when the paging system displays/hides a terrain so I can keep up with what objects to add/remove?

I read a lot of information from you in that official terrain thread so I really appreciate your help.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Understanding Ogre Terrain Paging

Post by stealth977 »

1 and 2 - I guess SFCBias provided the answer for it

Question 3: Its a bit more complicated:

First you can provide your own version of TerrainPaging (just copy/paste/rename the class code), in your own version you can signal your own functions during load/unload of a terrain object

But:
If you are using async loading, the signal will only mean that the terrain object starts to load/unload, it doesnt mean it has completed the process. So if i really need to know when the object is fully loaded and visible, i add the object pointer to a queue after calling LOAD and then in my general loop, i check if the queue has any elements and if so ,i check if the elements are fully loaded and take action according to it (remove from queue when done)


I also know that some people managed to do it by supplying their own PageLoader class (ProceduralPageLoader???) and instead of creating the page in there, they use it to signal page loading...
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
reigys
Gnoblar
Posts: 8
Joined: Sun Nov 14, 2010 4:54 pm

Re: Understanding Ogre Terrain Paging

Post by reigys »

Hi,
I am trying 'Page' in Terrain demo with Ogre1.7.
First, I define four page max or min macro in Terrain.h

Code: Select all

    #define TERRAIN_PAGE_MIN_X -1
    #define TERRAIN_PAGE_MIN_Y -1
    #define TERRAIN_PAGE_MAX_X 1
    #define TERRAIN_PAGE_MAX_Y 1
    
Then compile, run and I get six terrain_XXXXXXXX.dat files.
Then I add #define PAGING in Terrain.h, the Page System runs well.
But, I find the distance I set with loadRadius and holdRadius in createWorldSection() is not the distance actually happens in my program. I mean, for example, when I am far away from a terrain object(when it becomes more than holdRadius away), it will not be unloaded; but when I am far far away, the distance may be five or ten times holdRadius, it starts to unload. And Whatever I change the loadRadius and holdRadius value, it seems not any change. I really don't know why. Any help will be appreciated.
By the way, I am sorry for my poor English. English is not my motherlanguage. :?
Lily
Gnoblar
Posts: 2
Joined: Fri Nov 26, 2010 11:20 am

Re: Understanding Ogre Terrain Paging

Post by Lily »

reigys wrote:Hi,


By the way, I am sorry for my poor English. English is not my motherlanguage. :?
if you are not sure about your expression .you can discribe it in your motherlanguage 就是用汉语. correctly under the English.I've found someone else doing like this.
User avatar
Xplodwild
Goblin
Posts: 231
Joined: Thu Feb 12, 2009 3:49 pm
Location: France
x 13
Contact:

Re: Understanding Ogre Terrain Paging

Post by Xplodwild »

It's because Ogre keeps it loaded for some time, to avoid having to reload it if you go back. It's definately not a problem.

As for Lily, I certainely better understand his English than 就是用汉语. The community of people who understands Chinese (or anything except english in general) is really really small. You'll have better chances by writing it in English.
User avatar
sleo
Gremlin
Posts: 171
Joined: Sun Jun 05, 2011 6:49 am
Location: Vodka Federation
x 18

Re: Understanding Ogre Terrain Paging

Post by sleo »

Good thread! I would actually start from other side

1) Ogre::PagedWorld most big class in the sense of holding metadata, consists of sections (stored in world-data file or maybe .scene?)
2) Ogre::PageManager - the glue between (1) and (3)
3) Ogre::PagedWorldSection or Ogre::TerrainPagedWorldSection consists of pages as defined typedef map< PageID, Page * >::type PageMap; PageMap mPages (stored in .page)
4) Ogre::TerrainGroup is a page! consists of terrain pieces, up to 65536x65536 "terrains", but usually smaller, you need to use defineTerrain() function to define each of these "terrains", actually not only Terrain Groups are paged, Terrain object also paged?
5) Ogre::Terrain as already been said, is a set of tiles with LOD functionality if a camera is too far away, consists of tiles (each terrain piece stored in .dat, filenames are made from prefix + "_" + packIndex(x,y) + "." + suffix)
6) Tile is a quad which has one or more blended with each other's textures and optionally relief shader applied afterwards (if user have ps_2_x capable card and turned this option in graphics options of a game), this procedure is called splatting
Post Reply