diff options
author | Harvey Harrison <[email protected]> | 2012-01-23 23:19:32 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-01-23 23:19:32 -0800 |
commit | 812718194fe41db01b25d540b7b179b98b4a24ef (patch) | |
tree | b69c5e7a110c13c7dd45d8bc16c3f36e636d03e7 | |
parent | 2802c9626a24abfb053acc4a45395aa3e8f587db (diff) |
j3dcore: add a getCenter(Point3d) to the Bounds interface and implement it in the implementing classes
Signed-off-by: Harvey Harrison <[email protected]>
4 files changed, 27 insertions, 15 deletions
diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java index c0a30b2..b1baee4 100644 --- a/src/classes/share/javax/media/j3d/BoundingBox.java +++ b/src/classes/share/javax/media/j3d/BoundingBox.java @@ -1838,6 +1838,11 @@ private void setInfiniteBounds() { return centroid; } +public void getCenter(Point3d center) { + center.add(lower, upper); + center.scale(0.5d); +} + void translate(BoundingBox bbox, Vector3d value) { if (bbox == null || bbox.boundsIsEmpty) { setEmptyBounds(); diff --git a/src/classes/share/javax/media/j3d/BoundingPolytope.java b/src/classes/share/javax/media/j3d/BoundingPolytope.java index e9e62df..b95eeb3 100644 --- a/src/classes/share/javax/media/j3d/BoundingPolytope.java +++ b/src/classes/share/javax/media/j3d/BoundingPolytope.java @@ -1714,6 +1714,10 @@ public class BoundingPolytope extends Bounds { return centroid; } +public void getCenter(Point3d center) { + center.set(centroid); +} + /** * if the passed the "region" is same type as this object * then do a copy, otherwise clone the Bounds and diff --git a/src/classes/share/javax/media/j3d/BoundingSphere.java b/src/classes/share/javax/media/j3d/BoundingSphere.java index e7bec53..d25424a 100644 --- a/src/classes/share/javax/media/j3d/BoundingSphere.java +++ b/src/classes/share/javax/media/j3d/BoundingSphere.java @@ -272,16 +272,13 @@ public BoundingSphere(Bounds[] boundsObjects) { updateBoundsStates(); } - /** - * Returns the position of this bounding sphere as a point. - * @param center a Point to receive the center of the bounding sphere - - */ - public void getCenter(Point3d center) { - center.x = this.center.x; - center.y = this.center.y; - center.z = this.center.z; - } +/** + * Returns the position of this bounding sphere as a point. + * @param center a Point to receive the center of the bounding sphere + */ +public void getCenter(Point3d center) { + center.set(this.center); +} /** * Sets the position of this bounding sphere from a point. diff --git a/src/classes/share/javax/media/j3d/Bounds.java b/src/classes/share/javax/media/j3d/Bounds.java index 9a0daf6..5759d50 100644 --- a/src/classes/share/javax/media/j3d/Bounds.java +++ b/src/classes/share/javax/media/j3d/Bounds.java @@ -170,11 +170,17 @@ public abstract class Bounds extends Object implements Cloneable { */ public abstract Bounds closestIntersection( Bounds[] boundsObjects); - /** - * Returns the center of the bounds - * @return bounds center - */ - abstract Point3d getCenter(); +/** + * Returns the center of the bounds + * @return bounds center + */ +abstract Point3d getCenter(); + +/** + * Gets the centroid of this bounding region. + * @param center a Point to receive the centroid of the bounding region + */ +public abstract void getCenter(Point3d center); /** * Combines this bounding object with a bounding object so that the |