Package com.jme.bounding

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


       
    /**
     * 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

            // 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

    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

        if (bg == null) {
            return;
        }

        BoundingVolume bounds = bg.getWorldBound();

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

     * 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

       
        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

            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

    private CellTransform generateGoToPosition(CellID cellID) {

        CellTransform viewTransform = model.getCellTransformForCellID(cellID);
       
        ServerSessionManager manager = LoginManager.getPrimary();
        BoundingVolume boundsHint = new BoundingSphere(1.0f, Vector3f.ZERO);
            CellTransform generated = CellPlacementUtils.getCellTransform(manager, boundsHint,
                    viewTransform);
        LOGGER.fine("ORIGINAL:\n" + logTransform(viewTransform) + "\n"
                + "GENERATED:\n" + logTransform(generated));
View Full Code Here

        outsideVolumeSlider.setValue(originalOutsideAudioVolume);
        fullVolumeRadiusSpinner.setValue(originalBounds.getX());

  showBoundsCheckBox.setSelected(originalShowBounds);

  BoundingVolume bounds = editor.getCell().getLocalBounds();

  if (bounds instanceof BoundingSphere) {
      float radius = ((BoundingSphere) bounds).getRadius();
     
            String text = BUNDLE.getString("Sphere_With_Radius");
            text = MessageFormat.format(text, (Math.round(radius * 10) / 10f));
            boundsLabel.setText(text);
  } else if (bounds instanceof BoundingBox) {
      Vector3f extent = new Vector3f();
      extent = ((BoundingBox) bounds).getExtent(extent);
      showBoxBounds("Box", extent);
  } else if (bounds instanceof OrientedBoundingBox) {
      Vector3f extent = ((OrientedBoundingBox) bounds).getExtent();
      showBoxBounds("OrientedBox", extent);
  } else {
      boundsLabel.setText(bounds.toString());
  }

  showBounds();
  inRestore = false;
    }
View Full Code Here

TOP

Related Classes of com.jme.bounding.BoundingVolume

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.