add debug helper method for rendering wireframe grid planes

This commit is contained in:
Gered 2013-10-14 16:15:55 -04:00
parent 38313529b4
commit 6dbd0fcce1

View file

@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
public final class GraphicsHelpers { public final class GraphicsHelpers {
@ -49,6 +50,19 @@ public final class GraphicsHelpers {
shapeRenderer.end(); 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. * 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 * Note that doing so will mean that the original texture image data will be restored if the OpenGL context is