use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.
the class BIHTree method collideWithBoundingVolume.
private int collideWithBoundingVolume(BoundingVolume bv, Matrix4f worldMatrix, CollisionResults results) {
BoundingBox bbox;
if (bv instanceof BoundingSphere) {
BoundingSphere sphere = (BoundingSphere) bv;
bbox = new BoundingBox(bv.getCenter().clone(), sphere.getRadius(), sphere.getRadius(), sphere.getRadius());
} else if (bv instanceof BoundingBox) {
bbox = new BoundingBox((BoundingBox) bv);
} else {
throw new UnsupportedCollisionException("BoundingVolume:" + bv);
}
bbox.transform(worldMatrix.invert(), bbox);
return root.intersectWhere(bv, bbox, worldMatrix, this, results);
}
use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeUnionBound.
/**
* Compute bounds of a geomList
* @param list
* @param mat
* @return
*/
public static BoundingBox computeUnionBound(GeometryList list, Matrix4f mat) {
BoundingBox bbox = new BoundingBox();
TempVars tempv = TempVars.get();
for (int i = 0; i < list.size(); i++) {
BoundingVolume vol = list.get(i).getWorldBound();
BoundingVolume store = vol.transform(mat, tempv.bbox);
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(store.getCenter().x) && !Float.isInfinite(store.getCenter().x)) {
bbox.mergeLocal(store);
}
}
tempv.release();
return bbox;
}
use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeUnionBound.
/**
* Compute bounds of a geomList
* @param list
* @param transform
* @return
*/
public static BoundingBox computeUnionBound(GeometryList list, Transform transform) {
BoundingBox bbox = new BoundingBox();
TempVars tempv = TempVars.get();
for (int i = 0; i < list.size(); i++) {
BoundingVolume vol = list.get(i).getWorldBound();
BoundingVolume newVol = vol.transform(transform, tempv.bbox);
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(newVol.getCenter().x) && !Float.isInfinite(newVol.getCenter().x)) {
bbox.mergeLocal(newVol);
}
}
tempv.release();
return bbox;
}
Aggregations