diff --git a/src/com/blarg/gdx/graphics/GraphicsHelpers.java b/src/com/blarg/gdx/graphics/GraphicsHelpers.java index b37fd62..5de1f28 100644 --- a/src/com/blarg/gdx/graphics/GraphicsHelpers.java +++ b/src/com/blarg/gdx/graphics/GraphicsHelpers.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; public final class GraphicsHelpers { @@ -49,6 +50,19 @@ public final class GraphicsHelpers { shapeRenderer.end(); } + public static void renderGridPlane(ShapeRenderer shapeRenderer, int width, int depth, Matrix4 transform) { + shapeRenderer.begin(ShapeRenderer.ShapeType.Line); + shapeRenderer.setTransformMatrix(transform); + shapeRenderer.setColor(Color.WHITE); + + for (int i = 0; i <= width; ++i) + shapeRenderer.line((float)i, 0.0f, 0.0f, (float)i, 0.0f, (float)depth); + for (int i = 0; i <= depth; ++i) + shapeRenderer.line(0.0f, 0.0f, (float)i, (float)width, 0.0f, (float)i); + + shapeRenderer.end(); + } + /** * Same as {@link Texture#draw}, but also allows drawing the source Pixmap object to an unmanaged Texture object. * Note that doing so will mean that the original texture image data will be restored if the OpenGL context is