Package com.jme.bounding

Examples of com.jme.bounding.BoundingBox


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


        }
       
        private void drawBounds(BoundingVolume bounds, Graphics2D g, boolean fill, Color color) {
            Color current = g.getColor();
            if (bounds instanceof BoundingBox) {
                BoundingBox box = (BoundingBox)bounds;
                center = box.getCenter(center);
                extent = box.getExtent(extent);
               
                if (extent.x==Float.POSITIVE_INFINITY)
                    return;

                g.setColor(color);
View Full Code Here

    public <T extends CellServerState> T getDefaultCellServerState(
            Properties props) {

        ModelCellServerState cellState = new ModelCellServerState();
        cellState.setBoundingVolumeHint(new BoundingVolumeHint(true,
                new BoundingBox(Vector3f.ZERO,
                                1.44526004f,
                                1.44525876f,
                                0.13593452f)));
       
        // add the model
View Full Code Here

        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;
            if (box.xExtent > 20 || box.zExtent > 20) {
                hint = new BoundingBox(Vector3f.ZERO, 1, box.yExtent, 1);
            }
        }
        else if (bounds instanceof BoundingSphere) {
            // Handle if the bounding volume is a sphere. This is a bit tricky.
            // If the radius is too large, we want to place the model close to
            // the avatar, but we also want the model to sit on the floor, not
            // in it. So in this case, we need to create a bounding box for the
            // hint instead of a sphere, so we can set the x and z extents to
            // be 1 and the y extent to be the radius of the sphere.
            BoundingSphere sphere = (BoundingSphere) bounds;
            if (sphere.radius > 20) {
                hint = new BoundingBox(Vector3f.ZERO, 1, sphere.radius, 1);
            }
        }
        return new BoundingVolumeHint(true, hint);
    }
View Full Code Here

        {
            super ("Pick Box", new Vector3f(x, y, z), xSize, ySize, zSize);

            this.jointName = jointName;

            setModelBound(new BoundingBox(new Vector3f(x, y, z),
                                          xSize, ySize, zSize));
            setCullHint(CullHint.Always);
        }
View Full Code Here

            boundsCenterZTF.setText(Double.toString(center.z));
            boundsSizeXTF.setText(Double.toString(sphere.getRadius()));
            boundsSizeYTF.setText("N/A Sphere");
            boundsSizeZTF.setText("N/A Sphere");
        } else if (bounds instanceof BoundingBox) {
            BoundingBox box = (BoundingBox) bounds;
            Vector3f center = new Vector3f();
            box.getCenter();
            boundsCenterXTF.setText(Double.toString(center.x));
            boundsCenterYTF.setText(Double.toString(center.y));
            boundsCenterZTF.setText(Double.toString(center.z));

            boundsSizeXTF.setText(Float.toString(box.xExtent));
View Full Code Here

     */
    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(),
View Full Code Here

         * Try rotating 45 degrees to see what that does.
         */
        //Vector3f axis = new Vector3f((float) 1, (float) 0, (float) 0);
        //cellServerState.setRotation(new Rotation(axis, (float) Math.PI / 4));

  BoundingBox box = new BoundingBox(
      new Vector3f(0, 0, 0), 0.27053905F, 0.060000006F, 0.27053908F);

  BoundingVolumeHint hint = new BoundingVolumeHint(true, box);
  cellServerState.setBoundingVolumeHint(hint);
 
View Full Code Here

  public void detonate(Ray vector) {
    final Teapot teapot = new Teapot("killer teapot");
    TankGame.GAME.lock();
    TankGame.GAMESTATE.getRoot().attachChild(teapot);
    teapot.updateRenderState();
    teapot.setModelBound(new BoundingBox());
    teapot.updateModelBound();
    teapot.updateWorldBound();
   
    teapot.setLocalTranslation(vector.origin);
    TankGame.GAME.unlock();
View Full Code Here

    MaterialTerrainBlock block1 = new MaterialTerrainBlock(getName()
        + "Block1", split, getStepScale(), heightBlock1, origin1, clod,
        getTotalSize(), tempOffset, getOffsetAmount(), materialMap);
    block1.setQuadrant((short) 1);
    this.attachChild(block1);
    block1.setModelBound(new BoundingBox());
    block1.updateModelBound();

    // 2 lower left
    int[] heightBlock2 = createHeightSubBlock(heightMap, 0, split - 1,
        split);

    Vector3f origin2 = new Vector3f(-halfSize * getStepScale().x, 0, 0);

    tempOffset.x = getOffset().x;
    tempOffset.y = getOffset().y;
    tempOffset.x += origin1.x / 2;
    tempOffset.y += quarterSize * getStepScale().z;

    MaterialTerrainBlock block2 = new MaterialTerrainBlock(getName()
        + "Block2", split, getStepScale(), heightBlock2, origin2, clod,
        getTotalSize(), tempOffset, getOffsetAmount(), materialMap);
    block2.setQuadrant((short) 2);
    this.attachChild(block2);
    block2.setModelBound(new BoundingBox());
    block2.updateModelBound();

    // 3 upper right
    int[] heightBlock3 = createHeightSubBlock(heightMap, split - 1, 0,
        split);

    Vector3f origin3 = new Vector3f(0, 0, -halfSize * getStepScale().z);

    tempOffset.x = getOffset().x;
    tempOffset.y = getOffset().y;
    tempOffset.x += quarterSize * getStepScale().x;
    tempOffset.y += origin3.z / 2;

    MaterialTerrainBlock block3 = new MaterialTerrainBlock(getName()
        + "Block3", split, getStepScale(), heightBlock3, origin3, clod,
        getTotalSize(), tempOffset, getOffsetAmount(), materialMap);
    block3.setQuadrant((short) 3);
    this.attachChild(block3);
    block3.setModelBound(new BoundingBox());
    block3.updateModelBound();

    // 4 lower right
    int[] heightBlock4 = createHeightSubBlock(heightMap, split - 1,
        split - 1, split);

    Vector3f origin4 = new Vector3f(0, 0, 0);

    tempOffset.x = getOffset().x;
    tempOffset.y = getOffset().y;
    tempOffset.x += quarterSize * getStepScale().x;
    tempOffset.y += quarterSize * getStepScale().z;

    MaterialTerrainBlock block4 = new MaterialTerrainBlock(getName()
        + "Block4", split, getStepScale(), heightBlock4, origin4, clod,
        getTotalSize(), tempOffset, getOffsetAmount(), materialMap);
    block4.setQuadrant((short) 4);
    this.attachChild(block4);
    block4.setModelBound(new BoundingBox());
    block4.updateModelBound();
  }
View Full Code Here

TOP

Related Classes of com.jme.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.