very basic questions about terrain

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
marlym014
Gnoblar
Posts: 4
Joined: Wed Mar 21, 2012 7:50 pm

very basic questions about terrain

Post by marlym014 » Wed Mar 28, 2012 11:48 pm

I went through the basic tutorial 3 and the API documentation .. and I tried to modify the code according to my needs but without the desired result because I have a lot of doubts regarding the terrain component

Code: Select all

mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(pSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
. from the code above I've got the following doubts:
third parameter is terrain size in vertex, but I see it match the dimension of the hightmap is it right?
fourth parameter is world size, but which units is this in?

Code: Select all

Ogre::Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
    defaultimp.terrainSize = 513;
    defaultimp.worldSize = 12000.0f;
    defaultimp.inputScale = 600;
    defaultimp.minBatchSize = 33;
    defaultimp.maxBatchSize = 65;
. from the piece of code above...
third parameter is meant to be How to scale the input values provided.... does that mean the scale of my models? how this number is calculated?
what are minBatchSize and maxBatchSize used for?

For each texture layer we'got something like this:

Code: Select all

  defaultimp.layerList[0].worldSize = 100; 
what does the number mean and what is its relation with whe worldsize parameter in the terrain group?
In the tutorial there is the funcion:

Code: Select all

void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
is it necessary to flip the heighmap around the axes?

. I'm doing a driving game so I don´t want my terrain to be squared , so do I need to add terrain pages along z axis... is there a good example about paging that you know?

Some of the questions might make no sense, but I'm pretty new in this subject and I'm really stuck trying to understand. THanks for your help
0 x

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: very basic questions about terrain

Post by bstone » Thu Mar 29, 2012 7:51 am

marlym014 wrote:third parameter is terrain size in vertex, but I see it match the dimension of the hightmap is it right?
TerrainGroup is a bunch of Terrain objects. The size parameter you mentioned is the size of each Terrain object that will be in the group, i.e. not the size of the whole combined terrain.
marlym014 wrote:fourth parameter is world size, but which units is this in?
Whatever you decide them to be. Depends on the size of other objects in your world. That is, if you make a bunny model that is 1000x1000x1000 in size, then your terrain is 12 bunnies in width and height. Good enough for a pit.
marlym014 wrote:third parameter is meant to be How to scale the input values provided.... does that mean the scale of my models? how this number is calculated?
The scale parameter applies to terrain that are using PF_L16 heightmap format. Each pixel is considered as a fixed point value in the range o f [-1..1]. Then the scale is applied so if you have inputScale=600 the highest point on your heightmap will be 600 in your world coordinates plus the origin of the terrain group. If you have a floating point heightmap then that scale parameter is ignored.
marlym014 wrote:what are minBatchSize and maxBatchSize used for?
Mostly for optimization. That value controls how deep each terrain object is sub-divided into square chunks that are rendered as a single render call (i.e. batch). You can safely use the default values for now.
marlym014 wrote:For each texture layer we'got something like this:

Code: Select all

  defaultimp.layerList[0].worldSize = 100; 
what does the number mean and what is its relation with whe worldsize parameter in the terrain group?
It's the size of your texture in the world. worldSize = 100 means that your texture (say 1024x1024) is just 100x100 in your world.
marlym014 wrote:is it necessary to flip the heighmap around the axes?
Depends on how you generate your terrain (i.e. whether the image is top-down or bottom-up, the x axis is usually doesn't require flipping). Ogre uses the right hand coordinate system so you have to account for that.
marlym014 wrote:. I'm doing a driving game so I don´t want my terrain to be squared , so do I need to add terrain pages along z axis... is there a good example about paging that you know?
You have to get the right relationship between what makes a terrain. There are terrain objects (Terrain class) that are square and there is the terrain group (TerrainGroup class) which basically combines the terrain objects into whatever layout you want. E.g. you can have a terrain group which is 1x10 in size (i.e. one long row of terrain objects). That wouldn't look square at all.
0 x

swuth
Bronze Sponsor
Bronze Sponsor
Posts: 53
Joined: Wed Mar 25, 2015 10:01 pm

Re: very basic questions about terrain

Post by swuth » Wed May 13, 2015 8:54 pm

So.... I am converting a game whose maps use a height map PNG. Each Terrain Grid square ( a single cell with a height at each corner) is 100 world units by 100 world units. I am pretty sure that is the number referred to by terrainsize (usually 513) in all the examples. As it seems this value is a power of 2 +1 then it seems I am SOL in having 100 by 100 tiles. It seems a good scheme would be to go with 129 as my terrain size and then adjust the worldsize accordingly to give me effectivley 100x100 worldunit tiles correct?

Thanks in advance!


Swuth
0 x

Post Reply