/** * This method clone the Track and search for the cloned counterpart of the * original audio node in the given cloned spatial. The spatial is assumed * to be the Spatial holding the AnimControl controlling the animation using * this Track. * * @param spatial the Spatial holding the AnimControl * @return the cloned Track with proper reference */ @Override public Track cloneForSpatial(Spatial spatial) { AudioTrack audioTrack = new AudioTrack(); audioTrack.length = this.length; audioTrack.startOffset = this.startOffset; //searching for the newly cloned AudioNode audioTrack.audio = findAudio(spatial); if (audioTrack.audio == null) { logger.log(Level.WARNING, "{0} was not found in {1} or is not bound to this track", new Object[]{audio.getName(), spatial.getName()}); audioTrack.audio = audio; } //setting user data on the new AudioNode and marking it with a reference to the cloned Track. setUserData(audioTrack); return audioTrack; }
/** * Creates an AudioTrack * * @param audio the AudioNode * @param length the length of the track (usually the length of the * animation you want to add the track to) */ public AudioTrack(AudioNode audio, float length) { this.audio = audio; this.length = length; setUserData(this); }
/** * Clone this track * * @return */ @Override public Track clone() { return new AudioTrack(audio, length, startOffset); }
/** * recursive function responsible for finding the newly cloned AudioNode * * @param spat * @return */ private AudioNode findAudio(Spatial spat) { if (spat instanceof AudioNode) { //spat is an AudioNode AudioNode em = (AudioNode) spat; //getting the UserData TrackInfo so check if it should be attached to this Track TrackInfo t = (TrackInfo) em.getUserData("TrackInfo"); if (t != null && t.getTracks().contains(this)) { return em; } return null; } else if (spat instanceof Node) { for (Spatial child : ((Node) spat).getChildren()) { AudioNode em = findAudio(child); if (em != null) { return em; } } } return null; }
/** * sets the audio node to be used for this track * * @param audio */ public void setAudio(AudioNode audio) { if (this.audio != null) { TrackInfo data = (TrackInfo) audio.getUserData("TrackInfo"); data.getTracks().remove(this); } this.audio = audio; setUserData(this); }
/** * Clone this track * * @return */ @Override public Track clone() { return new AudioTrack(audio, length, startOffset); }
/** * recursive function responsible for finding the newly cloned AudioNode * * @param spat * @return */ private AudioNode findAudio(Spatial spat) { if (spat instanceof AudioNode) { //spat is an AudioNode AudioNode em = (AudioNode) spat; //getting the UserData TrackInfo so check if it should be attached to this Track TrackInfo t = (TrackInfo) em.getUserData("TrackInfo"); if (t != null && t.getTracks().contains(this)) { return em; } return null; } else if (spat instanceof Node) { for (Spatial child : ((Node) spat).getChildren()) { AudioNode em = findAudio(child); if (em != null) { return em; } } } return null; }
/** * This method clone the Track and search for the cloned counterpart of the * original audio node in the given cloned spatial. The spatial is assumed * to be the Spatial holding the AnimControl controling the animation using * this Track. * * @param spatial the Spatial holding the AnimControl * @return the cloned Track with proper reference */ public Track cloneForSpatial(Spatial spatial) { AudioTrack audioTrack = new AudioTrack(); audioTrack.length = this.length; audioTrack.startOffset = this.startOffset; //searching for the newly cloned AudioNode audioTrack.audio = findAudio(spatial); if (audioTrack.audio == null) { logger.log(Level.WARNING, "{0} was not found in {1} or is not bound to this track", new Object[]{audio.getName(), spatial.getName()}); audioTrack.audio = audio; } //setting user data on the new AudioNode and marking it with a reference to the cloned Track. setUserData(audioTrack); return audioTrack; }
/** * Creates an AudioTrack * * @param audio the AudioNode * @param length the length of the track (usually the length of the * animation you want to add the track to) */ public AudioTrack(AudioNode audio, float length) { this.audio = audio; this.length = length; setUserData(this); }
/** * Clone this track * * @return */ @Override public Track clone() { return new AudioTrack(audio, length, startOffset); }
/** * recursive function responsible for finding the newly cloned AudioNode * * @param spat * @return */ private AudioNode findAudio(Spatial spat) { if (spat instanceof AudioNode) { //spat is an AudioNode AudioNode em = (AudioNode) spat; //getting the UserData TrackInfo so check if it should be attached to this Track TrackInfo t = (TrackInfo) em.getUserData("TrackInfo"); if (t != null && t.getTracks().contains(this)) { return em; } return null; } else if (spat instanceof Node) { for (Spatial child : ((Node) spat).getChildren()) { AudioNode em = findAudio(child); if (em != null) { return em; } } } return null; }
/** * This method clone the Track and search for the cloned counterpart of the * original audio node in the given cloned spatial. The spatial is assumed * to be the Spatial holding the AnimControl controlling the animation using * this Track. * * @param spatial the Spatial holding the AnimControl * @return the cloned Track with proper reference */ @Override public Track cloneForSpatial(Spatial spatial) { AudioTrack audioTrack = new AudioTrack(); audioTrack.length = this.length; audioTrack.startOffset = this.startOffset; //searching for the newly cloned AudioNode audioTrack.audio = findAudio(spatial); if (audioTrack.audio == null) { logger.log(Level.WARNING, "{0} was not found in {1} or is not bound to this track", new Object[]{audio.getName(), spatial.getName()}); audioTrack.audio = audio; } //setting user data on the new AudioNode and marking it with a reference to the cloned Track. setUserData(audioTrack); return audioTrack; }
/** * Creates an AudioTrack * * @param audio the AudioNode * @param length the length of the track (usually the length of the * animation you want to add the track to) */ public AudioTrack(AudioNode audio, float length) { this.audio = audio; this.length = length; setUserData(this); }
/** * sets the audio node to be used for this track * * @param audio */ public void setAudio(AudioNode audio) { if (this.audio != null) { TrackInfo data = (TrackInfo) audio.getUserData("TrackInfo"); data.getTracks().remove(this); } this.audio = audio; setUserData(this); }
/** * sets the audio node to be used for this track * * @param audio */ public void setAudio(AudioNode audio) { if (this.audio != null) { TrackInfo data = (TrackInfo) audio.getUserData("TrackInfo"); data.getTracks().remove(this); } this.audio = audio; setUserData(this); }