EffectTrack and AudioTrack can now porperly update their reference to the Spatial they are using upon loading. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9634 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
ae3cc96caa
commit
3bd77d3048
@ -0,0 +1,40 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.animation; |
||||
|
||||
import com.jme3.scene.Spatial; |
||||
|
||||
/** |
||||
* An interface that allow to clone a Track for a given Spatial. |
||||
* The spatial fed to the method is the Spatial holding the AnimControl controling the Animation using this track. |
||||
* |
||||
* Implement this interface only if you make your own Savable Track and that the track has a direct reference to a Spatial in the scene graph. |
||||
* This Spatial is assumed to be a child of the spatial holding the AnimControl. |
||||
* |
||||
* |
||||
* @author Nehon |
||||
*/ |
||||
public interface ClonableTrack extends Track { |
||||
|
||||
/** |
||||
* Allows to clone the track for a given Spatial. |
||||
* The spatial fed to the method is the Spatial holding the AnimControl controling the Animation using this track. |
||||
* This method will be called during the loading process of a j3o model by the assetManager. |
||||
* The assetManager keeps the original model in cache and returns a clone of the model. |
||||
* |
||||
* This method prupose is to find the cloned reference of the original spatial which it refers to in the cloned model. |
||||
* |
||||
* See EffectTrack for a proper implementation. |
||||
* |
||||
* @param spatial the spatial holding the AnimControl |
||||
* @return the cloned Track |
||||
*/ |
||||
public Track cloneForSpatial(Spatial spatial); |
||||
|
||||
/** |
||||
* Method responsible of cleaning UserData on referenced Spatials when the Track is deleted |
||||
*/ |
||||
public void cleanUp(); |
||||
} |
@ -0,0 +1,48 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.animation; |
||||
|
||||
import com.jme3.export.InputCapsule; |
||||
import com.jme3.export.JmeExporter; |
||||
import com.jme3.export.JmeImporter; |
||||
import com.jme3.export.OutputCapsule; |
||||
import com.jme3.export.Savable; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
|
||||
/** |
||||
* This class is intended as a UserData added to a Spatial that is referenced by a Track. |
||||
* (ParticleEmitter for EffectTrack and AudioNode for AudioTrack) |
||||
* It holds the list of tracks that are directly referencing the Spatial. |
||||
* |
||||
* This is used when loading a Track to find the cloned reference of a Spatial in the cloned model returned by the assetManager. |
||||
* |
||||
* @author Nehon |
||||
*/ |
||||
public class TrackInfo implements Savable { |
||||
|
||||
ArrayList<Track> tracks = new ArrayList<Track>(); |
||||
|
||||
public TrackInfo() { |
||||
} |
||||
|
||||
public void write(JmeExporter ex) throws IOException { |
||||
OutputCapsule c = ex.getCapsule(this); |
||||
c.writeSavableArrayList(tracks, "tracks", null); |
||||
} |
||||
|
||||
public void read(JmeImporter im) throws IOException { |
||||
InputCapsule c = im.getCapsule(this); |
||||
tracks = c.readSavableArrayList("tracks", null); |
||||
} |
||||
|
||||
public ArrayList<Track> getTracks() { |
||||
return tracks; |
||||
} |
||||
|
||||
public void addTrack(Track track) { |
||||
tracks.add(track); |
||||
} |
||||
} |
Loading…
Reference in new issue