* Mesh.getTriangle() now supports 32bit index buffers and no index buffers

* Fix small logging issue in InputManager
 * Added stream-cache feature to streaming audio
 * Additional javadoc

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7515 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 14 years ago
parent cbefb99eed
commit 3a938b7dc9
  1. 5
      engine/src/core/com/jme3/audio/ALObject.java
  2. 4
      engine/src/core/com/jme3/audio/AudioBuffer.java
  3. 2
      engine/src/core/com/jme3/audio/AudioData.java
  4. 45
      engine/src/core/com/jme3/audio/AudioKey.java
  5. 4
      engine/src/core/com/jme3/audio/AudioNode.java
  6. 7
      engine/src/core/com/jme3/audio/AudioStream.java
  7. 2
      engine/src/core/com/jme3/input/InputManager.java
  8. 30
      engine/src/core/com/jme3/scene/Mesh.java
  9. 7
      engine/src/core/com/jme3/scene/mesh/WrappedIndexBuffer.java

@ -32,6 +32,11 @@
package com.jme3.audio;
/**
* Used for managing AL (Audio Library) objects.
*
* @author Kirill Vainer
*/
public abstract class ALObject {
protected int id = -1;

@ -38,10 +38,10 @@ import java.nio.ByteBuffer;
/**
* An <code>AudioBuffer</code> is an implementation of AudioData
* where the audio is buffered (stored in memory). All parts of it
* are accessable at any time. <br/>
* are accessible at any time. <br/>
* AudioBuffers are useful for short sounds, like effects, etc.
*
* @author Kirill
* @author Kirill Vainer
*/
public class AudioBuffer extends AudioData {

@ -38,7 +38,7 @@ package com.jme3.audio;
* are to be stored entirely in memory, while long audio files (music) is
* streamed from the hard drive as it is played.
*
* @author Kirill
* @author Kirill Vainer
*/
public abstract class AudioData extends ALObject {

@ -42,11 +42,28 @@ import java.io.IOException;
/**
* <code>AudioKey</code> is extending AssetKey by holding stream flag.
*
* @author Kirill
* @author Kirill Vainer
*/
public class AudioKey extends AssetKey<AudioData> {
private boolean stream;
private boolean streamCache;
/**
* Create a new AudioKey.
*
* @param name Name of the asset
* @param stream If true, the audio will be streamed from harddrive,
* otherwise it will be buffered entirely and then played.
* @param streamCache If stream is true, then this specifies if
* the stream cache is used. When enabled, the audio stream will
* be read entirely but not decoded, allowing features such as
* seeking, determining duration and looping.
*/
public AudioKey(String name, boolean stream, boolean streamCache){
this(name, stream);
this.streamCache = streamCache;
}
/**
* Create a new AudioKey
@ -70,15 +87,35 @@ public class AudioKey extends AssetKey<AudioData> {
@Override
public String toString(){
return name + (stream ? "/S" : "");
return name + (stream ?
(streamCache ?
" (Stream/Cache)" :
" (Stream)") :
" (Buffer)");
}
/**
* @return True if the loaded audio should be a {@link AudioStream} or
* false if it should be a {@link AudioBuffer}.
*/
public boolean isStream() {
return stream;
}
/**
* Specifies if the stream cache is used.
*
* When enabled, the audio stream will
* be read entirely but not decoded, allowing features such as
* seeking, looping and determining duration.
*/
public boolean useStreamCache(){
return streamCache;
}
@Override
public boolean shouldCache(){
return !stream;
return !stream && !streamCache;
}
@Override
@ -86,6 +123,7 @@ public class AudioKey extends AssetKey<AudioData> {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write(stream, "do_stream", false);
oc.write(streamCache, "use_stream_cache", false);
}
@Override
@ -93,6 +131,7 @@ public class AudioKey extends AssetKey<AudioData> {
super.read(im);
InputCapsule ic = im.getCapsule(this);
stream = ic.readBoolean("do_stream", false);
streamCache = ic.readBoolean("use_stream_cache", false);
}
}

@ -428,10 +428,6 @@ public class AudioNode extends Node {
* @see AudioNode#setDryFilter(com.jme3.audio.Filter)
*/
public void setReverbFilter(Filter reverbFilter) {
if (this.reverbFilter != null) {
throw new IllegalStateException("Filter already set");
}
this.reverbFilter = reverbFilter;
if (channel >= 0)
renderer.updateSourceParam(this, AudioParam.ReverbFilter);

@ -47,9 +47,9 @@ import java.io.InputStream;
public class AudioStream extends AudioData implements Closeable{
protected InputStream in;
private float duration = -1f;
private boolean open = false;
private int[] ids;
protected float duration = -1f;
protected boolean open = false;
protected int[] ids;
public AudioStream(){
}
@ -104,6 +104,7 @@ public class AudioStream extends AudioData implements Closeable{
throw new RuntimeException("Don't use getId() on streams");
}
@Override
public void setId(int id){
throw new RuntimeException("Don't use setId() on streams");
}

@ -434,7 +434,7 @@ public class InputManager implements RawInputListener {
names.add(mapping);
mapping.triggers.add(hash);
} else {
logger.log(Level.WARNING, "Attempted to add mapping '{0}' twice to trigger.", mappingName);
logger.log(Level.WARNING, "Attempted to add mapping \"{0}\" twice to trigger.", mappingName);
}
}
}

@ -51,6 +51,8 @@ import com.jme3.math.Triangle;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.VertexBuffer.*;
import com.jme3.scene.mesh.VirtualIndexBuffer;
import com.jme3.scene.mesh.WrappedIndexBuffer;
import com.jme3.util.BufferUtils;
import com.jme3.util.IntMap;
import com.jme3.util.IntMap.Entry;
@ -455,25 +457,27 @@ public class Mesh implements Savable, Cloneable {
public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3){
VertexBuffer pb = getBuffer(Type.Position);
VertexBuffer ib = getBuffer(Type.Index);
IndexBuffer ib = getIndexBuffer();
if (ib == null){
ib = new VirtualIndexBuffer(vertCount, mode);
}else if (mode != Mode.Triangles){
ib = new WrappedIndexBuffer(this);
}
if (pb.getFormat() == Format.Float){
FloatBuffer fpb = (FloatBuffer) pb.getData();
if (ib.getFormat() == Format.UnsignedShort){
// accepted format for buffers
ShortBuffer sib = (ShortBuffer) ib.getData();
// aquire triangle's vertex indices
int vertIndex = index * 3;
int vert1 = ib.get(vertIndex);
int vert2 = ib.get(vertIndex+1);
int vert3 = ib.get(vertIndex+2);
// aquire triangle's vertex indices
int vertIndex = index * 3;
int vert1 = sib.get(vertIndex);
int vert2 = sib.get(vertIndex+1);
int vert3 = sib.get(vertIndex+2);
BufferUtils.populateFromBuffer(v1, fpb, vert1);
BufferUtils.populateFromBuffer(v2, fpb, vert2);
BufferUtils.populateFromBuffer(v3, fpb, vert3);
BufferUtils.populateFromBuffer(v1, fpb, vert1);
BufferUtils.populateFromBuffer(v2, fpb, vert2);
BufferUtils.populateFromBuffer(v3, fpb, vert3);
}
}
}

@ -8,6 +8,13 @@ import java.nio.Buffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
/**
* <code>WrappedIndexBuffer</code> converts from one representation of mesh
* data to another. For example it can be used to read TriangleStrip data
* as if it was in Triangle format.
*
* @author Kirill Vainer
*/
public class WrappedIndexBuffer extends VirtualIndexBuffer {
private final IndexBuffer ib;

Loading…
Cancel
Save