From 33487ad8cb3aade1174acfa5efe39349081986f6 Mon Sep 17 00:00:00 2001 From: sgold Date: Sat, 15 Mar 2014 19:12:43 +0000 Subject: [PATCH] Bugfix: issue #635 (center WireBox on BoundingBox) in trunk git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11088 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../core/com/jme3/scene/debug/WireBox.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/engine/src/core/com/jme3/scene/debug/WireBox.java b/engine/src/core/com/jme3/scene/debug/WireBox.java index 7e0daa15c..947d2c0a5 100644 --- a/engine/src/core/com/jme3/scene/debug/WireBox.java +++ b/engine/src/core/com/jme3/scene/debug/WireBox.java @@ -32,6 +32,8 @@ package com.jme3.scene.debug; import com.jme3.bounding.BoundingBox; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Format; @@ -100,8 +102,23 @@ public class WireBox extends Mesh { updateBound(); } - public void fromBoundingBox(BoundingBox bbox){ - updatePositions(bbox.getXExtent(), bbox.getYExtent(), bbox.getZExtent()); + /** + * Create a geometry suitable for visualizing the specified bounding box. + * + * @param bbox the bounding box (not null) + * @return a new Geometry instance in world space + */ + public static Geometry fromBoundingBox(BoundingBox bbox) { + float xExtent = bbox.getXExtent(); + float yExtent = bbox.getYExtent(); + float zExtent = bbox.getZExtent(); + WireBox mesh = new WireBox(xExtent, yExtent, zExtent); + Geometry result = new Geometry("bounding box", mesh); + + Vector3f center = bbox.getCenter(); + result.setLocalTranslation(center); + + return result; } -} +} \ No newline at end of file