* 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. 4
      engine/src/core/com/jme3/material/Material.java
  3. 6
      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 {
/**
* List of targets which this controller effects.
*/
// Mesh[] targets;
/**
* Skeleton object must contain corresponding data for the targets' weight buffers.
*/
Skeleton skeleton;
/** only used for backward compatibility */
@Deprecated
private SkeletonControl skeletonControl;
/**
* List of animations
*/
HashMap<String, BoneAnimation> animationMap;
/**
* Animation channels
*/
transient ArrayList<AnimChannel> channels = new ArrayList<AnimChannel>();
transient ArrayList<AnimEventListener> listeners = new ArrayList<AnimEventListener>();
private transient ArrayList<AnimChannel> channels = new ArrayList<AnimChannel>();
/**
* Create a new <code>AnimControl</code> that will animate the given skins
* 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.
* Animation event listeners
*/
@Deprecated
public AnimControl(Node model, Mesh[] meshes, Skeleton skeleton) {
super(model);
this.skeleton = skeleton;
skeletonControl = new SkeletonControl(meshes, this.skeleton);
reset();
}
private transient ArrayList<AnimEventListener> listeners = new ArrayList<AnimEventListener>();
/**
* 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) {
if (skeleton == null)
throw new IllegalArgumentException("skeleton cannot be null");
this.skeleton = skeleton;
reset();
}
@ -134,6 +123,8 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
clone.spatial = spatial;
clone.skeleton = new Skeleton(skeleton);
clone.channels = new ArrayList<AnimChannel>();
// animationMap is reference-copied, animation data should be shared
// to reduce memory usage.
return clone;
} catch (CloneNotSupportedException ex) {
throw new AssertionError();
@ -181,28 +172,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
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
* in the skeleton.
@ -253,17 +222,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
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.
* @param listener The listener to add.
@ -317,8 +275,10 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
//Backward compatibility.
if (skeletonControl != null) {
spatial.addControl(skeletonControl);
// once the skeleton control is added to the spatial,
// the AnimControl returns to "non-compatible" mode.
skeletonControl = null;
}
}
final void reset() {
@ -380,7 +340,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone
skeleton = (Skeleton) in.readSavable("skeleton", null);
animationMap = (HashMap<String, BoneAnimation>) in.readStringSavableMap("animations", null);
//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.
//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);
spatial.addControl(skeletonControl);
}
//------
}
}

@ -694,7 +694,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
if (name.equals("Default")) {
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() + "'");
}
@ -723,7 +723,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
if (!rendererCaps.containsAll(techDef.getRequiredCaps())) {
throw new UnsupportedOperationException("The explicitly chosen technique '" + name + "' on material '" + def.getName() + "'\n"
+ "requires caps " + techDef.getRequiredCaps() + " which are not"
+ "requires caps " + techDef.getRequiredCaps() + " which are not "
+ "supported by the video renderer");
}

@ -749,11 +749,9 @@ public class Mesh implements Savable, Cloneable {
// in.readStringSavableMap("buffers", null);
buffers = (IntMap<VertexBuffer>) in.readIntSavableMap("buffers", null);
Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
if(lodLevelsSavable!=null){
if (lodLevelsSavable != null) {
lodLevels = new VertexBuffer[lodLevelsSavable.length];
for (int i = 0; i < lodLevels.length; i++){
lodLevels[i] = (VertexBuffer) lodLevelsSavable[i];
}
System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
}
}

@ -51,16 +51,6 @@ public abstract class AbstractControl implements Control {
protected boolean enabled = true;
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(){
}

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

@ -51,10 +51,10 @@ public class TestAmbient extends AudioApp {
@Override
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);
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");
// float[] eax = new float[]
@ -69,8 +69,8 @@ public class TestAmbient extends AudioApp {
waves.setRefDistance(1);
nature.setVolume(3);
ar.playSourceInstance(waves);
ar.playSource(nature);
audioRenderer.playSourceInstance(waves);
audioRenderer.playSource(nature);
}
@Override

@ -52,10 +52,10 @@ public class TestDoppler extends AudioApp {
@Override
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.setLooping(true);
ar.playSource(ufo);
audioRenderer.playSource(ufo);
}
@Override

@ -47,20 +47,20 @@ public class TestOgg extends AudioApp {
@Override
public void initAudioApp(){
System.out.println("Playing without filter");
src = new AudioNode(manager, "Sound/Effects/Foot steps.ogg", true);
ar.playSource(src);
src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true);
audioRenderer.playSource(src);
}
@Override
public void updateAudioApp(float tpf){
if (src.getStatus() != AudioNode.Status.Playing){
ar.deleteAudioData(src.getAudioData());
audioRenderer.deleteAudioData(src.getAudioData());
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.setVolume(3);
ar.playSource(src);
audioRenderer.playSource(src);
}
}

@ -51,7 +51,7 @@ public class TestReverb extends AudioApp {
@Override
public void initAudioApp(){
src = new AudioNode(manager, "Sound/Effects/Bang.wav");
src = new AudioNode(assetManager, "Sound/Effects/Bang.wav");
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 }
@ -59,7 +59,7 @@ public class TestReverb extends AudioApp {
// ar.setEnvironment(new Environment(eax));
Environment env = Environment.Cavern;
ar.setEnvironment(env);
audioRenderer.setEnvironment(env);
}
@Override
@ -75,7 +75,7 @@ public class TestReverb extends AudioApp {
v.subtractLocal(20, 1, 20);
src.setLocalTranslation(v);
ar.playSourceInstance(src);
audioRenderer.playSourceInstance(src);
time = 0;
nextTime = FastMath.nextRandomFloat() * 2 + 0.5f;
}

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

Loading…
Cancel
Save