Bugfix: issue #635 (center WireBox on BoundingBox) in trunk

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11088 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
sgold 11 years ago
parent df66664f98
commit 33487ad8cb
  1. 23
      engine/src/core/com/jme3/scene/debug/WireBox.java

@ -32,6 +32,8 @@
package com.jme3.scene.debug; package com.jme3.scene.debug;
import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingBox;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Format;
@ -100,8 +102,23 @@ public class WireBox extends Mesh {
updateBound(); 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;
} }
} }
Loading…
Cancel
Save