Examples of BoundingVolume


Examples of com.jme.bounding.BoundingVolume

        // To set the scale properly, we need to compute the scale w.r.t the
        // current size of the object as a ratio of the original size of the
        // object (in case the size of the object has changed).
        currentScale = size;
        float xScale = 0.0f, yScale = 0.0f, zScale = 0.0f;
        BoundingVolume bounds = sceneRoot.getWorldBound();
        if (bounds instanceof BoundingSphere) {
            float newExtent = ((BoundingSphere)bounds).radius;
            xScale = yScale = zScale = (newExtent / extent) * currentScale;
        }
        else if (bounds instanceof BoundingBox) {
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

        super("Resize");

        // Figure out the bounds of the root entity of the cell and create a
        // cube to be just a bit larger than that
        this.sceneRoot = sceneRoot;
        BoundingVolume bounds = sceneRoot.getWorldBound();
        if (bounds instanceof BoundingSphere) {
            radius = ((BoundingSphere)bounds).radius;
        }
        else if (bounds instanceof BoundingBox) {
            float xExtent = ((BoundingBox)bounds).xExtent;
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

        // To set the scale properly, we need to compute the scale w.r.t the
        // current size of the object as a ratio of the original size of the
        // object (in case the size of the object has changed).
        currentScale = size;
        BoundingVolume bounds = sceneRoot.getWorldBound();
        float scale = 0.0f;
        if (bounds instanceof BoundingSphere) {
            float newRadius = ((BoundingSphere)bounds).radius;
            scale = (newRadius / radius) * currentScale;
        }
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

       
    /**
     * Return the bounds of the avatar cell.
     */
    public static BoundingVolume getCellBounds(Vector3f center) {
        BoundingVolume tileBounds = new BoundingBox(center, AVATAR_CELL_SIZE, AVATAR_CELL_SIZE, AVATAR_CELL_SIZE);
        return tileBounds;
       
    }
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

            // the model bounds.
            // Go ahead and load the model. We need to load the model in order to
            // find out its bounds to set the hint.
            ModelLoader loader = dm.getModelLoader();
            Node node = loader.loadDeployedModel(dm, null);
            BoundingVolume bounds = node.getWorldBound();
            hint = getBoundingVolumeHint(bounds);
            posComp.setBounds(bounds);
        } else {
            hint = getBoundingVolumeHint(dm.getModelBounds());
            posComp.setBounds(dm.getModelBounds());
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

    private BoundingVolumeHint getBoundingVolumeHint(BoundingVolume bounds) {
        // If the model is too large, then set the bounds to extent/radius of
        // 1, so that it essentially appears on top of the avatar. This prevents
        // it from being placed too far away. We keep the y value -- so that
        // the model is placed on the ground, and not in it.
        BoundingVolume hint = bounds;
        if (bounds instanceof BoundingBox) {
            // Handle if the bounding volume is a box. We only care about the
            // x and z extents, since we'll always want to place the model on
            // the floor, no matter how high it is.
            BoundingBox box = (BoundingBox) bounds;
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

        if (bg == null) {
            return;
        }

        BoundingVolume bounds = bg.getWorldBound();

        if (bounds == null) {
            bounds = calcBounds(bg);
        }
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

     * Traverse the graph, combining all the world bounds into bv
     * @param n
     * @param bv
     */
    BoundingVolume calcBounds(Spatial n) {
        BoundingVolume bounds = null;

        if (n instanceof Geometry) {
            bounds = new BoundingBox();
            bounds.computeFromPoints(((Geometry) n).getVertexBuffer());

            bounds.transform(
                    n.getLocalRotation(),
                    n.getLocalTranslation(),
                    n.getLocalScale());
        }

        if (n instanceof Node && ((Node) n).getQuantity() > 0) {
            for (Spatial child : ((Node) n).getChildren()) {
                BoundingVolume childB = calcBounds(child);
                if (bounds == null) {
                    bounds = childB;
                } else {
                    bounds.mergeLocal(childB);
                }
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

       
        if (hint != null && hint.isDoSystemPlacement() == true) {
            // Case (1): We have a bounds hint and we want to do the layout,
            // so we find the distance away from the avatar and also the height
            // above the ground.
            BoundingVolume boundsHint = hint.getBoundsHint();
            transform = CellPlacementUtils.getCellTransform(manager, boundsHint,
                    viewTransform);
        }
        else if (hint == null) {
            // Case (2): Do the optimal placement using the default radius.
            BoundingVolume boundsHint = new BoundingSphere(DEFAULT_RADIUS, Vector3f.ZERO);
            transform = CellPlacementUtils.getCellTransform(manager, boundsHint,
                    viewTransform);
        }
        else if (hint != null && hint.isDoSystemPlacement() == false) {
            // Case (3): The Cell will take care of its own placement, use
View Full Code Here

Examples of com.jme.bounding.BoundingVolume

            child.setWorldTransform(childTransform, source);
        } else {
            child.setWorldTransform(parentWorldTransform, source);
        }

        BoundingVolume ret = child.getWorldBounds();

        Iterator<Cell> it = child.getChildren().iterator();
        while (it.hasNext()) {
            ret.mergeLocal(transformTreeUpdate(child, it.next(), source));
        }

        child.setWorldBounds(ret);

        return null;
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.