/** * 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; }
/** * 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; }
/** * 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; }
@Override public void runCommand(Application app) { if (audioNode.getParent() == null) { System.out.println("attach " + audioNode.getName() + " to " + root); root.attachChild(audioNode); } if (sphereNode == null) { sphereNode = new Node(); Geometry geo = SpatialFactory.createSphere(0.2f, ColorRGBA.Blue.clone().set( ColorRGBA.Blue.r, ColorRGBA.Blue.r, ColorRGBA.Blue.r, 0.5f), true); sphereNode.attachChild(geo); sphereNode.addControl(new RemoveSpatialTimerControl(2f)); } RemoveSpatialTimerControl rstc = sphereNode.getControl(RemoveSpatialTimerControl.class); rstc.reset(); root.attachChild(sphereNode); System.out.println("Play audio!!"); //audioBuffer.resetObject(); audioNode.setVolume(0.5f); audioNode.play(); }