Class TerrainGrid
java.lang.Object
com.codename1.gaming.level.TerrainGrid
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
FieldsModifier and TypeFieldDescriptionstatic final floatSentinel height meaning "no ground in this cell" (an open hole / sky gap). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatintgetCols()floatgetHeight(int col, int row) getMaterial(int col, int row) The surface material id at a cell (aMaterialRegistryid); never null -- an unpainted cell reads asMaterialRegistry#GRASS.intgetRows()floatgetWall(int col, int row) Wall height stacked on top of the ground in this cell (0 = none).booleanhasGround(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 (lengthcols * rows).String[]The raw row-major surface-material array (lengthcols * rows) ofMaterialRegistryids; anullentry means the defaultMaterialRegistry#GRASS.setCellSize(float cellSize) setGround(int col, int row, boolean present) setHeight(int col, int row, float height) setMaterial(int col, int row, String material) setWall(int col, int row, float height) float[]walls()The raw row-major wall-height array (lengthcols * rows); 0 = no wall.
-
Field Details
-
NO_GROUND
public static final float NO_GROUNDSentinel 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:
-
-
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
-
heights
public float[] heights()The raw row-major heights array (lengthcols * rows). -
walls
public float[] walls()The raw row-major wall-height array (lengthcols * rows); 0 = no wall. -
materials
The raw row-major surface-material array (lengthcols * rows) ofMaterialRegistryids; anullentry means the defaultMaterialRegistry#GRASS. -
getMaterial
The surface material id at a cell (aMaterialRegistryid); never null -- an unpainted cell reads asMaterialRegistry#GRASS. -
setMaterial
-
getHeight
public float getHeight(int col, int row) -
setHeight
-
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
-
getWall
public float getWall(int col, int row) Wall height stacked on top of the ground in this cell (0 = none). -
setWall
-