PointSound java 3d

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PointSound java 3d

Davidave
Hey guys !  

I hope someone can help me to modify my PointSound in java3d. i have created a small scene in Java3D with one house. when i start my program im looking at the front of my house ! when i press a key the camera is moving towards the house.
what i want is:  the nearer i get the quieter should the music get. when im in front of the house the music should be turned off.

my house has the coordinates (0.0f , 0.0f , 6.0f)
when i run my programm the camera coordinates are (0f,0f,-4.5f)

this is my code for the pointSound


MediaContainer myWave = null;
                try {
                        myWave = new MediaContainer(new URL("file:C:/Users/David/Desktop/Castle/pte.wav"));
                } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        Point2f[] myAtten = {
           new Point2f( 0.0f, 0.0f ),
           new Point2f( 0.0f, 0.0f ),
           new Point2f( 0.0f, 0.0f )
        };
        PointSound mySound = new PointSound( );
        mySound.setSoundData( myWave );
        mySound.setEnable( true );
        mySound.setCapability(PointSound.ALLOW_ENABLE_READ);  
        mySound.setCapability(PointSound.ALLOW_ENABLE_WRITE);
        mySound.setInitialGain( 1.0f );
        mySound.setLoop(-1);  // Loop forever
        mySound.setPosition( new Point3f( -1.27f, -0.55f, -4f ) );
        mySound.setDistanceGain( myAtten );
        BoundingSphere myBounds = new BoundingSphere(
           new Point3d(), 1.0 );
        mySound.setSchedulingBounds( myBounds );
                        return mySound;




(i dont know what to do with the point2f[] )

sry for my bad english i h0pe you anderstand what i need =)

thanks in advance
david
Reply | Threaded
Open this post in threaded view
|

Re: PointSound java 3d

Davidave
edit*  mySound.setPosition( new Point3f( 0f, 0f, -4f ) )
Reply | Threaded
Open this post in threaded view
|

Re: PointSound java 3d

gouessej
Administrator
In reply to this post by Davidave
Hi

You should look at the documentation:
"accepting an array of Point2f for the distance attenuation values where each pair in the array contains a distance and a gain scale factor"

I assume that your gain scale factor should be negative in your case.
Julien Gouesse | Personal blog | Website