* Removed deprecated methods from AnimControl

* Fixed bug where AnimControl would crash on setSpatial(null)
 * Mesh will deserialize lod levels list using arraycopy now
 * Renamed shorthands "ar" and "manager" to their Application equivalents in AudioApp 

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7287 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 9cc223c507
commit 8aa7468370
  1. 85
      engine/src/core/com/jme3/animation/AnimControl.java
  2. 2
      engine/src/core/com/jme3/material/Material.java
  3. 4
      engine/src/core/com/jme3/scene/Mesh.java
  4. 10
      engine/src/core/com/jme3/scene/control/AbstractControl.java
  5. 14
      engine/src/test/jme3test/audio/AudioApp.java
  6. 8
      engine/src/test/jme3test/audio/TestAmbient.java
  7. 4
      engine/src/test/jme3test/audio/TestDoppler.java
  8. 10
      engine/src/test/jme3test/audio/TestOgg.java
  9. 6
      engine/src/test/jme3test/audio/TestReverb.java
  10. 4
      engine/src/test/jme3test/audio/TestWav.java

@ -70,52 +70,41 @@ import java.util.HashMap;
*/ */
public final class AnimControl extends AbstractControl implements Savable, Cloneable { public final class AnimControl extends AbstractControl implements Savable, Cloneable {
/**
* List of targets which this controller effects.
*/
// Mesh[] targets;
/** /**
* Skeleton object must contain corresponding data for the targets' weight buffers. * Skeleton object must contain corresponding data for the targets' weight buffers.
*/ */
Skeleton skeleton; Skeleton skeleton;
/** only used for backward compatibility */ /** only used for backward compatibility */
@Deprecated @Deprecated
private SkeletonControl skeletonControl; private SkeletonControl skeletonControl;
/** /**
* List of animations * List of animations
*/ */
HashMap<String, BoneAnimation> animationMap; HashMap<String, BoneAnimation> animationMap;
/** /**
* Animation channels * Animation channels
*/ */
transient ArrayList<AnimChannel> channels = new ArrayList<AnimChannel>(); private transient ArrayList<AnimChannel> channels = new ArrayList<AnimChannel>();
transient ArrayList<AnimEventListener> listeners = new ArrayList<AnimEventListener>();
/** /**
* Create a new <code>AnimControl</code> that will animate the given skins * Animation event listeners
* using the skeleton and provided animations.
*
* @param model The root node of all the skins specified in
* <code>meshes</code> argument.
* @param meshes The skins, or meshes, to animate. Should have
* properly set BoneIndex and BoneWeight buffers.
* @param skeleton The skeleton structure represents a bone hierarchy
* to be animated.
* @deprecated AnimControl doesnt' hande the skinning anymore, use AnimControl(Skeleton skeleton);
* Then create a SkeletonControl(Node model, Mesh[] meshes, Skeleton skeleton);
* and add it to the spatial.
*/ */
@Deprecated private transient ArrayList<AnimEventListener> listeners = new ArrayList<AnimEventListener>();
public AnimControl(Node model, Mesh[] meshes, Skeleton skeleton) {
super(model);
this.skeleton = skeleton;
skeletonControl = new SkeletonControl(meshes, this.skeleton);
reset();
}
/**
* Creates a new animation control for the given skeleton.
* The method {@link AnimControl#setAnimations(java.util.HashMap) }
* must be called after initialization in order for this class to be useful.
*
* @param skeleton The skeleton to animate
*/
public AnimControl(Skeleton skeleton) { public AnimControl(Skeleton skeleton) {
if (skeleton == null)
throw new IllegalArgumentException("skeleton cannot be null");
this.skeleton = skeleton; this.skeleton = skeleton;
reset(); reset();
} }
@ -134,6 +123,8 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
clone.spatial = spatial; clone.spatial = spatial;
clone.skeleton = new Skeleton(skeleton); clone.skeleton = new Skeleton(skeleton);
clone.channels = new ArrayList<AnimChannel>(); clone.channels = new ArrayList<AnimChannel>();
// animationMap is reference-copied, animation data should be shared
// to reduce memory usage.
return clone; return clone;
} catch (CloneNotSupportedException ex) { } catch (CloneNotSupportedException ex) {
throw new AssertionError(); throw new AssertionError();
@ -181,28 +172,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
animationMap.remove(anim.getName()); animationMap.remove(anim.getName());
} }
/**
*
* @param boneName the name of the bone
* @return the node attached to this bone
* @deprecated use SkeletonControl.getAttachementNode instead.
*/
@Deprecated
public Node getAttachmentsNode(String boneName) {
Bone b = skeleton.getBone(boneName);
if (b == null) {
throw new IllegalArgumentException("Given bone name does not exist "
+ "in the skeleton.");
}
Node n = b.getAttachmentsNode();
if (spatial != null) {
Node model = (Node) spatial;
model.attachChild(n);
}
return n;
}
/** /**
* Create a new animation channel, by default assigned to all bones * Create a new animation channel, by default assigned to all bones
* in the skeleton. * in the skeleton.
@ -253,17 +222,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
return skeleton; return skeleton;
} }
/**
* @return The targets, or skins, being influenced by this
* <code>AnimControl</code>.
* @deprecated use SkeletonControl.getTargets() instead
* get the SkeletonControl doing spatial.getControl(SkeletonControl.class);
*/
@Deprecated
public Mesh[] getTargets() {
return skeletonControl.getTargets();
}
/** /**
* Adds a new listener to receive animation related events. * Adds a new listener to receive animation related events.
* @param listener The listener to add. * @param listener The listener to add.
@ -317,8 +275,10 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
//Backward compatibility. //Backward compatibility.
if (skeletonControl != null) { if (skeletonControl != null) {
spatial.addControl(skeletonControl); spatial.addControl(skeletonControl);
// once the skeleton control is added to the spatial,
// the AnimControl returns to "non-compatible" mode.
skeletonControl = null;
} }
} }
final void reset() { final void reset() {
@ -380,7 +340,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
skeleton = (Skeleton) in.readSavable("skeleton", null); skeleton = (Skeleton) in.readSavable("skeleton", null);
animationMap = (HashMap<String, BoneAnimation>) in.readStringSavableMap("animations", null); animationMap = (HashMap<String, BoneAnimation>) in.readStringSavableMap("animations", null);
//changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split
//if we find a target mesh array the AnimControl creates the SkeletonControl for old files and add it to the spatial. //if we find a target mesh array the AnimControl creates the SkeletonControl for old files and add it to the spatial.
//When backward compatibility won't be needed anymore this can deleted //When backward compatibility won't be needed anymore this can deleted
@ -392,7 +351,5 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
skeletonControl = new SkeletonControl(tg, skeleton); skeletonControl = new SkeletonControl(tg, skeleton);
spatial.addControl(skeletonControl); spatial.addControl(skeletonControl);
} }
//------
} }
} }

@ -694,7 +694,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
if (name.equals("Default")) { if (name.equals("Default")) {
List<TechniqueDef> techDefs = def.getDefaultTechniques(); List<TechniqueDef> techDefs = def.getDefaultTechniques();
if (techDefs == null || techDefs.size() == 0) { if (techDefs == null || techDefs.isEmpty()) {
throw new IllegalStateException("No default techniques are available on material '" + def.getName() + "'"); throw new IllegalStateException("No default techniques are available on material '" + def.getName() + "'");
} }

@ -751,9 +751,7 @@ public class Mesh implements Savable, Cloneable {
Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null); Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
if (lodLevelsSavable != null) { if (lodLevelsSavable != null) {
lodLevels = new VertexBuffer[lodLevelsSavable.length]; lodLevels = new VertexBuffer[lodLevelsSavable.length];
for (int i = 0; i < lodLevels.length; i++){ System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
lodLevels[i] = (VertexBuffer) lodLevelsSavable[i];
}
} }
} }

@ -51,16 +51,6 @@ public abstract class AbstractControl implements Control {
protected boolean enabled = true; protected boolean enabled = true;
protected Spatial spatial; protected Spatial spatial;
/**
* @param spatial
* @deprecated The spatial parameter is passed in {@link AbstractControl#setSpatial(com.jme3.scene.Spatial) }
* automatically.
*/
@Deprecated
public AbstractControl(Spatial spatial){
this.spatial = spatial;
}
public AbstractControl(){ public AbstractControl(){
} }

@ -43,20 +43,20 @@ public class AudioApp {
private static final float UPDATE_RATE = 0.01f; private static final float UPDATE_RATE = 0.01f;
protected AssetManager manager; protected AssetManager assetManager;
protected Listener listener; protected Listener listener;
protected AudioRenderer ar; protected AudioRenderer audioRenderer;
public AudioApp(){ public AudioApp(){
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);
settings.setRenderer(null); // force dummy renderer (?) settings.setRenderer(null); // force dummy renderer (?)
settings.setAudioRenderer(AppSettings.LWJGL_OPENAL); settings.setAudioRenderer(AppSettings.LWJGL_OPENAL);
ar = JmeSystem.newAudioRenderer(settings); audioRenderer = JmeSystem.newAudioRenderer(settings);
ar.initialize(); audioRenderer.initialize();
manager = new DesktopAssetManager(true); assetManager = new DesktopAssetManager(true);
listener = new Listener(); listener = new Listener();
ar.setListener(listener); audioRenderer.setListener(listener);
} }
public void initAudioApp(){ public void initAudioApp(){
@ -70,7 +70,7 @@ public class AudioApp {
while (true){ while (true){
updateAudioApp(UPDATE_RATE); updateAudioApp(UPDATE_RATE);
ar.update(UPDATE_RATE); audioRenderer.update(UPDATE_RATE);
try{ try{
Thread.sleep((int) (UPDATE_RATE * 1000f)); Thread.sleep((int) (UPDATE_RATE * 1000f));

@ -51,10 +51,10 @@ public class TestAmbient extends AudioApp {
@Override @Override
public void initAudioApp(){ public void initAudioApp(){
waves = new AudioNode(manager, "Sound/Environment/Ocean Waves.ogg", false); waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
waves.setPositional(true); waves.setPositional(true);
nature = new AudioNode(manager, "Sound/Environment/Nature.ogg", true); nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
// river = new AudioSource(manager, "sounds/river.ogg"); // river = new AudioSource(manager, "sounds/river.ogg");
// float[] eax = new float[] // float[] eax = new float[]
@ -69,8 +69,8 @@ public class TestAmbient extends AudioApp {
waves.setRefDistance(1); waves.setRefDistance(1);
nature.setVolume(3); nature.setVolume(3);
ar.playSourceInstance(waves); audioRenderer.playSourceInstance(waves);
ar.playSource(nature); audioRenderer.playSource(nature);
} }
@Override @Override

@ -52,10 +52,10 @@ public class TestDoppler extends AudioApp {
@Override @Override
public void initAudioApp(){ public void initAudioApp(){
ufo = new AudioNode(manager, "Sound/Effects/Beep.ogg", false); ufo = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", false);
ufo.setPositional(true); ufo.setPositional(true);
ufo.setLooping(true); ufo.setLooping(true);
ar.playSource(ufo); audioRenderer.playSource(ufo);
} }
@Override @Override

@ -47,20 +47,20 @@ public class TestOgg extends AudioApp {
@Override @Override
public void initAudioApp(){ public void initAudioApp(){
System.out.println("Playing without filter"); System.out.println("Playing without filter");
src = new AudioNode(manager, "Sound/Effects/Foot steps.ogg", true); src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
ar.playSource(src); audioRenderer.playSource(src);
} }
@Override @Override
public void updateAudioApp(float tpf){ public void updateAudioApp(float tpf){
if (src.getStatus() != AudioNode.Status.Playing){ if (src.getStatus() != AudioNode.Status.Playing){
ar.deleteAudioData(src.getAudioData()); audioRenderer.deleteAudioData(src.getAudioData());
System.out.println("Playing with low pass filter"); System.out.println("Playing with low pass filter");
src = new AudioNode(manager, "Sound/Effects/Foot steps.ogg", true); src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
src.setDryFilter(new LowPassFilter(1f, .1f)); src.setDryFilter(new LowPassFilter(1f, .1f));
src.setVolume(3); src.setVolume(3);
ar.playSource(src); audioRenderer.playSource(src);
} }
} }

@ -51,7 +51,7 @@ public class TestReverb extends AudioApp {
@Override @Override
public void initAudioApp(){ public void initAudioApp(){
src = new AudioNode(manager, "Sound/Effects/Bang.wav"); src = new AudioNode(assetManager, "Sound/Effects/Bang.wav");
float[] eax = new float[] float[] eax = new float[]
{15, 38.0f, 0.300f, -1000, -3300, 0, 1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f,0.00f,0.00f, -229, 0.088f, 0.00f,0.00f,0.00f, 0.125f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } {15, 38.0f, 0.300f, -1000, -3300, 0, 1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f,0.00f,0.00f, -229, 0.088f, 0.00f,0.00f,0.00f, 0.125f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f }
@ -59,7 +59,7 @@ public class TestReverb extends AudioApp {
// ar.setEnvironment(new Environment(eax)); // ar.setEnvironment(new Environment(eax));
Environment env = Environment.Cavern; Environment env = Environment.Cavern;
ar.setEnvironment(env); audioRenderer.setEnvironment(env);
} }
@Override @Override
@ -75,7 +75,7 @@ public class TestReverb extends AudioApp {
v.subtractLocal(20, 1, 20); v.subtractLocal(20, 1, 20);
src.setLocalTranslation(v); src.setLocalTranslation(v);
ar.playSourceInstance(src); audioRenderer.playSourceInstance(src);
time = 0; time = 0;
nextTime = FastMath.nextRandomFloat() * 2 + 0.5f; nextTime = FastMath.nextRandomFloat() * 2 + 0.5f;
} }

@ -55,7 +55,7 @@ public class TestWav extends AudioApp {
public void updateAudioApp(float tpf){ public void updateAudioApp(float tpf){
time += tpf; time += tpf;
if (time > .1f){ if (time > .1f){
ar.playSourceInstance(src); audioRenderer.playSourceInstance(src);
time = 0; time = 0;
} }
@ -63,7 +63,7 @@ public class TestWav extends AudioApp {
@Override @Override
public void initAudioApp(){ public void initAudioApp(){
src = new AudioNode(manager, "Sound/Effects/Gun.wav", false); src = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
src.setLooping(false); src.setLooping(false);
} }

Loading…
Cancel
Save