# Class TerrainGrid

java.lang.Object
com.codename1.gaming.level.TerrainGrid

public class TerrainGrid extends Object
A height grid for a 3D `GameLevel`: a `#getCols()` x `#getRows()` array of vertex heights spaced `#getCellSize()` world units apart. It is plain authoring data -- turning it into a renderable mesh is the realizer's job and needs the GPU device, so that happens at runtime, not here.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final float`
  `NO_GROUND`
  Sentinel height meaning "no ground in this cell" (an open hole / sky gap).

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TerrainGrid()`
  `TerrainGrid(int cols, int rows, float cellSize)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getCellSize()`
  `int`
  `getCols()`
  `float`
  `getHeight(int col, int row)`
  `String`
  `getMaterial(int col, int row)`
  The surface material id at a cell (a `MaterialRegistry` id); never null -- an unpainted cell reads as `MaterialRegistry#GRASS`.
  `int`
  `getRows()`
  `float`
  `getWall(int col, int row)`
  Wall height stacked on top of the ground in this cell (0 = none).
  `boolean`
  `hasGround(int col, int row)`
  Whether the given cell has a floor (true) or is an open hole / sky gap (false).
  `float[]`
  `heights()`
  The raw row-major heights array (length `cols * rows`).
  `String[]`
  `materials()`
  The raw row-major surface-material array (length `cols * rows`) of `MaterialRegistry` ids; a `null` entry means the default `MaterialRegistry#GRASS`.
  `TerrainGrid`
  `setCellSize(float cellSize)`
  `TerrainGrid`
  `setGround(int col, int row, boolean present)`
  `TerrainGrid`
  `setHeight(int col, int row, float height)`
  `TerrainGrid`
  `setMaterial(int col, int row, String material)`
  `TerrainGrid`
  `setWall(int col, int row, float height)`
  `float[]`
  `walls()`
  The raw row-major wall-height array (length `cols * rows`); 0 = no wall.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### NO_GROUND

    public static final float NO_GROUND
    Sentinel height meaning "no ground in this cell" (an open hole / sky gap). Lets a level have a partial floor -- e.g. a flight level with only a few ground patches.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TerrainGrid

    public TerrainGrid()

  - ### TerrainGrid

    public TerrainGrid(int cols, int rows, float cellSize)

- ## Method Details

  - ### getCols

    public int getCols()

  - ### getRows

    public int getRows()

  - ### getCellSize

    public float getCellSize()

  - ### setCellSize

    public TerrainGrid setCellSize(float cellSize)

  - ### heights

    public float[] heights()
    The raw row-major heights array (length `cols * rows`).

  - ### walls

    public float[] walls()
    The raw row-major wall-height array (length `cols * rows`); 0 = no wall.

  - ### materials

    public String[] materials()
    The raw row-major surface-material array (length `cols * rows`) of `MaterialRegistry` ids; a `null` entry means the default `MaterialRegistry#GRASS`.

  - ### getMaterial

    public String getMaterial(int col, int row)
    The surface material id at a cell (a `MaterialRegistry` id); never null -- an unpainted cell reads as `MaterialRegistry#GRASS`.

  - ### setMaterial

    public TerrainGrid setMaterial(int col, int row, String material)

  - ### getHeight

    public float getHeight(int col, int row)

  - ### setHeight

    public TerrainGrid setHeight(int col, int row, float height)

  - ### hasGround

    public boolean hasGround(int col, int row)
    Whether the given cell has a floor (true) or is an open hole / sky gap (false).

  - ### setGround

    public TerrainGrid setGround(int col, int row, boolean present)

  - ### getWall

    public float getWall(int col, int row)
    Wall height stacked on top of the ground in this cell (0 = none).

  - ### setWall

    public TerrainGrid setWall(int col, int row, float height)