/** * Estimate the screen area of a bounding volume. If the volume isn't a * BoundingSphere, BoundingBox, or OrientedBoundingBox, 0 is returned. * * @param bound The bounds to calculate the volume from. * @param distance The distance from camera to object. * @param screenWidth The width of the screen. * @return The area in pixels on the screen of the bounding volume. */ public static float calcScreenArea(BoundingVolume bound, float distance, float screenWidth) { if (bound.getType() == BoundingVolume.Type.Sphere){ return calcScreenArea((BoundingSphere) bound, distance, screenWidth); }else if (bound.getType() == BoundingVolume.Type.AABB){ return calcScreenArea((BoundingBox) bound, distance, screenWidth); } return 0.0f; }
switch (volume.getType()) { case AABB: BoundingBox vBox = (BoundingBox) volume;
/** * <code>clone</code> creates a new BoundingBox object containing the same * data as this one. * * @param store * where to store the cloned information. if null or wrong class, * a new store is created. * @return the new BoundingBox */ public BoundingVolume clone(BoundingVolume store) { if (store != null && store.getType() == Type.AABB) { BoundingBox rVal = (BoundingBox) store; rVal.center.set(center); rVal.xExtent = xExtent; rVal.yExtent = yExtent; rVal.zExtent = zExtent; rVal.checkPlane = checkPlane; return rVal; } BoundingBox rVal = new BoundingBox(center.clone(), xExtent, yExtent, zExtent); return rVal; }
/** * <code>clone</code> creates a new BoundingSphere object containing the * same data as this one. * * @param store * where to store the cloned information. if null or wrong class, * a new store is created. * @return the new BoundingSphere */ public BoundingVolume clone(BoundingVolume store) { if (store != null && store.getType() == Type.Sphere) { BoundingSphere rVal = (BoundingSphere) store; if (null == rVal.center) { rVal.center = new Vector3f(); } rVal.center.set(center); rVal.radius = radius; rVal.checkPlane = checkPlane; return rVal; } return new BoundingSphere(radius, center.clone()); }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingSphere sphere; if (store == null || store.getType() != BoundingVolume.Type.Sphere) { sphere = new BoundingSphere(1, new Vector3f(0, 0, 0)); } else { sphere = (BoundingSphere) store; } trans.mult(center, sphere.center); Vector3f axes = new Vector3f(1, 1, 1); trans.mult(axes, axes); float ax = getMaxAxis(axes); sphere.radius = FastMath.abs(ax * radius) + RADIUS_EPSILON - 1f; return sphere; }
switch (volume.getType()) {
switch (volume.getType()) {
/** * <code>transform</code> modifies the center of the sphere to reflect the * change made via a rotation, translation and scale. * * @param trans * the transform to apply * @param store * sphere to store result in * @return BoundingVolume * @return ref */ public BoundingVolume transform(Transform trans, BoundingVolume store) { BoundingSphere sphere; if (store == null || store.getType() != BoundingVolume.Type.Sphere) { sphere = new BoundingSphere(1, new Vector3f(0, 0, 0)); } else { sphere = (BoundingSphere) store; } center.mult(trans.getScale(), sphere.center); trans.getRotation().mult(sphere.center, sphere.center); sphere.center.addLocal(trans.getTranslation()); sphere.radius = FastMath.abs(getMaxAxis(trans.getScale()) * radius) + RADIUS_EPSILON - 1f; return sphere; }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else {
/** * Sets the bounds of this LightProbe * Note that for now only BoundingSphere is supported and this method will * throw an UnsupportedOperationException with any other BoundingVolume type * @param bounds the bounds of the LightProbe */ public void setBounds(BoundingVolume bounds) { if( bounds.getType()!= BoundingVolume.Type.Sphere){ throw new UnsupportedOperationException("For not only BoundingSphere are suported for LightProbe"); } this.bounds = bounds; }
/** * Estimate the screen area of a bounding volume. If the volume isn't a * BoundingSphere, BoundingBox, or OrientedBoundingBox, 0 is returned. * * @param bound The bounds to calculate the volume from. * @param distance The distance from camera to object. * @param screenWidth The width of the screen. * @return The area in pixels on the screen of the bounding volume. */ public static float calcScreenArea(BoundingVolume bound, float distance, float screenWidth) { if (bound.getType() == BoundingVolume.Type.Sphere){ return calcScreenArea((BoundingSphere) bound, distance, screenWidth); }else if (bound.getType() == BoundingVolume.Type.AABB){ return calcScreenArea((BoundingBox) bound, distance, screenWidth); } return 0.0f; }
/** * calcScreenArea -- in Pixels * Aproximates the screen area of a bounding volume. If the volume isn't a * BoundingSphere, BoundingBox, or OrientedBoundingBox 0 is returned. * * @param bound The bounds to calculate the volume from. * @param distance The distance from camera to object. * @param screenWidth The width of the screen. * @return The area in pixels on the screen of the bounding volume. */ public static float calcScreenArea(BoundingVolume bound, float distance, float screenWidth) { if (bound.getType() == BoundingVolume.Type.Sphere){ return calcScreenArea((BoundingSphere) bound, distance, screenWidth); }else if (bound.getType() == BoundingVolume.Type.AABB){ return calcScreenArea((BoundingBox) bound, distance, screenWidth); } return 0.0f; }
/** * <code>clone</code> creates a new BoundingBox object containing the same * data as this one. * * @param store * where to store the cloned information. if null or wrong class, * a new store is created. * @return the new BoundingBox */ public BoundingVolume clone(BoundingVolume store) { if (store != null && store.getType() == Type.AABB) { BoundingBox rVal = (BoundingBox) store; rVal.center.set(center); rVal.xExtent = xExtent; rVal.yExtent = yExtent; rVal.zExtent = zExtent; rVal.checkPlane = checkPlane; return rVal; } BoundingBox rVal = new BoundingBox(center.clone(), xExtent, yExtent, zExtent); return rVal; }
/** * <code>clone</code> creates a new BoundingSphere object containing the * same data as this one. * * @param store * where to store the cloned information. if null or wrong class, * a new store is created. * @return the new BoundingSphere */ public BoundingVolume clone(BoundingVolume store) { if (store != null && store.getType() == Type.Sphere) { BoundingSphere rVal = (BoundingSphere) store; if (null == rVal.center) { rVal.center = new Vector3f(); } rVal.center.set(center); rVal.radius = radius; rVal.checkPlane = checkPlane; return rVal; } return new BoundingSphere(radius, center.clone()); }
/** * <code>clone</code> creates a new BoundingSphere object containing the * same data as this one. * * @param store * where to store the cloned information. if null or wrong class, * a new store is created. * @return the new BoundingSphere */ public BoundingVolume clone(BoundingVolume store) { if (store != null && store.getType() == Type.Sphere) { BoundingSphere rVal = (BoundingSphere) store; if (null == rVal.center) { rVal.center = new Vector3f(); } rVal.center.set(center); rVal.radius = radius; rVal.checkPlane = checkPlane; return rVal; } return new BoundingSphere(radius, (center != null ? (Vector3f) center.clone() : null)); }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingSphere sphere; if (store == null || store.getType() != BoundingVolume.Type.Sphere) { sphere = new BoundingSphere(1, new Vector3f(0, 0, 0)); } else { sphere = (BoundingSphere) store; } trans.mult(center, sphere.center); Vector3f axes = new Vector3f(1, 1, 1); trans.mult(axes, axes); float ax = getMaxAxis(axes); sphere.radius = FastMath.abs(ax * radius) + RADIUS_EPSILON - 1f; return sphere; }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingSphere sphere; if (store == null || store.getType() != BoundingVolume.Type.Sphere) { sphere = new BoundingSphere(1, new Vector3f(0, 0, 0)); } else { sphere = (BoundingSphere) store; } trans.mult(center, sphere.center); Vector3f axes = new Vector3f(1, 1, 1); trans.mult(axes, axes); float ax = getMaxAxis(axes); sphere.radius = FastMath.abs(ax * radius) + RADIUS_EPSILON - 1f; return sphere; }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }