Search in sources :

Example 26 with Direction

use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.

the class SpotLight method intersectsFrustum.

@Override
public boolean intersectsFrustum(Camera cam, TempVars vars) {
    if (spotRange == 0) {
        // The algorithm below does not support infinite spot range.
        return true;
    }
    Vector3f farPoint = vars.vect1.set(position).addLocal(vars.vect2.set(direction).multLocal(spotRange));
    for (int i = 5; i >= 0; i--) {
        //check origin against the plane
        Plane plane = cam.getWorldPlane(i);
        float dot = plane.pseudoDistance(position);
        if (dot < 0) {
            // outside, check the far point against the plane   
            dot = plane.pseudoDistance(farPoint);
            if (dot < 0) {
                // outside, check the projection of the far point along the normal of the plane to the base disc perimeter of the cone
                //computing the radius of the base disc
                float farRadius = (spotRange / outerAngleCos) * outerAngleSin;
                //computing the projection direction : perpendicular to the light direction and coplanar with the direction vector and the normal vector
                Vector3f perpDirection = vars.vect2.set(direction).crossLocal(plane.getNormal()).normalizeLocal().crossLocal(direction);
                //projecting the far point on the base disc perimeter
                Vector3f projectedPoint = vars.vect3.set(farPoint).addLocal(perpDirection.multLocal(farRadius));
                //checking against the plane
                dot = plane.pseudoDistance(projectedPoint);
                if (dot < 0) {
                    // Outside, the light can be culled
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : Plane(com.jme3.math.Plane) Vector3f(com.jme3.math.Vector3f)

Example 27 with Direction

use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.

the class SpotLight method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    spotInnerAngle = ic.readFloat("spotInnerAngle", FastMath.QUARTER_PI / 8);
    spotOuterAngle = ic.readFloat("spotOuterAngle", FastMath.QUARTER_PI / 6);
    computeAngleParameters();
    direction = (Vector3f) ic.readSavable("direction", new Vector3f());
    position = (Vector3f) ic.readSavable("position", new Vector3f());
    spotRange = ic.readFloat("spotRange", 100);
    if (spotRange != 0) {
        this.invSpotRange = 1 / spotRange;
    } else {
        this.invSpotRange = 0;
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 28 with Direction

use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.

the class CubeMapWrapper method getPixel.

/**
     * 
     * Reads a pixel from the cube map given the coordinate vector
     * @param vector the direction vector to fetch the texel
     * @param mipLevel the mip level to read from
     * @param store the color in which to store the pixel color read.
     * @return the color of the pixel read.
     */
public ColorRGBA getPixel(Vector3f vector, int mipLevel, ColorRGBA store) {
    if (mipMapRaster == null) {
        throw new IllegalArgumentException("This cube map has no mip maps");
    }
    if (store == null) {
        store = new ColorRGBA();
    }
    int face = EnvMapUtils.getCubemapFaceTexCoordFromVector(vector, sizes[mipLevel], uvs, EnvMapUtils.FixSeamsMethod.Stretch);
    mipMapRaster.setSlice(face);
    mipMapRaster.setMipLevel(mipLevel);
    return mipMapRaster.getPixel((int) uvs.x, (int) uvs.y, store);
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA)

Example 29 with Direction

use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.

the class DirectionalLight method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    direction = (Vector3f) ic.readSavable("direction", null);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 30 with Direction

use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.

the class VehicleWheel method read.

@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule capsule = im.getCapsule(this);
    wheelSpatial = (Spatial) capsule.readSavable("wheelSpatial", null);
    frontWheel = capsule.readBoolean("frontWheel", false);
    location = (Vector3f) capsule.readSavable("wheelLocation", new Vector3f());
    direction = (Vector3f) capsule.readSavable("wheelDirection", new Vector3f());
    axle = (Vector3f) capsule.readSavable("wheelAxle", new Vector3f());
    suspensionStiffness = capsule.readFloat("suspensionStiffness", 20.0f);
    wheelsDampingRelaxation = capsule.readFloat("wheelsDampingRelaxation", 2.3f);
    wheelsDampingCompression = capsule.readFloat("wheelsDampingCompression", 4.4f);
    frictionSlip = capsule.readFloat("frictionSlip", 10.5f);
    rollInfluence = capsule.readFloat("rollInfluence", 1.0f);
    maxSuspensionTravelCm = capsule.readFloat("maxSuspensionTravelCm", 500f);
    maxSuspensionForce = capsule.readFloat("maxSuspensionForce", 6000f);
    radius = capsule.readFloat("wheelRadius", 0.5f);
    restLength = capsule.readFloat("restLength", 1f);
}
Also used : Vector3f(com.jme3.math.Vector3f)

Aggregations

Vector3f (com.jme3.math.Vector3f)26 TempVars (com.jme3.util.TempVars)19 CollisionResult (com.jme3.collision.CollisionResult)6 ColorRGBA (com.jme3.math.ColorRGBA)6 Quaternion (com.jme3.math.Quaternion)6 Geometry (com.jme3.scene.Geometry)4 CollisionResults (com.jme3.collision.CollisionResults)3 DirectionalLight (com.jme3.light.DirectionalLight)3 Ray (com.jme3.math.Ray)3 Vector2f (com.jme3.math.Vector2f)3 Renderer (com.jme3.renderer.Renderer)3 CameraNode (com.jme3.scene.CameraNode)3 Node (com.jme3.scene.Node)3 BoundingSphere (com.jme3.bounding.BoundingSphere)2 VehicleWheel (com.jme3.bullet.objects.VehicleWheel)2 InputCapsule (com.jme3.export.InputCapsule)2 OutputCapsule (com.jme3.export.OutputCapsule)2 AmbientLight (com.jme3.light.AmbientLight)2 Light (com.jme3.light.Light)2 PointLight (com.jme3.light.PointLight)2