List of usage examples for javax.media.j3d PointSound PointSound
public PointSound(MediaContainer soundData, float initialGain, float posX, float posY, float posZ)
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);// www .java 2s . c om 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; }