Java Reference
In-Depth Information
Figure 4. Code segment and screen capture for MultiViewApp.java
1.
public TransformGroup createViewPlatform(Canvas3D canvas3D, int mode)
2.
{
3.
Transform3D transform3D = vpTransform3D(mode);
4.
ViewPlatform viewPlatform = new ViewPlatform();
5.
viewPlatform.setActivationRadius(10.0f);
6.
TransformGroup objTransform = new TransformGroup(transform3D);
7.
objTransform.addChild(viewPlatform);
8.
9.
// call method in PointSoundScape; add a colored cube and a footsteps PointSound as avatar
10.
if (mode == 0) myWorld.addAvatar(objTransform);
11.
12.
View view = new View();
13.
view.attachViewPlatform(viewPlatform);
14.
view.addCanvas3D(canvas3D);
15.
view.setPhysicalBody(new PhysicalBody());
16.
PhysicalEnvironment physicalEnvironment = new PhysicalEnvironment();
17.
view.setPhysicalEnvironment(physicalEnvironment);
18.
19.
if(mode == 0) { // Initializes sound
20.
JavaSoundMixer javaSoundMixer = new JavaSoundMixer(physicalEnvironment);
21.
javaSoundMixer.initialize(); }
22.
23.
return objTransform;
24. }
Figure 5 shows the code segment for PointSoundScape.java, where two methods, addSound
and addAvatar, are provided to add stationary PointSound sources and a Soundscape are
added to the scene graph. Specifically, addAvatar adds a PointSound to simulate footsteps
at the current position, while addSound adds two other PointSound sources.
Lines 6 and 7 of addSound specify the sound files to be used for these two PointSound
sources, line 5 sets the position of one source, while lines 10 and 11 provide the attenuation
characteristics of both sources through a series of distance gain pairs in an array.
Search WWH ::




Custom Search