Clarification wanted for TerrainQuad

In re: com.jme3.terrain.geomipmap.TerrainQuad’s constructor:

TerrainQuad(java.lang.String name, int patchSize, int totalSize, float[] heightMap)



…What are the default dimensions of the entire Quad in coordinate space? (space != in terrain cells)



Does patchSize pertain to the square-side-length of each cell in texels, the real-world cell-size in coordinate space, (and if it is for coordinate space, why is it ‘int’ rather than ‘float’?) or is this something else completely?



Similar questions with totalSize: Is this describing the side-square-length of the grid, the real-world side-dimension of the grid in space, or something else?



If anything, do these figures affect the default dimensions of the Quad in coordinate space?



How are height values scaled by default?



Thanks for reading.

TerrainQuad uses world units (WU). So, no units; or the units are up to you. By default each vertex is 1WU away from its neighbour. Int coordinate (object) space this is 1 unit.

PatchSize is the size of one side of a single tile of the terrain. So if it is 33, then each tile will be 33x33 height points. TerrainQuad is made up of many tiles (TerrainPatches). The larger the patches, the fewer tiles you will have. But it will not change the total dimensions of the terrain.

A TerrainQuad that is 513x513 will be 513WU wide and 513WU long (ie. in coordinate space).



You can scale height values before you give them to the TerrainQuad or you can just call terrainQuad.setLocalScale(1, myScale, 1) to scale it after (which is more flexible).

cjritola said:
In re: com.jme3.terrain.geomipmap.TerrainQuad's constructor:
TerrainQuad(java.lang.String name, int patchSize, int totalSize, float[] heightMap)

...What are the default dimensions of the entire Quad in coordinate space? (space != in terrain cells)


You mean world-space? The default scale is [1,1,1], so each vertex in the grid gets scaled by that.


Does patchSize pertain to the square-side-length of each cell in texels, the real-world cell-size in coordinate space, (and if it is for coordinate space, why is it 'int' rather than 'float'?) or is this something else completely?


It is square-side-length of each cell, or subdivision of the TerrainQuad.


Similar questions with totalSize: Is this describing the side-square-length of the grid, the real-world side-dimension of the grid in space, or something else?


The side-square-length of the grid.

I agree that the JavaDoc can be very much improved (I have found most things out by going through the source) but you can always just try and see what happens. The scene-composer can manipulate terrain. There are also examples in the tutorial that you can make an application from and play with.

EDIT: Doh, sploreg beat me to it and with better answer also :)

Yea I will add some more to the javadocs. It’s all covered in the documentation, but that isn’t as directly accessible as in javadoc.

Thanks for the fast replies; to verify that I understand correctly I will try to summarize:


  • * Default side-length of entire TerrainQuad in world units (WUs) is the same as the value passed to totalSize. ex: TerrainQuad where totalSize=257, the TerrainQuad as a whole will be 256x256 WUs in size.


  • * texture-tile-grid resolution and height-tile-grid resolution are partially independent of each other such that multiple height-tiles can be contained within a single texture-tile.


  • * patchSize is the side-length resolution ratio between the texture-tile-grid and the height-tile-grid such that:

    (pseudocode)
    patchSize = heightTileGrid.sideResolution / textureTileGrid.sideResolution
    (/pseudocode).


  • * heightMap [] is rasterized to a 2D height grid using totalSize.


  • * TerrainQuad altitude protrusion in WUs is by default the raw values passed by heightMap[] i.e. height value of 127.0 protrudes by 127.0 WUs.

  • * Default side-length of entire TerrainQuad in world units (WUs) is the same as the value passed to totalSize. ex: TerrainQuad where totalSize=257, the TerrainQuad as a whole will be 256x256 WUs in size.


  • No it will be 257x257 WU in area.


  • * texture-tile-grid resolution and height-tile-grid resolution are partially independent of each other such that multiple height-tiles can be contained within a single texture-tile.


  • * patchSize is the side-length resolution ratio between the texture-tile-grid and the height-tile-grid such that:

  • I'm not sure what you mean by texture-tile-grid. If you mean the splat alpha map, then yes that is independent of the heightmap.
    Patch size is always the size of each little geometry tile that gets created when you make terrain. Each of these tiles has its own LOD and will seam itself to its neighbour.


    (pseudocode)
    patchSize = heightTileGrid.sideResolution / textureTileGrid.sideResolution
    (/pseudocode).

    I'm again not sure what those two tileGrid variables are. The texture coordinates are separate from the heightmap. If you are talking about TerrainGrid, then it acts as another layer on top of TerrainQuad.


  • * heightMap [] is rasterized to a 2D height grid using totalSize.


  • It's not rasterized, its the other way around: it's vectorized from a 2d heightmap. It does have to match totalSize


  • * TerrainQuad altitude protrusion in WUs is by default the raw values passed by heightMap[] i.e. height value of 127.0 protrudes by 127.0 WUs.


  • yes