* Always close InputStream in WAVLoader

* Fix use of deprecated classes/methods in android tests
 * Fix bugs with joysticks often generating events for both the negative and positive side of axis
 * Camera.clone() properly clones the gui bounding
 * Camera.setParallelProjection() updates the camera's projection matrix instead of keeping old values
 * LwjglOffscreenBuffer obeys by framerate setting and sets renderable property as needed

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8283 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 13 years ago
parent 4916af3b16
commit a5be89598f
  1. 4
      engine/src/android/jme3test/android/TestAmbient.java
  2. 3
      engine/src/android/jme3test/android/TestSkyLoadingLagoon.java
  3. 3
      engine/src/android/jme3test/android/TestSkyLoadingPrimitives.java
  4. 3
      engine/src/core/com/jme3/animation/Bone.java
  5. 1
      engine/src/core/com/jme3/animation/Skeleton.java
  6. 31
      engine/src/core/com/jme3/audio/plugins/WAVLoader.java
  7. 4
      engine/src/core/com/jme3/input/InputManager.java
  8. 2
      engine/src/core/com/jme3/renderer/Camera.java
  9. 4
      engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java
  10. 31
      engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java
  11. 6
      engine/src/test/jme3test/niftygui/TestNiftyGui.java

@ -83,10 +83,10 @@ public class TestAmbient extends SimpleApplication {
audioRenderer.playSource(beep);
*/
waves = new AudioNode(audioRenderer, assetManager, "Sound/Environment/Ocean Waves.ogg", true);
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
waves.setPositional(true);
nature = new AudioNode(audioRenderer, assetManager, "Sound/Environment/Nature.ogg", true);
nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
waves.setLocalTranslation(new Vector3f(4, -1, 30));
waves.setMaxDistance(5);

@ -36,7 +36,6 @@ import com.jme3.app.SimpleApplication;
import com.jme3.scene.Spatial;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import com.jme3.util.android.AndroidSkyFactory;
public class TestSkyLoadingLagoon extends SimpleApplication {
@ -64,7 +63,7 @@ public class TestSkyLoadingLagoon extends SimpleApplication {
Texture down = assetManager.loadTexture("Textures/Sky/Primitives/primitives_negative_y.png");
*/
Spatial sky = AndroidSkyFactory.createSky(assetManager, west, east, north, south, up, down);
Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
rootNode.attachChild(sky);
}

@ -36,7 +36,6 @@ import com.jme3.app.SimpleApplication;
import com.jme3.scene.Spatial;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import com.jme3.util.android.AndroidSkyFactory;
public class TestSkyLoadingPrimitives extends SimpleApplication {
@ -62,7 +61,7 @@ public class TestSkyLoadingPrimitives extends SimpleApplication {
Texture up = assetManager.loadTexture("Textures/Sky/Primitives/primitives_positive_y.png");
Texture down = assetManager.loadTexture("Textures/Sky/Primitives/primitives_negative_y.png");
Spatial sky = AndroidSkyFactory.createSky(assetManager, west, east, north, south, up, down);
Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
rootNode.attachChild(sky);
}

@ -102,6 +102,9 @@ public final class Bone implements Savable {
* @param name Name to give to this bone
*/
public Bone(String name) {
if (name == null)
throw new IllegalArgumentException("Name cannot be null");
this.name = name;
initialPos = new Vector3f();

@ -210,7 +210,6 @@ public final class Skeleton implements Savable {
return boneList[i];
}
}
return null;
}

@ -41,6 +41,7 @@ import com.jme3.audio.AudioKey;
import com.jme3.util.BufferUtils;
import com.jme3.util.LittleEndien;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -52,7 +53,7 @@ public class WAVLoader implements AssetLoader {
// all these are in big endian
private static final int i_RIFF = 0x46464952;
private static final int i_WAVE = 0x45564157;
private static final int i_fmt = 0x20746D66 ;
private static final int i_fmt = 0x20746D66;
private static final int i_data = 0x61746164;
private boolean readStream = false;
@ -104,7 +105,6 @@ public class WAVLoader implements AssetLoader {
if (remaining > 0){
in.skipBytes(remaining);
}
}
private void readDataChunkForBuffer(int len) throws IOException {
@ -123,9 +123,9 @@ public class WAVLoader implements AssetLoader {
audioStream.updateData(in, duration);
}
public Object load(AssetInfo info) throws IOException {
this.in = new LittleEndien(info.openStream());
private AudioData load(InputStream inputStream, boolean stream) throws IOException{
this.in = new LittleEndien(inputStream);
int sig = in.readInt();
if (sig != i_RIFF)
throw new IOException("File is not a WAVE file");
@ -135,8 +135,7 @@ public class WAVLoader implements AssetLoader {
if (in.readInt() != i_WAVE)
throw new IOException("WAVE File does not contain audio");
readStream = ((AudioKey)info.getKey()).isStream();
readStream = stream;
if (readStream){
audioStream = new AudioStream();
audioData = audioStream;
@ -168,9 +167,25 @@ public class WAVLoader implements AssetLoader {
if (skipped <= 0) {
return null;
}
break;
}
}
}
public Object load(AssetInfo info) throws IOException {
AudioData data;
InputStream inputStream = null;
try {
inputStream = info.openStream();
data = load(inputStream, ((AudioKey)info.getKey()).isStream());
if (data instanceof AudioStream){
inputStream = null;
}
return data;
} finally {
if (inputStream != null){
inputStream.close();
}
}
}
}

@ -337,12 +337,16 @@ public class InputManager implements RawInputListener {
} else if (value < 0) {
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, false);
invokeAnalogsAndActions(hash, -value, true);
axisValues.put(hash, -value);
axisValues.remove(otherHash);
} else {
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false);
int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
invokeAnalogsAndActions(hash, value, true);
axisValues.put(hash, value);
axisValues.remove(otherHash);
}
}

@ -286,6 +286,7 @@ public class Camera implements Savable, Cloneable {
cam.viewMatrix = viewMatrix.clone();
cam.projectionMatrix = projectionMatrix.clone();
cam.viewProjectionMatrix = viewProjectionMatrix.clone();
cam.guiBounding = (BoundingBox) guiBounding.clone();
cam.update();
@ -1227,6 +1228,7 @@ public class Camera implements Savable, Cloneable {
*/
public void setParallelProjection(final boolean value) {
this.parallelProjection = value;
onFrustumChange();
}
/**

@ -1530,7 +1530,9 @@ public class LwjglRenderer implements Renderer {
public void setFrameBuffer(FrameBuffer fb) {
if (lastFb == fb) {
return;
if (fb == null || !fb.isUpdateNeeded()){
return;
}
}
// generate mipmaps for last FB if needed

@ -43,6 +43,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.OpenGLException;
import org.lwjgl.opengl.Pbuffer;
import org.lwjgl.opengl.PixelFormat;
@ -64,10 +65,11 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
}
pixelFormat = new PixelFormat(settings.getBitsPerPixel(),
0,
settings.getDepthBits(),
settings.getStencilBits(),
settings.getSamples());
0,
settings.getDepthBits(),
settings.getStencilBits(),
settings.getSamples());
width = settings.getWidth();
height = settings.getHeight();
try{
@ -77,21 +79,7 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
}
});
//String rendererStr = settings.getString("Renderer");
// if (rendererStr.startsWith("LWJGL-OpenGL3")){
// ContextAttribs attribs;
// if (rendererStr.equals("LWJGL-OpenGL3.1")){
// attribs = new ContextAttribs(3, 1);
// }else{
// attribs = new ContextAttribs(3, 0);
// }
// attribs.withForwardCompatible(true);
// attribs.withDebug(false);
// Display.create(pf, attribs);
// }else{
pbuffer = new Pbuffer(width, height, pixelFormat, null, null, createContextAttribs());
// }
pbuffer.makeCurrent();
renderable.set(true);
@ -141,9 +129,16 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
assert checkGLError();
renderer.onFrame();
int frameRate = settings.getFrameRate();
if (frameRate >= 1){
Display.sync(frameRate);
}
}
protected void deinitInThread(){
renderable.set(false);
listener.destroy();
renderer.cleanup();
pbuffer.destroy();

@ -66,9 +66,6 @@ public class TestNiftyGui extends SimpleApplication implements ScreenController
audioRenderer,
guiViewPort);
nifty = niftyDisplay.getNifty();
URL url = Thread.currentThread().getContextClassLoader().getResource("jme3test/niftygui/hellojme.xml");
nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this);
// attach the nifty display to the gui view port as a processor
@ -76,7 +73,8 @@ public class TestNiftyGui extends SimpleApplication implements ScreenController
// disable the fly cam
// flyCam.setEnabled(false);
flyCam.setDragToRotate(true);
// flyCam.setDragToRotate(true);
inputManager.setCursorVisible(true);
}
public void bind(Nifty nifty, Screen screen) {

Loading…
Cancel
Save