Package com.jme3.bounding

Examples of com.jme3.bounding.BoundingBox


      bar.setQueueBucket(Bucket.Transparent);
        bar.setShadowMode(ShadowMode.Off);
        bar.setLocalTranslation(-0.5f, 0f, 0f);
      n.attachChild(bar);
        if(vis.getWorldBound() instanceof BoundingBox){
          BoundingBox bbox = (BoundingBox)vis.getWorldBound();
          n.setLocalTranslation(0f, bbox.getYExtent()+0.6f, 0f);
          logger.finest("Healthbar by BBox @ "+n.getLocalTranslation());
        }
        else if(vis.getWorldBound() instanceof BoundingSphere){
          BoundingSphere bound = (BoundingSphere)vis.getWorldBound();
          n.setLocalTranslation(0f, bound.getRadius()+0.6f, 0f);
View Full Code Here


        this.gridTileLoader = terrainQuadGrid;
        terrainQuadGrid.setPatchSize(this.patchSize);
        terrainQuadGrid.setQuadSize(this.quadSize);
        addControl(new UpdateControl());
       
        fixNormalEdges(new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2));
        addControl(new NormalRecalcControl(this));
    }
View Full Code Here

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

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

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

            min.minLocal(temp);
            max.maxLocal(temp);
        }
        Vector3f center = min.add(max).multLocal(0.5f);
        Vector3f extent = max.subtract(min).multLocal(0.5f);
        return new BoundingBox(center, extent.x, extent.y, extent.z);
    }
View Full Code Here

        }
        vars.release();
        Vector3f center = min.add(max).multLocal(0.5f);
        Vector3f extent = max.subtract(min).multLocal(0.5f);
        //Nehon 08/18/2010 : Added an offset to the extend to avoid banding artifacts when the frustum are aligned
        return new BoundingBox(center, extent.x + 2.0f, extent.y + 2.0f, extent.z + 2.5f);
    }
View Full Code Here

        }

        Matrix4f viewProjMatrix = shadowCam.getViewProjectionMatrix();
        Matrix4f projMatrix = shadowCam.getProjectionMatrix();

        BoundingBox splitBB = computeBoundForPoints(points, viewProjMatrix);

        TempVars vars = TempVars.get();

        Vector3f splitMin = splitBB.getMin(vars.vect1);
        Vector3f splitMax = splitBB.getMax(vars.vect2);

//        splitMin.z = 0;

        // Create the crop matrix.
        float scaleX, scaleY, scaleZ;
View Full Code Here

        }

        // create transform to rotate points to viewspace       
        Matrix4f viewProjMatrix = shadowCam.getViewProjectionMatrix();

        BoundingBox splitBB = computeBoundForPoints(points, viewProjMatrix);

        TempVars vars = TempVars.get();
       
        BoundingBox casterBB = new BoundingBox();
        BoundingBox receiverBB = new BoundingBox();
       
        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));                   
                        casterBB.mergeLocal(occBox);
                        casterCount++;
                    }
                    if (splitOccluders != null) {
                        splitOccluders.add(occluder);
View Full Code Here

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

TOP

Related Classes of com.jme3.bounding.BoundingBox

Copyright © 2018 www.massapicom. 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.