From 3b717723972b2df8755f8a87bdbde45bbb02511f Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 27 Oct 2013 16:45:58 -0400 Subject: [PATCH] maybe a bit over the top with all these extra overloads? --- .../gdx/graphics/DebugGeometryRenderer.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/com/blarg/gdx/graphics/DebugGeometryRenderer.java b/src/com/blarg/gdx/graphics/DebugGeometryRenderer.java index 15e645f..19429d1 100644 --- a/src/com/blarg/gdx/graphics/DebugGeometryRenderer.java +++ b/src/com/blarg/gdx/graphics/DebugGeometryRenderer.java @@ -24,6 +24,11 @@ public class DebugGeometryRenderer { static final Color COLOR_1 = new Color(Color.YELLOW); static final Color COLOR_2 = new Color(Color.RED); + static final BoundingBox tmpBox = new BoundingBox(); + static final Sphere tmpSphere = new Sphere(Vector3.Zero, 0.0f); + static final Ray tmpRay = new Ray(Vector3.Zero, Vector3.Zero); + static final Segment tmpSegment = new Segment(Vector3.Zero, Vector3.Zero); + final ImmediateModeRenderer renderer; public DebugGeometryRenderer() { @@ -51,6 +56,28 @@ public class DebugGeometryRenderer { renderer.end(); } + public void box(Vector3 min, Vector3 max) { + box(min, max, COLOR_1); + } + + public void box(Vector3 min, Vector3 max, Color color) { + tmpBox.min.set(min); + tmpBox.max.set(max); + box(tmpBox, color); + } + + public void box(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + tmpBox.min.set(minX, minY, minZ); + tmpBox.max.set(maxX, maxY, maxZ); + box(tmpBox, COLOR_1); + } + + public void box(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, Color color) { + tmpBox.min.set(minX, minY, minZ); + tmpBox.max.set(maxX, maxY, maxZ); + box(tmpBox, color); + } + public void box(BoundingBox box) { box(box, COLOR_1); } @@ -100,6 +127,28 @@ public class DebugGeometryRenderer { vtx(box.min.x, box.min.y, box.min.z, color); } + public void sphere(Vector3 center, float radius) { + sphere(center, radius, COLOR_1); + } + + public void sphere(Vector3 center, float radius, Color color) { + tmpSphere.center.set(center); + tmpSphere.radius = radius; + sphere(tmpSphere, color); + } + + public void sphere(float centerX, float centerY, float centerZ, float radius) { + tmpSphere.center.set(centerX, centerY, centerZ); + tmpSphere.radius = radius; + sphere(tmpSphere, COLOR_1); + } + + public void sphere(float centerX, float centerY, float centerZ, float radius, Color color) { + tmpSphere.center.set(centerX, centerY, centerZ); + tmpSphere.radius = radius; + sphere(tmpSphere, color); + } + public void sphere(Sphere sphere) { sphere(sphere, COLOR_1); } @@ -150,6 +199,25 @@ public class DebugGeometryRenderer { } } + public void ray(Vector3 origin, Vector3 direction, float length) { + ray(origin, direction, length, COLOR_1, COLOR_2); + } + + public void ray(Vector3 origin, Vector3 direction, float length, Color originColor, Color endPointColor) { + tmpRay.set(origin, direction); + ray(tmpRay, length, originColor, endPointColor); + } + + public void ray(float originX, float originY, float originZ, float directionX, float directionY, float directionZ, float length) { + tmpRay.set(originX, originY, originZ, directionX, directionY, directionZ); + ray(tmpRay, length, COLOR_1, COLOR_2); + } + + public void ray(float originX, float originY, float originZ, float directionX, float directionY, float directionZ, float length, Color originColor, Color endPointColor) { + tmpRay.set(originX, originY, originZ, directionX, directionY, directionZ); + ray(tmpRay, length, originColor, endPointColor); + } + public void ray(Ray ray, float length) { ray(ray, length, COLOR_1, COLOR_2); } @@ -162,6 +230,28 @@ public class DebugGeometryRenderer { vtx(endPoint, endPointColor); } + public void line(Vector3 a, Vector3 b) { + line(a, b, COLOR_1); + } + + public void line(Vector3 a, Vector3 b, Color color) { + tmpSegment.a.set(a); + tmpSegment.b.set(b); + line(tmpSegment, color); + } + + public void line(float aX, float aY, float aZ, float bX, float bY, float bZ) { + tmpSegment.a.set(aX, aY, aZ); + tmpSegment.b.set(bX, bY, bZ); + line(tmpSegment, COLOR_1); + } + + public void line(float aX, float aY, float aZ, float bX, float bY, float bZ, Color color) { + tmpSegment.a.set(aX, aY, aZ); + tmpSegment.b.set(bX, bY, bZ); + line(tmpSegment, color); + } + public void line(Segment line) { line(line, COLOR_1); }