Source Code Cross Referenced for ConeSound.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ConeSound.java,v $
003:         *
004:         * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.6 $
028:         * $Date: 2008/02/28 20:17:20 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.lang.Math;
035:        import javax.vecmath.Point2f;
036:        import javax.vecmath.Point3f;
037:        import javax.vecmath.Vector3f;
038:
039:        /**
040:         * The ConeSound node object defines a PointSound node whose sound source is
041:         * directed along a specific vector in space. A ConeSound source is attenuated
042:         * by gain scale factors and filters based on the angle between the vector from
043:         * the source to the listener, and the ConeSound's direction vector. This
044:         * attenuation is either a single spherical distance gain attenuation (as for
045:         * a general PointSound source) or dual front and back distance gain 
046:         * attenuations defining elliptical attenuation areas. The angular filter and the
047:         * active AuralAttribute component filter define what filtering is applied to
048:         * the sound source. (See AuralAtttribute class for more details on filtering.)
049:         * This node has the same attributes as a PointSound node with the addition of a
050:         * direction vector and an array of points each containing: angular distance (in
051:         * radians), gain scale factor, and filter (which for now consists of a lowpass
052:         * filter cutoff frequency). Similar to the definition of the back distance gain
053:         * array for PointSounds, a piece-wise linear curve (defined in terms of 
054:         * radians from the axis) specifies the slope of these additional attenuation
055:         * values.
056:         *   <P>
057:         *  Distance Gain attuation
058:         *   <P><UL>
059:         * A cone sound node can have one or two distance attenuation arrays.
060:         * If none are set, no distance gain attenuation is performed (equivalent
061:         * to using a distance gain of 1.0 for all distances). If only one distance
062:         * attenuation array is set, sphere attenuation is assumed. If both a front
063:         * and back distance attenuation are set, elliptical attenuation regions
064:         * are defined.
065:         *<P>
066:         * Use PointSound setDistanceGain() method to set the front distance
067:         * attenuation array separate from the back distance attenuation array.
068:         * A front distance attenuation array defines monotonically-increasing
069:         * distances from the sound source origin along the position direction
070:         * vector. A back distance attenuation array (if given) defines 
071:         * monotonically-increasing distances from the sound source origin along the
072:         * negative direction vector. The two arrays must be of the same length.
073:         * The backDistance[i] gain values must be less than or equal to
074:         * the frontDistance[i] gain values.
075:         * <P>
076:         * Gain scale factors are associated with distances from the listener to
077:         * the sound source via an array of (distance, gain-scale-factor) pairs.
078:         * The gain scale factor applied to the sound source is the linear
079:         * interpolated gain value between the distance value range that includes
080:         * the current distance from the listener to the sound source.
081:         *<P>
082:         * The getDistanceGainLength method defined for PointSound returns the length
083:         * of the all distance gain attenuation arrays, including the back distance
084:         * gain arrays.  Arrays passed into getDistanceGain methods should all
085:         * be at least this size.
086:         *  </UL> <P>
087:         *  Direction Methods
088:         *   <P><UL>
089:         * This value is the sound source's direction vector. It is the axis from
090:         * which angular distance is measured.
091:         * </UL><P>
092:         *  Angular Attenuation
093:         *   <P><UL>
094:         * Besides sound (linear) distance attenuation a ConeSound can optionally
095:         * define angular gain and filter attenuation.
096:         *   <P>
097:         * This attenuation is defined
098:         * as a triple of (angular distance, gain-scale-factor, filter). The
099:         * distance is measured as the angle in radians between the ConeSound's
100:         * direction vector and the vector from the sound source position to the
101:         * listener. Both the gain scale factor and filter applied to the sound
102:         * source is the linear interpolation of values between the distance value
103:         * range that includes the angular distance from the sound source axis.
104:         *<P>
105:         * If this is not set, no angular gain attenuation or filtering is performed
106:         * (equivalent to using an angular gain scale factor of 1.0 and an angular
107:         * filter of Sound.NO_FILTER for all distances). 
108:         *   <P>
109:         * If angular distance from the listener-sound-position vector and a sound's
110:         * direction vector is less than the first distance in the array, only the first
111:         * gain scale factor and first filter are applied to the sound source.
112:         * This creates a conical region around the listener within which the sound
113:         * is uniformly attenuated by first gain and first filter in the array.
114:         *   <P>
115:         * If the distance from the listener-sound-position vector and the sound's
116:         * direction vector is greater than the last distance in the array, the last gain
117:         * scale factor and last filter are applied to the sound source.
118:         *   <P>
119:         * Distance elements in this array of points is a monotonically-increasing
120:         * set of floating point numbers measured from 0 to p radians. Gain scale
121:         * factors elements in this list of points can be any positive floating
122:         * point numbers.  While for most applications this list of gain scale
123:         * factors will usually be monotonically-decreasing, they do not have to be.
124:         * The filter (for now) is a single simple frequency cutoff value.
125:         *   <P>
126:         * The getAngularAttenuationArrayLength method returns the length of the angular
127:         * attenuation arrays. Arrays passed into getAngularAttenuation methods
128:         * should all be at least this size.
129:         *</UL>
130:         */
131:
132:        public class ConeSound extends PointSound {
133:            // Constants
134:            //
135:            // These flags, when enabled using the setCapability method, allow an
136:            // application to invoke methods that respectively read and write direction
137:            // and angular attenuation array. These capability flags are enforced only
138:            // when the node is part of a live or compiled scene graph.
139:
140:            /**
141:             * Specifies that this ConeSound allows access to its object's direction
142:             * information.
143:             */
144:            public static final int ALLOW_DIRECTION_READ = CapabilityBits.CONE_SOUND_ALLOW_DIRECTION_READ;
145:
146:            /**
147:             * Specifies that this ConeSound allows writing to its object's direction
148:             * information.
149:             */
150:            public static final int ALLOW_DIRECTION_WRITE = CapabilityBits.CONE_SOUND_ALLOW_DIRECTION_WRITE;
151:
152:            /**
153:             * Specifies that this ConeSound allows access to its object's cone params
154:             * information.
155:             */
156:            public static final int ALLOW_ANGULAR_ATTENUATION_READ = CapabilityBits.CONE_SOUND_ALLOW_ANGULAR_ATTENUATION_READ;
157:
158:            /**
159:             * Specifies that this ConeSound allows writing to its object's cone params
160:             * information.
161:             */
162:            public static final int ALLOW_ANGULAR_ATTENUATION_WRITE = CapabilityBits.CONE_SOUND_ALLOW_ANGULAR_ATTENUATION_WRITE;
163:
164:            // Array for setting default read capabilities
165:            private static final int[] readCapabilities = {
166:                    ALLOW_DIRECTION_READ, ALLOW_ANGULAR_ATTENUATION_READ };
167:
168:            /**
169:             * Constructs and initializes a new ConeSound node using default
170:             * parameters.  The following default values are used:
171:             * <ul>
172:             * Direction vector: (0.0, 0.0, 1.0) <br>
173:             * Angular attenuation:
174:             *     ((0.0, 1.0, Sound.NO_FILTER),(p/2, 0.0, Sound.NO_FILTER)) <br>
175:             * </ul>
176:             */
177:            public ConeSound() {
178:                // Uses default values defined in ConeSoundRetained.java
179:                super ();
180:                // set default read capabilities
181:                setDefaultReadCapabilities(readCapabilities);
182:            }
183:
184:            /**
185:             * Constructs a ConeSound node object using only the provided parameter
186:             * values for sound, overall initial gain, position, and direction.  The
187:             * remaining fields are set to the default values above. This form uses
188:             * Point3f as input for its position and Vector3f for direction.
189:             * @param soundData sound source data associated with this node
190:             * @param initialGain amplitude scale factor applied to sound
191:             * @param position 3D location of source
192:             * @param direction 3D vector defining cone's axis
193:             */
194:            public ConeSound(MediaContainer soundData, float initialGain,
195:                    Point3f position, Vector3f direction) {
196:
197:                super (soundData, initialGain, position);
198:
199:                // set default read capabilities
200:                setDefaultReadCapabilities(readCapabilities);
201:
202:                ((ConeSoundRetained) this .retained).setDirection(direction);
203:            }
204:
205:            /**
206:             * Constructs a ConeSound node object using only the provided parameter
207:             * values for sound, overall initial gain, position, and direction.  The
208:             * remaining fields are set to the default values above. This form uses
209:             * individual float parameters for the elements of the position and 
210:             * direction vectors.
211:             * @param soundData sound source data
212:             * @param initialGain amplitude scale factor applied to sound
213:             * @param posX x coordinate of location of source
214:             * @param posY y coordinate of location of source
215:             * @param posZ z coordinate of location of source
216:             * @param dirX x coordinate cones' axii vector
217:             * @param dirY y coordinate cones' axii vector
218:             * @param dirZ z coordinate cones' axii vector
219:             */
220:            public ConeSound(MediaContainer soundData, float initialGain,
221:                    float posX, float posY, float posZ, float dirX, float dirY,
222:                    float dirZ) {
223:
224:                super (soundData, initialGain, posX, posY, posZ);
225:
226:                // set default read capabilities
227:                setDefaultReadCapabilities(readCapabilities);
228:
229:                ((ConeSoundRetained) this .retained).setDirection(dirX, dirY,
230:                        dirZ);
231:            }
232:
233:            /**
234:             * Constructs a ConeSound node object using all the provided PointSound
235:             * parameter values.  This form uses points or vectors as input for its 
236:             * position, direction, and front/back distance attenuation arrays.
237:             *<P>
238:             * Unlike the single distance gain attenuation array for PointSounds which
239:             * define spherical areas about the sound source between which gains are
240:             * linearly interpolated, this directed ConeSound can have two distance gain
241:             * attenuation arrays that define ellipsoidal attenuation areas. See the 
242:             * setDistanceGain PointSound method for details on how the separate distance
243:             * and distanceGain arrays are interpreted.
244:             *<P>
245:             * The ConeSound's direction vector and angular measurements are defined in
246:             * the local coordinate system of the node.
247:             * @param soundData sound source data associated with this node
248:             * @param initialGain amplitude scale factor applied to sound
249:             * @param loopCount number of times sound is looped
250:             * @param release flag denoting playing sound to end
251:             * @param continuous denotes that sound silently plays when disabled
252:             * @param enable sound switched on/off
253:             * @param region scheduling bounds
254:             * @param priority playback ranking value
255:             * @param position 3D location of source
256:             * @param frontDistanceAttenuation array of (distance,gain) pairs controlling 
257:             * attenuation values along the positive direction axis
258:             * @param backDistanceAttenuation array of (distance,gain) pairs controlling 
259:             * attenuation values along the negative direction axis
260:             * @param direction vector defining cones' axii
261:             */
262:            public ConeSound(MediaContainer soundData, float initialGain,
263:                    int loopCount, boolean release, boolean continuous,
264:                    boolean enable, Bounds region, float priority,
265:                    Point3f position, Point2f[] frontDistanceAttenuation,
266:                    Point2f[] backDistanceAttenuation, Vector3f direction) {
267:
268:                super (soundData, initialGain, loopCount, release, continuous,
269:                        enable, region, priority, position,
270:                        frontDistanceAttenuation);
271:
272:                // set default read capabilities
273:                setDefaultReadCapabilities(readCapabilities);
274:
275:                ((ConeSoundRetained) this .retained)
276:                        .setBackDistanceGain(backDistanceAttenuation);
277:                ((ConeSoundRetained) this .retained).setDirection(direction);
278:            }
279:
280:            /**
281:             * Constructs a ConeSound node object using the provided parameter values.
282:             * This form uses individual float parameters for the elements of the 
283:             * position, direction, and two distance attenuation arrays.
284:             * Unlike the single distance gain attenuation array for PointSounds, which 
285:             * define spherical areas about the sound source between which gains are
286:             * linearly interpolated, this directed ConeSound can have two distance
287:             * gain attenuation arrays that define ellipsoidal attenuation areas. 
288:             * See the setDistanceGain PointSound method for details on how the 
289:             * separate distance and distanceGain arrays are interpreted.
290:             * The ConeSound's direction vector and angular measurements are defined
291:             * in the local coordinate system of the node.
292:             * @param soundData sound source data associated with this node
293:             * @param initialGain amplitude scale factor applied to sound
294:             * @param loopCount number of times sound is looped
295:             * @param release flag denoting playing sound to end
296:             * @param continuous denotes that sound silently plays when disabled
297:             * @param enable sound switched on/off
298:             * @param region scheduling bounds
299:             * @param priority playback ranking value
300:             * @param posX x coordinate of location of source
301:             * @param posY y coordinate of location of source
302:             * @param posZ z coordinate of location of source
303:             * @param frontDistance array of front distance values used for attenuation
304:             * @param frontDistanceGain array of front gain scale factors used for attenuation
305:             * @param backDistance array of back distance values used for attenuation
306:             * @param backDistanceGain array of back gain scale factors used for attenuation
307:             * @param dirX x coordinate cones' axii vector
308:             * @param dirY y coordinate cones' axii vector
309:             * @param dirZ z coordinate cones' axii vector
310:             */
311:            public ConeSound(MediaContainer soundData, float initialGain,
312:                    int loopCount, boolean release, boolean continuous,
313:                    boolean enable, Bounds region, float priority, float posX,
314:                    float posY, float posZ, float[] frontDistance,
315:                    float[] frontDistanceGain, float[] backDistance,
316:                    float[] backDistanceGain, float dirX, float dirY, float dirZ) {
317:                super (soundData, initialGain, loopCount, release, continuous,
318:                        enable, region, priority, posX, posY, posZ,
319:                        frontDistance, frontDistanceGain);
320:
321:                // set default read capabilities
322:                setDefaultReadCapabilities(readCapabilities);
323:
324:                ((ConeSoundRetained) this .retained).setDirection(dirX, dirY,
325:                        dirZ);
326:                ((ConeSoundRetained) this .retained).setBackDistanceGain(
327:                        backDistance, backDistanceGain);
328:            }
329:
330:            /**
331:             * Constructs a ConeSound node object using all the provided PointSound
332:             * parameter values, which include a single spherical distance attenuation
333:             * array, but includes an angular attenuation array. 
334:             * This form uses points and vectors as input for its position, direction,
335:             * single spherical distanceAttenuation array, and angularAttenuation array.
336:             * It also accepts arrays of points for the distance attenuation and angular
337:             * values. Each Point2f in the distanceAttenuation array contains a distance
338:             * and a gain scale factor. Each Point3f in the angularAttenuation array
339:             * contains an angular distance, a gain scale factor, and a filtering value
340:             * (which is currently defined as a simple cutoff frequency).
341:             * @param soundData sound source data associated with this node
342:             * @param initialGain amplitude scale factor applied to sound
343:             * @param loopCount number of times sound is looped
344:             * @param release flag denoting playing sound to end
345:             * @param continuous denotes that sound silently plays when disabled
346:             * @param enable sound switched on/off
347:             * @param region scheduling bounds
348:             * @param priority playback ranking value
349:             * @param position 3D location of source
350:             * @param distanceAttenuation array of (distance,gain) pairs controlling 
351:             * attenuation values along the positive direction axis
352:             * @param direction vector defining cones' axii
353:             * @param angularAttenuation array of tuples defining angular gain/filtering
354:             */
355:            public ConeSound(MediaContainer soundData, float initialGain,
356:                    int loopCount, boolean release, boolean continuous,
357:                    boolean enable, Bounds region, float priority,
358:                    Point3f position, Point2f[] distanceAttenuation,
359:                    Vector3f direction, Point3f[] angularAttenuation) {
360:
361:                super (soundData, initialGain, loopCount, release, continuous,
362:                        enable, region, priority, position, distanceAttenuation);
363:
364:                // set default read capabilities
365:                setDefaultReadCapabilities(readCapabilities);
366:
367:                ((ConeSoundRetained) this .retained).setDirection(direction);
368:                ((ConeSoundRetained) this .retained)
369:                        .setAngularAttenuation(angularAttenuation);
370:            }
371:
372:            /**
373:             * Constructs a ConeSound node object using all the provided PointSound
374:             * parameter values, which include a single spherical distance attenuation
375:             * array, but includes an angular attenuation array.
376:             * This form uses individual float parameters for elements of position,
377:             * direction, distanceAttenuation array, and angularAttenuation array.
378:             * It also accepts separate arrays for the distance and gain scale factors
379:             * components of distance attenuation, and separate arrays for the angular
380:             * distance, angular gain, and filtering components of angular attenuation.
381:             * See the setDistanceGain ConeSound method for details on how the separate
382:             * distance and distanceGain arrays are interpreted. See the 
383:             * setAngularAttenuation ConeSound method for details on how the separate
384:             * angularDistance, angularGain, and filter arrays are interpreted.
385:             * @param soundData sound source data associated with this node
386:             * @param initialGain amplitude scale factor applied to sound
387:             * @param loopCount number of times sound is looped
388:             * @param release flag denoting playing sound to end
389:             * @param continuous denotes that sound silently plays when disabled
390:             * @param enable sound switched on/off
391:             * @param region scheduling bounds
392:             * @param priority playback ranking value
393:             * @param posX x coordinate of location of source
394:             * @param posY y coordinate of location of source
395:             * @param posZ z coordinate of location of source
396:             * @param distance array of front distance values used for attenuation
397:             * @param distanceGain array of front gain scale factors used for attenuation
398:             * @param dirX x coordinate cones' axii vector
399:             * @param dirY y coordinate cones' axii vector
400:             * @param dirZ z coordinate cones' axii vector
401:             * @param angle array of angle radians for angularAttenuation
402:             * @param angularGain array of gain scale factors for angularAttenuation
403:             * @param frequencyCutoff array of lowpass filter values in Hertz
404:             */
405:            public ConeSound(MediaContainer soundData, float initialGain,
406:                    int loopCount, boolean release, boolean continuous,
407:                    boolean enable, Bounds region, float priority, float posX,
408:                    float posY, float posZ, float[] distance,
409:                    float[] distanceGain, float dirX, float dirY, float dirZ,
410:                    float[] angle, float[] angularGain, float[] frequencyCutoff) {
411:                super (soundData, initialGain, loopCount, release, continuous,
412:                        enable, region, priority, posX, posY, posZ, distance,
413:                        distanceGain);
414:
415:                // set default read capabilities
416:                setDefaultReadCapabilities(readCapabilities);
417:
418:                ((ConeSoundRetained) this .retained).setDirection(dirX, dirY,
419:                        dirZ);
420:                ((ConeSoundRetained) this .retained).setAngularAttenuation(
421:                        angle, angularGain, frequencyCutoff);
422:            }
423:
424:            /**
425:             * Constructs and initializes a new Cone Sound node explicitly setting all
426:             * PointSound and ConeSound fields as arguments: the PointSound position,
427:             * front and back distance attenuation Point2f array, and ConeSound
428:             * direction vector and Point3f angular attenuation.
429:             * @param soundData sound source data associated with this node
430:             * @param initialGain amplitude scale factor applied to sound
431:             * @param loopCount number of times sound is looped
432:             * @param release flag denoting playing sound to end
433:             * @param continuous denotes that sound silently plays when disabled
434:             * @param enable sound switched on/off
435:             * @param region scheduling bounds
436:             * @param priority playback ranking value
437:             * @param position 3D location of source
438:             * @param frontDistanceAttenuation array of (distance,gain) pairs controlling 
439:             * attenuation values along the positive direction axis
440:             * @param backDistanceAttenuation array of (distance,gain) pairs controlling 
441:             * attenuation values along the negative direction axis
442:             * @param direction vector defining cones' axii
443:             * @param angularAttenuation array of tuples defining angular gain/filtering
444:             */
445:            public ConeSound(MediaContainer soundData, float initialGain,
446:                    int loopCount, boolean release, boolean continuous,
447:                    boolean enable, Bounds region, float priority,
448:                    Point3f position, Point2f[] frontDistanceAttenuation,
449:                    Point2f[] backDistanceAttenuation, Vector3f direction,
450:                    Point3f[] angularAttenuation) {
451:
452:                super (soundData, initialGain, loopCount, release, continuous,
453:                        enable, region, priority, position,
454:                        frontDistanceAttenuation);
455:
456:                // set default read capabilities
457:                setDefaultReadCapabilities(readCapabilities);
458:
459:                ((ConeSoundRetained) this .retained)
460:                        .setBackDistanceGain(backDistanceAttenuation);
461:                ((ConeSoundRetained) this .retained).setDirection(direction);
462:                ((ConeSoundRetained) this .retained)
463:                        .setAngularAttenuation(angularAttenuation);
464:            }
465:
466:            /**
467:             * Constructs and initializes a new Cone Sound node explicitly setting all
468:             * PointSound and ConeSound fields as arguments but all the vector and point
469:             * arguments are broken into individual float array components.
470:             * @param soundData sound source data associated with this node
471:             * @param initialGain amplitude scale factor applied to sound
472:             * @param loopCount number of times sound is looped
473:             * @param release flag denoting playing sound to end
474:             * @param continuous denotes that sound silently plays when disabled
475:             * @param enable sound switched on/off
476:             * @param region scheduling bounds
477:             * @param priority playback ranking value
478:             * @param posX x coordinate of location of source
479:             * @param posY y coordinate of location of source
480:             * @param posZ z coordinate of location of source
481:             * @param frontDistance array of front distance values used for attenuation
482:             * @param frontDistanceGain array of front gain scale factors used for attenuation
483:             * @param backDistance array of back distance values used for attenuation
484:             * @param backDistanceGain array of back gain scale factors used for attenuation
485:             * @param dirX x coordinate cones' axii vector
486:             * @param dirY y coordinate cones' axii vector
487:             * @param dirZ z coordinate cones' axii vector
488:             * @param angle array of angle radians for angularAttenuation
489:             * @param angularGain array of gain scale factors for angularAttenuation
490:             * @param frequencyCutoff array of lowpass filter values in Hertz
491:             */
492:            public ConeSound(MediaContainer soundData, float initialGain,
493:                    int loopCount, boolean release, boolean continuous,
494:                    boolean enable, Bounds region, float priority, float posX,
495:                    float posY, float posZ, float[] frontDistance,
496:                    float[] frontDistanceGain, float[] backDistance,
497:                    float[] backDistanceGain, float dirX, float dirY,
498:                    float dirZ, float[] angle, float[] angularGain,
499:                    float[] frequencyCutoff) {
500:                super (soundData, initialGain, loopCount, release, continuous,
501:                        enable, region, priority, posX, posY, posZ,
502:                        frontDistance, frontDistanceGain);
503:
504:                // set default read capabilities
505:                setDefaultReadCapabilities(readCapabilities);
506:
507:                ((ConeSoundRetained) this .retained).setBackDistanceGain(
508:                        backDistance, backDistanceGain);
509:                ((ConeSoundRetained) this .retained).setDirection(dirX, dirY,
510:                        dirZ);
511:                ((ConeSoundRetained) this .retained).setAngularAttenuation(
512:                        angle, angularGain, frequencyCutoff);
513:            }
514:
515:            /**
516:             * Creates the retained mode ConeSoundRetained object that this
517:             * ConeSound object will point to.
518:             */
519:            void createRetained() {
520:                this .retained = new ConeSoundRetained();
521:                this .retained.setSource(this );
522:            }
523:
524:            //
525:            // OVERLOADED Sound methods
526:            //
527:            /**
528:             * Sets this sound's distance gain elliptical attenuation - 
529:             * where gain scale factor is applied to sound based on distance listener
530:             * is from sound source.
531:             * @param frontAttenuation defined by pairs of (distance,gain-scale-factor)
532:             * @param backAttenuation defined by pairs of (distance,gain-scale-factor)
533:             * @exception CapabilityNotSetException if appropriate capability is
534:             * not set and this object is part of live or compiled scene graph
535:             */
536:            public void setDistanceGain(Point2f[] frontAttenuation,
537:                    Point2f[] backAttenuation) {
538:                if (isLiveOrCompiled())
539:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_WRITE))
540:                        throw new CapabilityNotSetException(J3dI18N
541:                                .getString("ConeSound0"));
542:
543:                ((ConeSoundRetained) this .retained).setDistanceGain(
544:                        frontAttenuation, backAttenuation);
545:            }
546:
547:            /**
548:             * Sets this sound's distance gain attenuation as an array of Point2fs.
549:             * @param frontDistance array of monotonically-increasing floats
550:             * @param frontGain array of non-negative scale factors
551:             * @param backDistance array of monotonically-increasing floats
552:             * @param backGain array of non-negative scale factors
553:             * @exception CapabilityNotSetException if appropriate capability is
554:             * not set and this object is part of live or compiled scene graph
555:             */
556:            public void setDistanceGain(float[] frontDistance,
557:                    float[] frontGain, float[] backDistance, float[] backGain) {
558:                if (isLiveOrCompiled())
559:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_WRITE))
560:                        throw new CapabilityNotSetException(J3dI18N
561:                                .getString("ConeSound0"));
562:
563:                ((ConeSoundRetained) this .retained).setDistanceGain(
564:                        frontDistance, frontGain, backDistance, backGain);
565:            }
566:
567:            /**
568:             * Sets this sound's back distance gain attenuation - where gain scale 
569:             * factor is applied to sound based on distance listener along the negative
570:             * sound direction axis from sound source.
571:             * @param attenuation defined by pairs of (distance,gain-scale-factor)
572:             * @exception CapabilityNotSetException if appropriate capability is
573:             * not set and this object is part of live or compiled scene graph
574:             */
575:            public void setBackDistanceGain(Point2f[] attenuation) {
576:                if (isLiveOrCompiled())
577:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_WRITE))
578:                        throw new CapabilityNotSetException(J3dI18N
579:                                .getString("ConeSound0"));
580:
581:                ((ConeSoundRetained) this .retained)
582:                        .setBackDistanceGain(attenuation);
583:            }
584:
585:            /**
586:             * Sets this sound's back distance gain attenuation as separate arrays.
587:             * @param distance array of monotonically-increasing floats
588:             * @param gain array of non-negative scale factors
589:             * @exception CapabilityNotSetException if appropriate capability is
590:             * not set and this object is part of live or compiled scene graph
591:             */
592:            public void setBackDistanceGain(float[] distance, float[] gain) {
593:                if (isLiveOrCompiled())
594:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_WRITE))
595:                        throw new CapabilityNotSetException(J3dI18N
596:                                .getString("ConeSound0"));
597:
598:                ((ConeSoundRetained) this .retained).setBackDistanceGain(
599:                        distance, gain);
600:            }
601:
602:            /**
603:             * Gets this sound's elliptical distance attenuation. The
604:             * attenuation values are copied into the specified arrays.
605:             * The arrays must be large enough to hold all of the
606:             * forward distances and backward distances attenuation values.
607:             * The individual array elements must be allocated by the
608:             * caller. The Point2f x,y values are defined as follows:
609:             * x is the distance, y is the gain.
610:             * @param frontAttenuation arrays containing forward distances 
611:             * attenuation pairs
612:             * @param backAttenuation arrays containing backward distances 
613:             * attenuation pairs
614:             * @exception CapabilityNotSetException if appropriate capability is
615:             * not set and this object is part of live or compiled scene graph
616:             */
617:            public void getDistanceGain(Point2f[] frontAttenuation,
618:                    Point2f[] backAttenuation) {
619:                if (isLiveOrCompiled())
620:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_READ))
621:                        throw new CapabilityNotSetException(J3dI18N
622:                                .getString("ConeSound2"));
623:
624:                ((ConeSoundRetained) this .retained).getDistanceGain(
625:                        frontAttenuation, backAttenuation);
626:            }
627:
628:            /**
629:             * Gets this sound's elliptical distance gain attenuation values in 
630:             * separate arrays. The arrays must be large enough to hold all
631:             * of the values.
632:             * @param frontDistance array of float distances along the sound axis
633:             * @param frontGain array of non-negative scale factors associated with 
634:             * front distances
635:             * @param backDistance array of float negative distances along the sound 
636:             * axis
637:             * @param backGain array of non-negative scale factors associated with 
638:             * back distances
639:             * @exception CapabilityNotSetException if appropriate capability is
640:             * not set and this object is part of live or compiled scene graph
641:             */
642:            public void getDistanceGain(float[] frontDistance,
643:                    float[] frontGain, float[] backDistance, float[] backGain) {
644:                if (isLiveOrCompiled())
645:                    if (!this .getCapability(ALLOW_DISTANCE_GAIN_READ))
646:                        throw new CapabilityNotSetException(J3dI18N
647:                                .getString("ConeSound10"));
648:
649:                ((ConeSoundRetained) this .retained).getDistanceGain(
650:                        frontDistance, frontGain, backDistance, backGain);
651:            }
652:
653:            /**
654:             * Sets this sound's direction from the vector provided.
655:             * @param direction the new direction
656:             * @exception CapabilityNotSetException if appropriate capability is
657:             * not set and this object is part of live or compiled scene graph
658:             */
659:            public void setDirection(Vector3f direction) {
660:                if (isLiveOrCompiled())
661:                    if (!this .getCapability(ALLOW_DIRECTION_WRITE))
662:                        throw new CapabilityNotSetException(J3dI18N
663:                                .getString("ConeSound3"));
664:
665:                ((ConeSoundRetained) this .retained).setDirection(direction);
666:            }
667:
668:            /**
669:             * Sets this sound's direction from the three values provided.
670:             * @param x the new x direction
671:             * @param y the new y direction
672:             * @param z the new z direction
673:             * @exception CapabilityNotSetException if appropriate capability is
674:             * not set and this object is part of live or compiled scene graph
675:             */
676:            public void setDirection(float x, float y, float z) {
677:                if (isLiveOrCompiled())
678:                    if (!this .getCapability(ALLOW_DIRECTION_WRITE))
679:                        throw new CapabilityNotSetException(J3dI18N
680:                                .getString("ConeSound3"));
681:
682:                ((ConeSoundRetained) this .retained).setDirection(x, y, z);
683:            }
684:
685:            /**
686:             * Retrieves this sound's direction and places it in the
687:             * vector provided.
688:             * @param direction axis of cones; 'direction' of sound
689:             * @exception CapabilityNotSetException if appropriate capability is
690:             * not set and this object is part of live or compiled scene graph
691:             */
692:            public void getDirection(Vector3f direction) {
693:                if (isLiveOrCompiled())
694:                    if (!this .getCapability(ALLOW_DIRECTION_READ))
695:                        throw new CapabilityNotSetException(J3dI18N
696:                                .getString("ConeSound5"));
697:
698:                ((ConeSoundRetained) this .retained).getDirection(direction);
699:            }
700:
701:            /**
702:             * Sets this sound's angular gain attenuation (not including filter).
703:             * In this form of setAngularAttenuation, only the angular distances 
704:             * and angular gain scale factors pairs are given. The filter values for 
705:             * these tuples are implicitly set to Sound.NO_FILTER. 
706:             * @param attenuation array containing angular distance and gain
707:             * @exception CapabilityNotSetException if appropriate capability is
708:             * not set and this object is part of live or compiled scene graph
709:             */
710:            public void setAngularAttenuation(Point2f[] attenuation) {
711:                if (isLiveOrCompiled())
712:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_WRITE))
713:                        throw new CapabilityNotSetException(J3dI18N
714:                                .getString("ConeSound6"));
715:
716:                ((ConeSoundRetained) this .retained)
717:                        .setAngularAttenuation(attenuation);
718:            }
719:
720:            /**
721:             * In the second form of setAngularAttenuation, an array of all three values 
722:             * is supplied.
723:             * @param attenuation array containing angular distance, gain, and filter
724:             * @exception CapabilityNotSetException if appropriate capability is
725:             * not set and this object is part of live or compiled scene graph
726:             */
727:            public void setAngularAttenuation(Point3f[] attenuation) {
728:                if (isLiveOrCompiled())
729:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_WRITE))
730:                        throw new CapabilityNotSetException(J3dI18N
731:                                .getString("ConeSound6"));
732:
733:                ((ConeSoundRetained) this .retained)
734:                        .setAngularAttenuation(attenuation);
735:            }
736:
737:            /**
738:             * Sets angular attenuation including gain and filter using separate arrays.
739:             * The third form of setAngularAttenuation accepts three separate arrays for
740:             * these angular attenuation values. These arrays should be of the same
741:             * length.  If the angularGain or filtering array length is greater than
742:             * angularDistance array length, the array elements beyond the length of
743:             * the angularDistance array are ignored. If the angularGain or filtering
744:             * array is shorter than the angularDistance array, the last value of the
745:             * short array is repeated to fill an array of length equal to 
746:             * angularDistance array.
747:             * @param distance array containing angular distance
748:             * @param gain array containing angular gain attenuation
749:             * @param filter array containing angular low-pass frequency cutoff values
750:             * @exception CapabilityNotSetException if appropriate capability is
751:             * not set and this object is part of live or compiled scene graph
752:             */
753:            public void setAngularAttenuation(float[] distance, float[] gain,
754:                    float[] filter) {
755:                if (isLiveOrCompiled())
756:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_WRITE))
757:                        throw new CapabilityNotSetException(J3dI18N
758:                                .getString("ConeSound6"));
759:
760:                ((ConeSoundRetained) this .retained).setAngularAttenuation(
761:                        distance, gain, filter);
762:            }
763:
764:            /**
765:             * Retrieves angular attenuation array length.
766:             * All arrays are forced to same size.
767:             * @exception CapabilityNotSetException if appropriate capability is
768:             * not set and this object is part of live or compiled scene graph
769:             */
770:            public int getAngularAttenuationLength() {
771:                if (isLiveOrCompiled())
772:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_READ))
773:                        throw new CapabilityNotSetException(J3dI18N
774:                                .getString("ConeSound9"));
775:
776:                return (((ConeSoundRetained) this .retained)
777:                        .getAngularAttenuationLength());
778:            }
779:
780:            /**
781:             * Copies the array of attenuation values from this sound, including 
782:             * gain and filter, into the specified array. The array must be
783:             * large enough to hold all of the points. The individual array
784:             * elements must be allocated by the caller. The Point3f x,y,z values
785:             * are defined as follows: x is the angular distance, y is
786:             * the angular gain attenuation, and z is the frequency
787:             * cutoff.
788:             * @param attenuation the array to receive the attenuation values 
789:             * applied to gain when listener is between cones
790:             * @exception CapabilityNotSetException if appropriate capability is
791:             * not set and this object is part of live or compiled scene graph
792:             */
793:            public void getAngularAttenuation(Point3f[] attenuation) {
794:                if (isLiveOrCompiled())
795:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_READ))
796:                        throw new CapabilityNotSetException(J3dI18N
797:                                .getString("ConeSound9"));
798:
799:                ((ConeSoundRetained) this .retained)
800:                        .getAngularAttenuation(attenuation);
801:            }
802:
803:            /**
804:             * Copies the array of attenuation values from this sound,
805:             * including gain and filter, into the separate arrays.
806:             * The arrays must be large enough to hold all of the values.
807:             * @param distance array containing angular distance
808:             * @param gain array containing angular gain attenuation
809:             * @param filter array containing angular low-pass frequency cutoff values
810:             * @exception CapabilityNotSetException if appropriate capability is
811:             * not set and this object is part of live or compiled scene graph
812:             */
813:            public void getAngularAttenuation(float[] distance, float[] gain,
814:                    float[] filter) {
815:                if (isLiveOrCompiled())
816:                    if (!this .getCapability(ALLOW_ANGULAR_ATTENUATION_WRITE))
817:                        throw new CapabilityNotSetException(J3dI18N
818:                                .getString("ConeSound9"));
819:
820:                ((ConeSoundRetained) this .retained).getAngularAttenuation(
821:                        distance, gain, filter);
822:            }
823:
824:            /**
825:             * Creates a new instance of the node.  This routine is called
826:             * by <code>cloneTree</code> to duplicate the current node.
827:             * @param forceDuplicate when set to <code>true</code>, causes the
828:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
829:             *  <code>false</code>, the value of each node's
830:             *  <code>duplicateOnCloneTree</code> variable determines whether
831:             *  NodeComponent data is duplicated or copied.
832:             *
833:             * @see Node#cloneTree
834:             * @see Node#cloneNode
835:             * @see Node#duplicateNode
836:             * @see NodeComponent#setDuplicateOnCloneTree
837:             */
838:            public Node cloneNode(boolean forceDuplicate) {
839:                ConeSound c = new ConeSound();
840:                c.duplicateNode(this , forceDuplicate);
841:                return c;
842:            }
843:
844:            /**
845:             * Copies all node information from <code>originalNode</code> into
846:             * the current node.  This method is called from the
847:             * <code>cloneNode</code> method which is, in turn, called by the
848:             * <code>cloneTree</code> method.
849:             * <P>
850:             * For any <code>NodeComponent</code> objects
851:             * contained by the object being duplicated, each <code>NodeComponent</code>
852:             * object's <code>duplicateOnCloneTree</code> value is used to determine
853:             * whether the <code>NodeComponent</code> should be duplicated in the new node
854:             * or if just a reference to the current node should be placed in the
855:             * new node.  This flag can be overridden by setting the
856:             * <code>forceDuplicate</code> parameter in the <code>cloneTree</code>
857:             * method to <code>true</code>.
858:             *
859:             * <br>
860:             * NOTE: Applications should <i>not</i> call this method directly.
861:             * It should only be called by the cloneNode method.
862:             *
863:             * @param originalNode the original node to duplicate.
864:             * @param forceDuplicate when set to <code>true</code>, causes the
865:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
866:             *  <code>false</code>, the value of each node's
867:             *  <code>duplicateOnCloneTree</code> variable determines whether
868:             *  NodeComponent data is duplicated or copied.
869:             * @exception ClassCastException if originalNode is not an instance of 
870:             *  <code>ConeSound</code>
871:             *
872:             * @see Node#cloneTree
873:             * @see Node#cloneNode
874:             * @see NodeComponent#setDuplicateOnCloneTree
875:             */
876:            public void duplicateNode(Node originalNode, boolean forceDuplicate) {
877:                checkDuplicateNode(originalNode, forceDuplicate);
878:            }
879:
880:            /**
881:             * Copies all ConeSound information from
882:             * <code>originalNode</code> into
883:             * the current node.  This method is called from the
884:             * <code>cloneNode</code> method which is, in turn, called by the
885:             * <code>cloneTree</code> method.<P> 
886:             *
887:             * @param originalNode the original node to duplicate.
888:             * @param forceDuplicate when set to <code>true</code>, causes the
889:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
890:             *  <code>false</code>, the value of each node's
891:             *  <code>duplicateOnCloneTree</code> variable determines whether
892:             *  NodeComponent data is duplicated or copied.
893:             *
894:             * @exception RestrictedAccessException if this object is part of a live
895:             *  or compiled scenegraph.
896:             *
897:             * @see Node#duplicateNode
898:             * @see Node#cloneTree
899:             * @see NodeComponent#setDuplicateOnCloneTree
900:             */
901:            void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
902:                super .duplicateAttributes(originalNode, forceDuplicate);
903:
904:                ConeSoundRetained orgRetained = (ConeSoundRetained) originalNode.retained;
905:                ConeSoundRetained this Retained = (ConeSoundRetained) this .retained;
906:
907:                // front distance gain & attenuation is set in super      
908:                // set back distance gain only
909:                int len = orgRetained.getDistanceGainLength();
910:                float distance[] = new float[len];
911:                float gain[] = new float[len];
912:                orgRetained.getDistanceGain(null, null, distance, gain);
913:                this Retained.setBackDistanceGain(distance, gain);
914:
915:                Vector3f v = new Vector3f();
916:                orgRetained.getDirection(v);
917:                this Retained.setDirection(v);
918:
919:                len = orgRetained.getAngularAttenuationLength();
920:                distance = gain = null;
921:                float angle[] = new float[len];
922:                float angularGain[] = new float[len];
923:                float frequencyCutoff[] = new float[len];
924:
925:                orgRetained.getAngularAttenuation(angle, angularGain,
926:                        frequencyCutoff);
927:
928:                thisRetained.setAngularAttenuation(angle, angularGain,
929:                        frequencyCutoff);
930:            }
931:
932:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.