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;
}
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;
}
}
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);
}
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);
}
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);
}
Aggregations