Terrain Scene Manager verices formula

Problems building or running the engine, queries about how to use features etc.
pin_
Halfling
Posts: 93
Joined: Sun Oct 29, 2006 10:26 am

Terrain Scene Manager verices formula

I need the coordinates for each vertex in the terrain (TSM) for our RTS pathfind. Since there is no way to access TSM vertice data (without editing the Ogre source which isn't an option as we're using Mogre) I am reconstructing that data from the height map. I need some help understanding the formula used to build the terrain mesh though.

terrain.cfg has these default settings:

Code: Select all

``````# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=513

# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=65

# The maximum error allowed when determining which LOD to use
MaxPixelError=3

# The size of a terrain page, in world units
PageWorldX=1500
PageWorldZ=1500
# Maximum height of the terrain
MaxHeight=100
``````
Does this mean that the terrain will have 513 x 513 vertices? (a total of 263169?) and that the distance between two neighboring vertices will be 65?

By this logic the vertices making the terrain corners will have this coordinates:

A (0,Y,0) ..........B(33345,Y,0)
. .
. .
. .
. .
. .
. .
D(0,Y,33345)....C(33345,Y,33345)

Is this correct?

P.S. Please note that I did look in OgreTerrainRenderable.cpp but I'm having a hard time understanding what final value of the vertices would be.

thanks
xavier
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22
You can register a TerrainPageSourceListener that gets called when a page is constructed -- this will give you the height data, and you can reconstruct your mesh data from that plus the paging config information.

It doesn't show up in the online API ref for some reason, but it's in OgreTerrainPageSource.h in the TSM source in ogrenew/plugins/OctreeSceneManager/src.
Do you need help? What have you tried?

Angels can fly because they take themselves lightly.
pin_
Halfling
Posts: 93
Joined: Sun Oct 29, 2006 10:26 am
Thanks xavier. A quick lookup in Mogre (which is what I'm using) didn't show anything, I posted about it in the Mogre forum in the hope it was just my miss. Anyways I'd appreciate if someone would help me understand how Ogre terrain is being built (number of vertices, vertice height, distance between vertices)
beaugard
OGRE Contributor
Posts: 265
Joined: Sun Mar 25, 2007 1:48 pm
x 2
PageSize is the size, in number of vertices (both x and y), of the unit which is loaded from disk (a page). In the TerrainSceneManager this is the whole world.

TileSize is the size (number of verts again) of the renderables. The TerrainSM will read the page and cut it up into tiles. LOD, etc. is performed at the tile level.

Finally, PageWorldX / PageWorldY is the size (in OGREs units) of a page. So in your example, the page would measure 1500 x 1500, one tile would measure (64/512)*1500 == 187.5, and one quad (distance between vertices in x or y) in one tile would measure 1500/512 == 187.5/64 ~ 2.93

ah, yes, and MaxHeight is kindof self explanatory, no? White on the heightmap will mean a height of 100, black 0.
pin_
Halfling
Posts: 93
Joined: Sun Oct 29, 2006 10:26 am
ahh, thanks. At last.
Makes perfect sense by the way.

Once again thank you!