Examples of BoundingVolume


Examples of com.jme3.bounding.BoundingVolume

  private void addBBoxes(Node n) {
    for(Spatial s : n.getChildren()){
      if(s instanceof Geometry){
        Node a = s.getParent();
        if(a==null)return;
        BoundingVolume bound = ((Geometry) s).getModelBound();
        if(bound instanceof BoundingBox) {
          WireBox b = new WireBox(((BoundingBox) bound).getXExtent(), ((BoundingBox) bound).getYExtent(), ((BoundingBox) bound).getZExtent());
          Geometry g = new Geometry(null, b);
          g.setLocalTransform(s.getWorldTransform());
          g.setMaterial(matWireframe);
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

  private void addBBoxes(Node n) {
    for(Spatial s : n.getChildren()){
      if(s instanceof Geometry){
        Node a = s.getParent();
        if(a==null)return;
        BoundingVolume bound = ((Geometry) s).getModelBound();
        if(bound instanceof BoundingBox) {
        WireBox b = new WireBox(((BoundingBox) bound).getXExtent(), ((BoundingBox) bound).getYExtent(), ((BoundingBox) bound).getZExtent());
        Geometry g = new Geometry(null, b);
        g.setLocalTransform(s.getWorldTransform());
        g.setMaterial(matWireframe);
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    }

    // Generate grass uniformly with random offset.
    float terrainWidth = 1f * 256; // get width length of terrain(assuming
                    // its a square)
    BoundingVolume bounds = ((Spatial) terrain).getWorldBound();
    if (BoundingVolume.Type.AABB.equals(bounds.getType())) {
      BoundingBox bb = ((BoundingBox) bounds);
      terrainWidth = Math.max(bb.getXExtent(), bb.getZExtent());
      terrainWidth *= 2f;
    } else if (BoundingVolume.Type.Sphere.equals(bounds.getType())) {
      terrainWidth = ((BoundingSphere) bounds).getRadius();
      terrainWidth *= 2f;
    }
    Vector3f centre = bounds.getCenter(); // get the centr location of the
                        // terrain
    Vector2f grassPatchRandomOffset = new Vector2f().zero();
    Vector3f candidateGrassPatchLocation = new Vector3f();

    Random rand = new Random();
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

        return true;
    }

    public int collideWith(Collidable other, CollisionResults results) {
        if (other instanceof BoundingVolume) {
            BoundingVolume bv = (BoundingVolume) other;
            return bv.collideWith(this, results);
        } else if (other instanceof AbstractTriangle) {
            AbstractTriangle tri = (AbstractTriangle) other;
            float d = intersects(tri.get1(), tri.get2(), tri.get3());
            if (Float.isInfinite(d) || Float.isNaN(d)) {
                return 0;
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    protected void updateWorldBound(){
        super.updateWorldBound();
       
        // for a node, the world bound is a combination of all it's children
        // bounds
        BoundingVolume resultBound = null;
        for (Spatial child : children.getArray()) {
            // child bound is assumed to be updated
            assert (child.refreshFlags & RF_BOUND) == 0;
            if (resultBound != null) {
                // merge current world bound with child world bound
                resultBound.mergeLocal(child.getWorldBound());
            } else {
                // set world bound to first non-null child world bound
                if (child.getWorldBound() != null) {
                    resultBound = child.getWorldBound().clone(this.worldBound);
                }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    }

    @Override
    protected void computeLastDistance(Spatial owner) {
        if (owner.getWorldBound() != null) {
            BoundingVolume bv = owner.getWorldBound();
            lastDistance = bv.distanceSquaredTo(position);
        } else {
            lastDistance = owner.getWorldTranslation().distanceSquared(position);
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    protected float invRadius = 0;

    @Override
    public void computeLastDistance(Spatial owner) {
        if (owner.getWorldBound() != null) {
            BoundingVolume bv = owner.getWorldBound();
            lastDistance = bv.distanceSquaredTo(position);
        } else {
            lastDistance = owner.getWorldTranslation().distanceSquared(position);
        }
    }
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

    @Override
    protected void controlUpdate(float tpf) {
    }

    protected void controlRender(RenderManager rm, ViewPort vp) {
        BoundingVolume bv = spatial.getWorldBound();

        Camera cam = vp.getCamera();
        float atanNH = FastMath.atan(cam.getFrustumNear() * cam.getFrustumTop());
        float ratio = (FastMath.PI / (8f * atanNH));
        float newDistance = bv.distanceTo(vp.getCamera().getLocation()) / ratio;
        int level;

        if (Math.abs(newDistance - lastDistance) <= distTolerance) {
            level = lastLevel; // we haven't moved relative to the model, send the old measurement back.
        } else if (lastDistance > newDistance && lastLevel == 0) {
View Full Code Here

Examples of com.jme3.bounding.BoundingVolume

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

Examples of com.jme3.bounding.BoundingVolume

            if (scale == null) {// the node will be repeated several times in the same place
                scale = new float[] { 0.0f, 0.0f, 0.0f };
            } else {
                // getting bounding box
                node.updateModelBound();
                BoundingVolume boundingVolume = node.getWorldBound();
                if (boundingVolume instanceof BoundingBox) {
                    scale[0] *= ((BoundingBox) boundingVolume).getXExtent() * 2.0f;
                    scale[1] *= ((BoundingBox) boundingVolume).getYExtent() * 2.0f;
                    scale[2] *= ((BoundingBox) boundingVolume).getZExtent() * 2.0f;
                } else if (boundingVolume instanceof BoundingSphere) {
                    float radius = ((BoundingSphere) boundingVolume).getRadius();
                    scale[0] *= radius * 2.0f;
                    scale[1] *= radius * 2.0f;
                    scale[2] *= radius * 2.0f;
                } else {
                    throw new IllegalStateException("Unknown bounding volume type: " + boundingVolume.getClass().getName());
                }
            }
   
            // adding object's offset
            float[] objectOffset = new float[] { 0.0f, 0.0f, 0.0f };
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.