* 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
This commit is contained in:
parent
4916af3b16
commit
a5be89598f
@ -83,10 +83,10 @@ public class TestAmbient extends SimpleApplication {
|
|||||||
audioRenderer.playSource(beep);
|
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);
|
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.setLocalTranslation(new Vector3f(4, -1, 30));
|
||||||
waves.setMaxDistance(5);
|
waves.setMaxDistance(5);
|
||||||
|
@ -36,7 +36,6 @@ import com.jme3.app.SimpleApplication;
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.util.SkyFactory;
|
import com.jme3.util.SkyFactory;
|
||||||
import com.jme3.util.android.AndroidSkyFactory;
|
|
||||||
|
|
||||||
public class TestSkyLoadingLagoon extends SimpleApplication {
|
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");
|
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);
|
rootNode.attachChild(sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import com.jme3.app.SimpleApplication;
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.util.SkyFactory;
|
import com.jme3.util.SkyFactory;
|
||||||
import com.jme3.util.android.AndroidSkyFactory;
|
|
||||||
|
|
||||||
public class TestSkyLoadingPrimitives extends SimpleApplication {
|
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 up = assetManager.loadTexture("Textures/Sky/Primitives/primitives_positive_y.png");
|
||||||
Texture down = assetManager.loadTexture("Textures/Sky/Primitives/primitives_negative_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);
|
rootNode.attachChild(sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,9 @@ public final class Bone implements Savable {
|
|||||||
* @param name Name to give to this bone
|
* @param name Name to give to this bone
|
||||||
*/
|
*/
|
||||||
public Bone(String name) {
|
public Bone(String name) {
|
||||||
|
if (name == null)
|
||||||
|
throw new IllegalArgumentException("Name cannot be null");
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
initialPos = new Vector3f();
|
initialPos = new Vector3f();
|
||||||
|
@ -210,7 +210,6 @@ public final class Skeleton implements Savable {
|
|||||||
return boneList[i];
|
return boneList[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import com.jme3.audio.AudioKey;
|
|||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import com.jme3.util.LittleEndien;
|
import com.jme3.util.LittleEndien;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -104,7 +105,6 @@ public class WAVLoader implements AssetLoader {
|
|||||||
if (remaining > 0){
|
if (remaining > 0){
|
||||||
in.skipBytes(remaining);
|
in.skipBytes(remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readDataChunkForBuffer(int len) throws IOException {
|
private void readDataChunkForBuffer(int len) throws IOException {
|
||||||
@ -123,8 +123,8 @@ public class WAVLoader implements AssetLoader {
|
|||||||
audioStream.updateData(in, duration);
|
audioStream.updateData(in, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object load(AssetInfo info) throws IOException {
|
private AudioData load(InputStream inputStream, boolean stream) throws IOException{
|
||||||
this.in = new LittleEndien(info.openStream());
|
this.in = new LittleEndien(inputStream);
|
||||||
|
|
||||||
int sig = in.readInt();
|
int sig = in.readInt();
|
||||||
if (sig != i_RIFF)
|
if (sig != i_RIFF)
|
||||||
@ -135,8 +135,7 @@ public class WAVLoader implements AssetLoader {
|
|||||||
if (in.readInt() != i_WAVE)
|
if (in.readInt() != i_WAVE)
|
||||||
throw new IOException("WAVE File does not contain audio");
|
throw new IOException("WAVE File does not contain audio");
|
||||||
|
|
||||||
readStream = ((AudioKey)info.getKey()).isStream();
|
readStream = stream;
|
||||||
|
|
||||||
if (readStream){
|
if (readStream){
|
||||||
audioStream = new AudioStream();
|
audioStream = new AudioStream();
|
||||||
audioData = audioStream;
|
audioData = audioStream;
|
||||||
@ -168,9 +167,25 @@ public class WAVLoader implements AssetLoader {
|
|||||||
if (skipped <= 0) {
|
if (skipped <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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) {
|
} else if (value < 0) {
|
||||||
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
|
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
|
||||||
|
int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, false);
|
||||||
invokeAnalogsAndActions(hash, -value, true);
|
invokeAnalogsAndActions(hash, -value, true);
|
||||||
axisValues.put(hash, -value);
|
axisValues.put(hash, -value);
|
||||||
|
axisValues.remove(otherHash);
|
||||||
} else {
|
} else {
|
||||||
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false);
|
int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false);
|
||||||
|
int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
|
||||||
invokeAnalogsAndActions(hash, value, true);
|
invokeAnalogsAndActions(hash, value, true);
|
||||||
axisValues.put(hash, value);
|
axisValues.put(hash, value);
|
||||||
|
axisValues.remove(otherHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +286,7 @@ public class Camera implements Savable, Cloneable {
|
|||||||
cam.viewMatrix = viewMatrix.clone();
|
cam.viewMatrix = viewMatrix.clone();
|
||||||
cam.projectionMatrix = projectionMatrix.clone();
|
cam.projectionMatrix = projectionMatrix.clone();
|
||||||
cam.viewProjectionMatrix = viewProjectionMatrix.clone();
|
cam.viewProjectionMatrix = viewProjectionMatrix.clone();
|
||||||
|
cam.guiBounding = (BoundingBox) guiBounding.clone();
|
||||||
|
|
||||||
cam.update();
|
cam.update();
|
||||||
|
|
||||||
@ -1227,6 +1228,7 @@ public class Camera implements Savable, Cloneable {
|
|||||||
*/
|
*/
|
||||||
public void setParallelProjection(final boolean value) {
|
public void setParallelProjection(final boolean value) {
|
||||||
this.parallelProjection = value;
|
this.parallelProjection = value;
|
||||||
|
onFrustumChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1530,8 +1530,10 @@ public class LwjglRenderer implements Renderer {
|
|||||||
|
|
||||||
public void setFrameBuffer(FrameBuffer fb) {
|
public void setFrameBuffer(FrameBuffer fb) {
|
||||||
if (lastFb == fb) {
|
if (lastFb == fb) {
|
||||||
|
if (fb == null || !fb.isUpdateNeeded()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// generate mipmaps for last FB if needed
|
// generate mipmaps for last FB if needed
|
||||||
if (lastFb != null) {
|
if (lastFb != null) {
|
||||||
|
@ -43,6 +43,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.opengl.OpenGLException;
|
import org.lwjgl.opengl.OpenGLException;
|
||||||
import org.lwjgl.opengl.Pbuffer;
|
import org.lwjgl.opengl.Pbuffer;
|
||||||
import org.lwjgl.opengl.PixelFormat;
|
import org.lwjgl.opengl.PixelFormat;
|
||||||
@ -68,6 +69,7 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
|
|||||||
settings.getDepthBits(),
|
settings.getDepthBits(),
|
||||||
settings.getStencilBits(),
|
settings.getStencilBits(),
|
||||||
settings.getSamples());
|
settings.getSamples());
|
||||||
|
|
||||||
width = settings.getWidth();
|
width = settings.getWidth();
|
||||||
height = settings.getHeight();
|
height = settings.getHeight();
|
||||||
try{
|
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 = new Pbuffer(width, height, pixelFormat, null, null, createContextAttribs());
|
||||||
// }
|
|
||||||
|
|
||||||
pbuffer.makeCurrent();
|
pbuffer.makeCurrent();
|
||||||
|
|
||||||
renderable.set(true);
|
renderable.set(true);
|
||||||
@ -141,9 +129,16 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
|
|||||||
assert checkGLError();
|
assert checkGLError();
|
||||||
|
|
||||||
renderer.onFrame();
|
renderer.onFrame();
|
||||||
|
|
||||||
|
int frameRate = settings.getFrameRate();
|
||||||
|
if (frameRate >= 1){
|
||||||
|
Display.sync(frameRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deinitInThread(){
|
protected void deinitInThread(){
|
||||||
|
renderable.set(false);
|
||||||
|
|
||||||
listener.destroy();
|
listener.destroy();
|
||||||
renderer.cleanup();
|
renderer.cleanup();
|
||||||
pbuffer.destroy();
|
pbuffer.destroy();
|
||||||
|
@ -66,9 +66,6 @@ public class TestNiftyGui extends SimpleApplication implements ScreenController
|
|||||||
audioRenderer,
|
audioRenderer,
|
||||||
guiViewPort);
|
guiViewPort);
|
||||||
nifty = niftyDisplay.getNifty();
|
nifty = niftyDisplay.getNifty();
|
||||||
|
|
||||||
URL url = Thread.currentThread().getContextClassLoader().getResource("jme3test/niftygui/hellojme.xml");
|
|
||||||
|
|
||||||
nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this);
|
nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this);
|
||||||
|
|
||||||
// attach the nifty display to the gui view port as a processor
|
// 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
|
// disable the fly cam
|
||||||
// flyCam.setEnabled(false);
|
// flyCam.setEnabled(false);
|
||||||
flyCam.setDragToRotate(true);
|
// flyCam.setDragToRotate(true);
|
||||||
|
inputManager.setCursorVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(Nifty nifty, Screen screen) {
|
public void bind(Nifty nifty, Screen screen) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user