Search in sources :

Example 21 with BoundingVolume

use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.

the class PointLight method computeLastDistance.

@Override
public void computeLastDistance(Spatial owner) {
    if (owner.getWorldBound() != null) {
        BoundingVolume bv = owner.getWorldBound();
        lastDistance = bv.distanceSquaredTo(position);
    } else {
        lastDistance = owner.getWorldTranslation().distanceSquared(position);
    }
}
Also used : BoundingVolume(com.jme3.bounding.BoundingVolume)

Example 22 with BoundingVolume

use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.

the class SpotLight method computeLastDistance.

@Override
protected void computeLastDistance(Spatial owner) {
    if (owner.getWorldBound() != null) {
        BoundingVolume bv = owner.getWorldBound();
        lastDistance = bv.distanceSquaredTo(position);
    } else {
        lastDistance = owner.getWorldTranslation().distanceSquared(position);
    }
}
Also used : BoundingVolume(com.jme3.bounding.BoundingVolume)

Example 23 with BoundingVolume

use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.

the class TemporalMesh method getWorldBound.

@Override
public BoundingVolume getWorldBound() {
    this.updateModelBound();
    Node parent = this.getParent();
    if (parent != null) {
        BoundingVolume bv = boundingBox.clone();
        bv.setCenter(parent.getWorldTranslation());
        return bv;
    } else {
        return boundingBox;
    }
}
Also used : Node(com.jme3.scene.Node) BoundingVolume(com.jme3.bounding.BoundingVolume)

Example 24 with BoundingVolume

use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.

the class BIHTree method collideWithRay.

private int collideWithRay(Ray r, Matrix4f worldMatrix, BoundingVolume worldBound, CollisionResults results) {
    TempVars vars = TempVars.get();
    try {
        CollisionResults boundResults = vars.collisionResults;
        boundResults.clear();
        worldBound.collideWith(r, boundResults);
        if (boundResults.size() > 0) {
            float tMin = boundResults.getClosestCollision().getDistance();
            float tMax = boundResults.getFarthestCollision().getDistance();
            if (tMax <= 0) {
                tMax = Float.POSITIVE_INFINITY;
            } else if (tMin == tMax) {
                tMin = 0;
            }
            if (tMin <= 0) {
                tMin = 0;
            }
            if (r.getLimit() < Float.POSITIVE_INFINITY) {
                tMax = Math.min(tMax, r.getLimit());
                if (tMin > tMax) {
                    return 0;
                }
            }
            //            return root.intersectBrute(r, worldMatrix, this, tMin, tMax, results);
            return root.intersectWhere(r, worldMatrix, this, tMin, tMax, results);
        }
        return 0;
    } finally {
        vars.release();
    }
}
Also used : CollisionResults(com.jme3.collision.CollisionResults) TempVars(com.jme3.util.TempVars)

Example 25 with BoundingVolume

use of com.jme3.bounding.BoundingVolume in project jmonkeyengine by jMonkeyEngine.

the class PoiLightProbeLightFilter method filterLights.

@Override
public void filterLights(Geometry geometry, LightList filteredLightList) {
    TempVars vars = TempVars.get();
    try {
        LightList worldLights = geometry.getWorldLightList();
        for (int i = 0; i < worldLights.size(); i++) {
            Light light = worldLights.get(i);
            if (light.getType() == Light.Type.Probe) {
                continue;
            }
            if (light.frustumCheckNeeded) {
                processedLights.add(light);
                light.frustumCheckNeeded = false;
                light.intersectsFrustum = light.intersectsFrustum(camera, vars);
            }
            if (!light.intersectsFrustum) {
                continue;
            }
            BoundingVolume bv = geometry.getWorldBound();
            if (bv instanceof BoundingBox) {
                if (!light.intersectsBox((BoundingBox) bv, vars)) {
                    continue;
                }
            } else if (bv instanceof BoundingSphere) {
                if (!Float.isInfinite(((BoundingSphere) bv).getRadius())) {
                    if (!light.intersectsSphere((BoundingSphere) bv, vars)) {
                        continue;
                    }
                }
            }
            filteredLightList.add(light);
        }
        processor.populateProbe(filteredLightList);
    } finally {
        vars.release();
    }
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) BoundingBox(com.jme3.bounding.BoundingBox) BoundingVolume(com.jme3.bounding.BoundingVolume) TempVars(com.jme3.util.TempVars)

Aggregations

BoundingVolume (com.jme3.bounding.BoundingVolume)18 BoundingBox (com.jme3.bounding.BoundingBox)10 TempVars (com.jme3.util.TempVars)10 BoundingSphere (com.jme3.bounding.BoundingSphere)7 Geometry (com.jme3.scene.Geometry)4 UnsupportedCollisionException (com.jme3.collision.UnsupportedCollisionException)3 Spatial (com.jme3.scene.Spatial)3 CollisionResult (com.jme3.collision.CollisionResult)2 CollisionResults (com.jme3.collision.CollisionResults)2 Vector3f (com.jme3.math.Vector3f)2 InputCapsule (com.jme3.export.InputCapsule)1 MatParamOverride (com.jme3.material.MatParamOverride)1 Matrix4f (com.jme3.math.Matrix4f)1 Camera (com.jme3.renderer.Camera)1 Bucket (com.jme3.renderer.queue.RenderQueue.Bucket)1 ShadowMode (com.jme3.renderer.queue.RenderQueue.ShadowMode)1 Node (com.jme3.scene.Node)1 BlenderFileException (com.jme3.scene.plugins.blender.file.BlenderFileException)1 FileBlockHeader (com.jme3.scene.plugins.blender.file.FileBlockHeader)1 Pointer (com.jme3.scene.plugins.blender.file.Pointer)1