use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class BasicShadowRenderer method postQueue.
public void postQueue(RenderQueue rq) {
for (Spatial scene : viewPort.getScenes()) {
ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Receive, lightReceivers);
}
// update frustum points based on current camera
Camera viewCam = viewPort.getCamera();
ShadowUtil.updateFrustumPoints(viewCam, viewCam.getFrustumNear(), viewCam.getFrustumFar(), 1.0f, points);
Vector3f frustaCenter = new Vector3f();
for (Vector3f point : points) {
frustaCenter.addLocal(point);
}
frustaCenter.multLocal(1f / 8f);
// update light direction
shadowCam.setProjectionMatrix(null);
shadowCam.setParallelProjection(true);
// shadowCam.setFrustumPerspective(45, 1, 1, 20);
shadowCam.lookAtDirection(direction, Vector3f.UNIT_Y);
shadowCam.update();
shadowCam.setLocation(frustaCenter);
shadowCam.update();
shadowCam.updateViewProjection();
// render shadow casters to shadow map
ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowOccluders, shadowMapSize);
if (shadowOccluders.size() == 0) {
noOccluders = true;
return;
} else {
noOccluders = false;
}
Renderer r = renderManager.getRenderer();
renderManager.setCamera(shadowCam, false);
renderManager.setForcedMaterial(preshadowMat);
r.setFrameBuffer(shadowFB);
r.clearBuffers(true, true, true);
viewPort.getQueue().renderShadowQueue(shadowOccluders, renderManager, shadowCam, true);
r.setFrameBuffer(viewPort.getOutputFrameBuffer());
renderManager.setForcedMaterial(null);
renderManager.setCamera(viewCam, false);
}
use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class BulletVehicleDebugControl method controlUpdate.
@Override
protected void controlUpdate(float tpf) {
for (int i = 0; i < body.getNumWheels(); i++) {
VehicleWheel physicsVehicleWheel = body.getWheel(i);
Vector3f location = physicsVehicleWheel.getLocation().clone();
Vector3f direction = physicsVehicleWheel.getDirection().clone();
Vector3f axle = physicsVehicleWheel.getAxle().clone();
float restLength = physicsVehicleWheel.getRestLength();
float radius = physicsVehicleWheel.getRadius();
Geometry locGeom = (Geometry) suspensionNode.getChild("WheelLocationDebugShape" + i);
Geometry dirGeom = (Geometry) suspensionNode.getChild("WheelDirectionDebugShape" + i);
Geometry axleGeom = (Geometry) suspensionNode.getChild("WheelAxleDebugShape" + i);
Geometry wheelGeom = (Geometry) suspensionNode.getChild("WheelRadiusDebugShape" + i);
Arrow locArrow = (Arrow) locGeom.getMesh();
locArrow.setArrowExtent(location);
Arrow axleArrow = (Arrow) axleGeom.getMesh();
axleArrow.setArrowExtent(axle.normalizeLocal().multLocal(0.3f));
Arrow wheelArrow = (Arrow) wheelGeom.getMesh();
wheelArrow.setArrowExtent(direction.normalizeLocal().multLocal(radius));
Arrow dirArrow = (Arrow) dirGeom.getMesh();
dirArrow.setArrowExtent(direction.normalizeLocal().multLocal(restLength));
dirGeom.setLocalTranslation(location);
axleGeom.setLocalTranslation(location.addLocal(direction));
wheelGeom.setLocalTranslation(location);
i++;
}
applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation));
}
use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class ALAudioRenderer method updateSourceParam.
public void updateSourceParam(AudioSource src, AudioParam param) {
checkDead();
synchronized (threadLock) {
if (audioDisabled) {
return;
}
// it should be safe to just ignore the update
if (src.getChannel() < 0) {
return;
}
assert src.getChannel() >= 0;
int id = channels[src.getChannel()];
switch(param) {
case Position:
if (!src.isPositional()) {
return;
}
Vector3f pos = src.getPosition();
al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
break;
case Velocity:
if (!src.isPositional()) {
return;
}
Vector3f vel = src.getVelocity();
al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
break;
case MaxDistance:
if (!src.isPositional()) {
return;
}
al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
break;
case RefDistance:
if (!src.isPositional()) {
return;
}
al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance());
break;
case ReverbFilter:
if (!supportEfx || !src.isPositional() || !src.isReverbEnabled()) {
return;
}
int filter = EFX.AL_FILTER_NULL;
if (src.getReverbFilter() != null) {
Filter f = src.getReverbFilter();
if (f.isUpdateNeeded()) {
updateFilter(f);
}
filter = f.getId();
}
al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter);
break;
case ReverbEnabled:
if (!supportEfx || !src.isPositional()) {
return;
}
if (src.isReverbEnabled()) {
updateSourceParam(src, AudioParam.ReverbFilter);
} else {
al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL);
}
break;
case IsPositional:
if (!src.isPositional()) {
// Play in headspace
al.alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE);
al.alSource3f(id, AL_POSITION, 0, 0, 0);
al.alSource3f(id, AL_VELOCITY, 0, 0, 0);
// Disable reverb
al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL);
} else {
al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE);
updateSourceParam(src, AudioParam.Position);
updateSourceParam(src, AudioParam.Velocity);
updateSourceParam(src, AudioParam.MaxDistance);
updateSourceParam(src, AudioParam.RefDistance);
updateSourceParam(src, AudioParam.ReverbEnabled);
}
break;
case Direction:
if (!src.isDirectional()) {
return;
}
Vector3f dir = src.getDirection();
al.alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z);
break;
case InnerAngle:
if (!src.isDirectional()) {
return;
}
al.alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle());
break;
case OuterAngle:
if (!src.isDirectional()) {
return;
}
al.alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle());
break;
case IsDirectional:
if (src.isDirectional()) {
updateSourceParam(src, AudioParam.Direction);
updateSourceParam(src, AudioParam.InnerAngle);
updateSourceParam(src, AudioParam.OuterAngle);
al.alSourcef(id, AL_CONE_OUTER_GAIN, 0);
} else {
al.alSourcef(id, AL_CONE_INNER_ANGLE, 360);
al.alSourcef(id, AL_CONE_OUTER_ANGLE, 360);
al.alSourcef(id, AL_CONE_OUTER_GAIN, 1f);
}
break;
case DryFilter:
if (!supportEfx) {
return;
}
if (src.getDryFilter() != null) {
Filter f = src.getDryFilter();
if (f.isUpdateNeeded()) {
updateFilter(f);
// NOTE: must re-attach filter for changes to apply.
al.alSourcei(id, EFX.AL_DIRECT_FILTER, f.getId());
}
} else {
al.alSourcei(id, EFX.AL_DIRECT_FILTER, EFX.AL_FILTER_NULL);
}
break;
case Looping:
if (src.isLooping() && !(src.getAudioData() instanceof AudioStream)) {
al.alSourcei(id, AL_LOOPING, AL_TRUE);
} else {
al.alSourcei(id, AL_LOOPING, AL_FALSE);
}
break;
case Volume:
al.alSourcef(id, AL_GAIN, src.getVolume());
break;
case Pitch:
al.alSourcef(id, AL_PITCH, src.getPitch());
break;
}
}
}
use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class BoundingBox method collideWithRay.
private int collideWithRay(Ray ray) {
TempVars vars = TempVars.get();
try {
Vector3f diff = vars.vect1.set(ray.origin).subtractLocal(center);
Vector3f direction = vars.vect2.set(ray.direction);
//float[] t = {0f, Float.POSITIVE_INFINITY};
// use one of the tempvars arrays
float[] t = vars.fWdU;
t[0] = 0;
t[1] = Float.POSITIVE_INFINITY;
float saveT0 = t[0], saveT1 = t[1];
boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t) && clip(-direction.x, +diff.x - xExtent, t) && clip(+direction.y, -diff.y - yExtent, t) && clip(-direction.y, +diff.y - yExtent, t) && clip(+direction.z, -diff.z - zExtent, t) && clip(-direction.z, +diff.z - zExtent, t);
if (notEntirelyClipped && (t[0] != saveT0 || t[1] != saveT1)) {
if (t[1] > t[0])
return 2;
else
return 1;
}
return 0;
} finally {
vars.release();
}
}
use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class AudioNode method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
// to "audio_key" in case Spatial's key will be written as "key".
if (ic.getSavableVersion(AudioNode.class) == 0) {
audioKey = (AudioKey) ic.readSavable("key", null);
} else {
audioKey = (AudioKey) ic.readSavable("audio_key", null);
}
loop = ic.readBoolean("looping", false);
volume = ic.readFloat("volume", 1);
pitch = ic.readFloat("pitch", 1);
timeOffset = ic.readFloat("time_offset", 0);
dryFilter = (Filter) ic.readSavable("dry_filter", null);
velocity = (Vector3f) ic.readSavable("velocity", null);
reverbEnabled = ic.readBoolean("reverb_enabled", false);
reverbFilter = (Filter) ic.readSavable("reverb_filter", null);
maxDistance = ic.readFloat("max_distance", 20);
refDistance = ic.readFloat("ref_distance", 10);
directional = ic.readBoolean("directional", false);
direction = (Vector3f) ic.readSavable("direction", null);
innerAngle = ic.readFloat("inner_angle", 360);
outerAngle = ic.readFloat("outer_angle", 360);
positional = ic.readBoolean("positional", false);
velocityFromTranslation = ic.readBoolean("velocity_from_translation", false);
if (audioKey != null) {
try {
data = im.getAssetManager().loadAsset(audioKey);
} catch (AssetNotFoundException ex) {
Logger.getLogger(AudioNode.class.getName()).log(Level.FINE, "Cannot locate {0} for audio node {1}", new Object[] { audioKey, key });
data = PlaceholderAssets.getPlaceholderAudio();
}
}
}
Aggregations