List of usage examples for javax.media.j3d BackgroundSound BackgroundSound
public BackgroundSound(MediaContainer soundData, float initialGain)
From source file:SimpleSounds.java
/** * This adds a continuous background sound to the branch group. * //from ww w .j a v a 2s . c om * @param b * BranchGroup to add the sound to. * @param soundFile * String that is the name of the sound file. */ protected void addBackgroundSound(BranchGroup b, String soundFile) { //Create a media container to load the file MediaContainer droneContainer = new MediaContainer(soundFile); //Create the background sound from the media container BackgroundSound drone = new BackgroundSound(droneContainer, 1.0f); //Activate the sound drone.setSchedulingBounds(bounds); drone.setEnable(true); //Set the sound to loop forever drone.setLoop(BackgroundSound.INFINITE_LOOPS); //Add it to the group b.addChild(drone); }
From source file:KeyNavigateTest.java
public Group createObject(Appearance app, Vector3d position, Vector3d scale, String szTextureFile, String szSoundFile, String szCollisionSound) { m_TransformGroup = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setScale(scale);//from w ww .j av a 2s. c o m t3d.setTranslation(position); m_TransformGroup.setTransform(t3d); m_BehaviorTransformGroup = new TransformGroup(); if ((m_nFlags & GEOMETRY) == GEOMETRY) m_BehaviorTransformGroup .addChild(createGeometryGroup(app, position, scale, szTextureFile, szSoundFile)); if ((m_nFlags & SOUND) == SOUND) { MediaContainer media = loadSoundFile(szSoundFile); PointSound pointSound = new PointSound(media, getSoundInitialGain(false), 0, 0, 0); setSoundAttributes(pointSound, false); m_BehaviorTransformGroup.addChild(pointSound); } if ((m_nFlags & COLLISION) == COLLISION) { m_BehaviorTransformGroup.setCapability(Node.ENABLE_COLLISION_REPORTING); m_BehaviorTransformGroup.setCollidable(true); m_BehaviorTransformGroup.setCollisionBounds(getGeometryBounds()); if ((m_nFlags & COLLISION_SOUND) == COLLISION_SOUND) { MediaContainer collideMedia = loadSoundFile(szCollisionSound); m_CollideSound = new BackgroundSound(collideMedia, 1); setSoundAttributes(m_CollideSound, true); m_TransformGroup.addChild(m_CollideSound); } CollisionBehavior collision = new CollisionBehavior(m_BehaviorTransformGroup, this); collision.setSchedulingBounds(getGeometryBounds()); m_BehaviorTransformGroup.addChild(collision); } m_TransformGroup.addChild(m_BehaviorTransformGroup); m_ParentGroup.addChild(m_TransformGroup); return m_BehaviorTransformGroup; }