Java Code Examples for com.jme3.bounding.BoundingBox#mergeLocal()
The following examples show how to use
com.jme3.bounding.BoundingBox#mergeLocal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShadowUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Compute bounds of a geomList * @param list * @param transform * @return a new instance */ 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; }
Example 2
Source File: ShadowUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Compute bounds of a geomList * @param list * @param mat * @return a new instance */ 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; }
Example 3
Source File: ShadowUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Computes the bounds of multiple bounding volumes * * @param bv * @return a new instance */ public static BoundingBox computeUnionBound(List<BoundingVolume> bv) { BoundingBox bbox = new BoundingBox(); for (int i = 0; i < bv.size(); i++) { BoundingVolume vol = bv.get(i); bbox.mergeLocal(vol); } return bbox; }
Example 4
Source File: ShadowUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Compute bounds of a geomList * @param list * @param transform * @return */ public static BoundingBox computeUnionBound(GeometryList list, Transform transform) { BoundingBox bbox = new BoundingBox(); for (int i = 0; i < list.size(); i++) { BoundingVolume vol = list.get(i).getWorldBound(); BoundingVolume newVol = vol.transform(transform); //Nehon : prevent NaN and infinity values to screw the final bounding box if (newVol.getCenter().x != Float.NaN && newVol.getCenter().x != Float.POSITIVE_INFINITY && newVol.getCenter().x != Float.NEGATIVE_INFINITY) { bbox.mergeLocal(newVol); } } return bbox; }
Example 5
Source File: ShadowUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Compute bounds of a geomList * @param list * @param mat * @return */ public static BoundingBox computeUnionBound(GeometryList list, Matrix4f mat) { BoundingBox bbox = new BoundingBox(); BoundingVolume store = null; for (int i = 0; i < list.size(); i++) { BoundingVolume vol = list.get(i).getWorldBound(); store = vol.clone().transform(mat, null); //Nehon : prevent NaN and infinity values to screw the final bounding box if (store.getCenter().x != Float.NaN && store.getCenter().x != Float.POSITIVE_INFINITY && store.getCenter().x != Float.NEGATIVE_INFINITY) { bbox.mergeLocal(store); } } return bbox; }
Example 6
Source File: ShadowUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Computes the bounds of multiple bounding volumes * @param bv * @return */ public static BoundingBox computeUnionBound(List<BoundingVolume> bv) { BoundingBox bbox = new BoundingBox(); for (int i = 0; i < bv.size(); i++) { BoundingVolume vol = bv.get(i); bbox.mergeLocal(vol); } return bbox; }
Example 7
Source File: Octree.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public Octree(Spatial scene, int minTrisPerNode){ scene.updateGeometricState(); List<Geometry> geomsList = getGeometries(scene); geoms = new Geometry[geomsList.size()]; geomsList.toArray(geoms); // generate bound box for all geom bbox = new BoundingBox(); for (Geometry geom : geoms){ BoundingVolume bv = geom.getWorldBound(); bbox.mergeLocal(bv); } // set largest extent float extent = Math.max(bbox.getXExtent(), Math.max(bbox.getYExtent(), bbox.getZExtent())); bbox.setXExtent(extent); bbox.setYExtent(extent); bbox.setZExtent(extent); this.minTrisPerNode = minTrisPerNode; Triangle t = new Triangle(); for (int g = 0; g < geoms.length; g++){ Mesh m = geoms[g].getMesh(); for (int i = 0; i < m.getTriangleCount(); i++){ m.getTriangle(i, t); OCTTriangle ot = new OCTTriangle(t.get1(), t.get2(), t.get3(), i, g); allTris.add(ot); // convert triangle to world space // geom.getWorldTransform().transformVector(t.get1(), t.get1()); // geom.getWorldTransform().transformVector(t.get2(), t.get2()); // geom.getWorldTransform().transformVector(t.get3(), t.get3()); } } }