use of com.jme3.terrain.noise.Filter in project jmonkeyengine by jMonkeyEngine.
the class BulletDebugAppState method updateJoints.
private void updateJoints() {
HashMap<PhysicsJoint, Spatial> oldObjects = joints;
joints = new HashMap<PhysicsJoint, Spatial>();
Collection<PhysicsJoint> current = space.getJointList();
//create new map
for (Iterator<PhysicsJoint> it = current.iterator(); it.hasNext(); ) {
PhysicsJoint physicsObject = it.next();
//copy existing spatials
if (oldObjects.containsKey(physicsObject)) {
Spatial spat = oldObjects.get(physicsObject);
joints.put(physicsObject, spat);
oldObjects.remove(physicsObject);
} else {
if (filter == null || filter.displayObject(physicsObject)) {
logger.log(Level.FINE, "Create new debug Joint");
//create new spatial
Node node = new Node(physicsObject.toString());
node.addControl(new BulletJointDebugControl(this, physicsObject));
joints.put(physicsObject, node);
physicsDebugRootNode.attachChild(node);
}
}
}
//remove leftover spatials
for (Map.Entry<PhysicsJoint, Spatial> entry : oldObjects.entrySet()) {
PhysicsJoint object = entry.getKey();
Spatial spatial = entry.getValue();
spatial.removeFromParent();
}
}
use of com.jme3.terrain.noise.Filter in project jmonkeyengine by jMonkeyEngine.
the class BulletDebugAppState method updateVehicles.
private void updateVehicles() {
HashMap<PhysicsVehicle, Spatial> oldObjects = vehicles;
vehicles = new HashMap<PhysicsVehicle, Spatial>();
Collection<PhysicsVehicle> current = space.getVehicleList();
//create new map
for (Iterator<PhysicsVehicle> it = current.iterator(); it.hasNext(); ) {
PhysicsVehicle physicsObject = it.next();
//copy existing spatials
if (oldObjects.containsKey(physicsObject)) {
Spatial spat = oldObjects.get(physicsObject);
vehicles.put(physicsObject, spat);
oldObjects.remove(physicsObject);
} else {
if (filter == null || filter.displayObject(physicsObject)) {
logger.log(Level.FINE, "Create new debug Vehicle");
//create new spatial
Node node = new Node(physicsObject.toString());
node.addControl(new BulletVehicleDebugControl(this, physicsObject));
vehicles.put(physicsObject, node);
physicsDebugRootNode.attachChild(node);
}
}
}
//remove leftover spatials
for (Map.Entry<PhysicsVehicle, Spatial> entry : oldObjects.entrySet()) {
PhysicsVehicle object = entry.getKey();
Spatial spatial = entry.getValue();
spatial.removeFromParent();
}
}
use of com.jme3.terrain.noise.Filter in project jmonkeyengine by jMonkeyEngine.
the class BulletDebugAppState method updateRigidBodies.
private void updateRigidBodies() {
HashMap<PhysicsRigidBody, Spatial> oldObjects = bodies;
bodies = new HashMap<PhysicsRigidBody, Spatial>();
Collection<PhysicsRigidBody> current = space.getRigidBodyList();
//create new map
for (Iterator<PhysicsRigidBody> it = current.iterator(); it.hasNext(); ) {
PhysicsRigidBody physicsObject = it.next();
//copy existing spatials
if (oldObjects.containsKey(physicsObject)) {
Spatial spat = oldObjects.get(physicsObject);
bodies.put(physicsObject, spat);
oldObjects.remove(physicsObject);
} else {
if (filter == null || filter.displayObject(physicsObject)) {
logger.log(Level.FINE, "Create new debug RigidBody");
//create new spatial
Node node = new Node(physicsObject.toString());
node.addControl(new BulletRigidBodyDebugControl(this, physicsObject));
bodies.put(physicsObject, node);
physicsDebugRootNode.attachChild(node);
}
}
}
//remove leftover spatials
for (Map.Entry<PhysicsRigidBody, Spatial> entry : oldObjects.entrySet()) {
PhysicsRigidBody object = entry.getKey();
Spatial spatial = entry.getValue();
spatial.removeFromParent();
}
}
use of com.jme3.terrain.noise.Filter 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.noise.Filter in project jmonkeyengine by jMonkeyEngine.
the class ALAudioRenderer method setSourceParams.
private void setSourceParams(int id, AudioSource src, boolean forceNonLoop) {
if (src.isPositional()) {
Vector3f pos = src.getPosition();
Vector3f vel = src.getVelocity();
al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance());
al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE);
if (src.isReverbEnabled() && supportEfx) {
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);
}
} else {
// 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);
}
if (src.getDryFilter() != null && supportEfx) {
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());
}
}
if (forceNonLoop || src.getAudioData() instanceof AudioStream) {
al.alSourcei(id, AL_LOOPING, AL_FALSE);
} else {
al.alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE);
}
al.alSourcef(id, AL_GAIN, src.getVolume());
al.alSourcef(id, AL_PITCH, src.getPitch());
al.alSourcef(id, AL_SEC_OFFSET, src.getTimeOffset());
if (src.isDirectional()) {
Vector3f dir = src.getDirection();
al.alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z);
al.alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle());
al.alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle());
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);
}
}
Aggregations