GridCreator - playmyskay/playmyskay-libgdx-tools GitHub Wiki
Common
Source
Description
This helper class is able to construct visible grids on all planes (xy, xz, yz) (i.e. for debugging purposes). The grids can be customized by color, size and position. The current implementation returns an object of type ModelInstance which could be rendered by an object of type ModelBatch.
Recommendations
Render with depthFunc = GL_FALSE otherwise the grid lines could be conflict with other vertices (i.e. lines). Furthermore you should render the grids before rendering the entire world.
Usage examples
Simple usage examples:
xy plane:
GridCreator.create().gridXY(50f).finish()
xz plane:
GridCreator.create().gridXZ(50f).finish()
yz plane:
GridCreator.create().gridYZ(50f).finish()
all planes:
GridCreator.create().grid(50f).finish()
Changing color and position per grid:
GridCreator.create().color(1f, 0f, 0f, 1f).gridYZ(50f).color(0f, 1f, 0f, 1f).pos(0f, 10f, 0f).gridXZ(50f).finish()
This would lead to a yz grid grid (red colored) and to a xz grid at 10f on y axis (blue colored).
Usage example with hard invocation:
GridCreator.create().color(0f, 1f, 0f, 1f).gridXY(100f).color(1f, 0, 0, 1f).gridXZ(100f) .pos(40f, 0, 0).color(0f, 0f, 1f, 1f).gridYZ(40f).finish();