Examples of BoundingVolume


Examples of com.jme3.bounding.BoundingVolume

        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()));
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

     */
    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;
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

     * @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;
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

        int casterCount = 0, receiverCount = 0;
       
        for (int i = 0; i < receivers.size(); i++) {
            // convert bounding box to light's viewproj space
            Geometry receiver = receivers.get(i);
            BoundingVolume bv = receiver.getWorldBound();
            BoundingVolume recvBox = bv.transform(viewProjMatrix, vars.bbox);

            if (splitBB.intersects(recvBox)) {
                //Nehon : prevent NaN and infinity values to screw the final bounding box
                if (!Float.isNaN(recvBox.getCenter().x) && !Float.isInfinite(recvBox.getCenter().x)) {
                    receiverBB.mergeLocal(recvBox);
                    receiverCount++;
                }
            }
        }

        for (int i = 0; i < occluders.size(); i++) {
            // convert bounding box to light's viewproj space
            Geometry occluder = occluders.get(i);
            BoundingVolume bv = occluder.getWorldBound();
            BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox);

            boolean intersects = splitBB.intersects(occBox);
            if (!intersects && occBox instanceof BoundingBox) {
                BoundingBox occBB = (BoundingBox) occBox;
                //Kirill 01/10/2011
                // Extend the occluder further into the frustum
                // This fixes shadow dissapearing issues when
                // the caster itself is not in the view camera
                // but its shadow is in the camera
                //      The number is in world units
                occBB.setZExtent(occBB.getZExtent() + 50);
                occBB.setCenter(occBB.getCenter().addLocal(0, 0, 25));
                if (splitBB.intersects(occBB)) {
                    //Nehon : prevent NaN and infinity values to screw the final bounding box
                    if (!Float.isNaN(occBox.getCenter().x) && !Float.isInfinite(occBox.getCenter().x)) {
                        // To prevent extending the depth range too much
                        // We return the bound to its former shape
                        // Before adding it
                        occBB.setZExtent(occBB.getZExtent() - 50);
                        occBB.setCenter(occBB.getCenter().subtractLocal(0, 0, 25));                   
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

        if (other instanceof Ray) {
            Ray ray = (Ray) other;
            return collideWithRay(ray, worldMatrix, worldBound, results);
        } else if (other instanceof BoundingVolume) {
            BoundingVolume bv = (BoundingVolume) other;
            return collideWithBoundingVolume(bv, worldMatrix, results);
        } else {
            throw new UnsupportedCollisionException();
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    public void attachBoundChildren(Node parent) {
        for (int i = 0; i < this.getQuantity(); i++) {
            if (this.getChild(i) instanceof TerrainQuad) {
                ((TerrainQuad) getChild(i)).attachBoundChildren(parent);
            } else if (this.getChild(i) instanceof TerrainPatch) {
                BoundingVolume bv = getChild(i).getWorldBound();
                if (bv instanceof BoundingBox) {
                    attachBoundingBox((BoundingBox)bv, parent);
                }
            }
        }
        BoundingVolume bv = getWorldBound();
        if (bv instanceof BoundingBox) {
            attachBoundingBox((BoundingBox)bv, parent);
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

     *            the mesh
     * @return bounding box of the given mesh
     */
    /* package */static BoundingBox getBoundingBox(Mesh mesh) {
        mesh.updateBound();
        BoundingVolume bv = mesh.getBound();
        if (bv instanceof BoundingBox) {
            return (BoundingBox) bv;
        } else if (bv instanceof BoundingSphere) {
            BoundingSphere bs = (BoundingSphere) bv;
            float r = bs.getRadius();
            return new BoundingBox(bs.getCenter(), r, r, r);
        } else {
            throw new IllegalStateException("Unknown bounding volume type: " + bv.getClass().getName());
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

     *            the mesh
     * @return bounding sphere of the given mesh
     */
    /* package */static BoundingSphere getBoundingSphere(Mesh mesh) {
        mesh.updateBound();
        BoundingVolume bv = mesh.getBound();
        if (bv instanceof BoundingBox) {
            BoundingBox bb = (BoundingBox) bv;
            float r = Math.max(bb.getXExtent(), bb.getYExtent());
            r = Math.max(r, bb.getZExtent());
            return new BoundingSphere(r, bb.getCenter());
        } else if (bv instanceof BoundingSphere) {
            return (BoundingSphere) bv;
        } else {
            throw new IllegalStateException("Unknown bounding volume type: " + bv.getClass().getName());
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    if (s.getWorldBound() == null || s.getName().equalsIgnoreCase("Sky")
        || s.getName().equalsIgnoreCase("PlayerShip"))
      return;

    BoundingVolume bv = s.getWorldBound();
    Node n = new DebugNode(cam, co, bv);
    nodes.put(co, n);
    GlobalObjectStore.<ITimedTaskExecutor>getObject(ITimedTaskExecutor.class).AddTimedCallback(new AddNodeCallback(n, this), 0);
    //this.attachChild(n);
    log.info("Spatial about to be added to debug: " + co);
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

   */
  public static BoundingVolume createBestBoundingVolume(Spatial s)
    {
    try
      {
      BoundingVolume vol = s.getWorldBound();
      BoundingVolume bs = getBoundingSphere(s);
      BoundingVolume bb = getAABoundingBox(s);
     
//      System.out.println("For: " + s);
//      System.out.println("Old: " + vol + " = " + vol.getVolume());
//      System.out.println("Sphere: " + bs + " = " + bs.getVolume());
//      System.out.println("Box: " + bb + " = " + bb.getVolume());
     
      //TODO: List and sort for minimum getVolume();
      if(vol.getVolume() <= bs.getVolume() && vol.getVolume() <= bb.getVolume() && vol.getVolume() > 0)
        return vol;
     
      if(bs.getVolume() < bb.getVolume() && bs.getVolume() > 0)
        {
        s.setModelBound(bs);
        return bs;
        }
      else if(bb.getVolume() > 0)
        {
        s.setModelBound(bb);
        return bb;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.