diff options
5 files changed, 98 insertions, 313 deletions
diff --git a/ardor3d-audio/build.gradle b/ardor3d-audio/build.gradle index 08d57d6..ae71ba6 100644 --- a/ardor3d-audio/build.gradle +++ b/ardor3d-audio/build.gradle @@ -3,4 +3,5 @@ description = 'Ardor 3D Sound System' dependencies { implementation project(':ardor3d-core') implementation project(':ardor3d-math') + implementation project(':ardor3d-savable') } diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/Library.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/Library.java index 8abd6b6..d11d2f7 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/Library.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/Library.java @@ -925,8 +925,8 @@ public class Library */ public void moveListener( float x, float y, float z ) { - setListenerPosition( listener.position.x + x, listener.position.y + y, - listener.position.z + z ); + setListenerPosition( listener.position.getXf() + x, listener.position.getYf() + y, + listener.position.getZf() + z ); } /** diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/ListenerData.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/ListenerData.java index 94e2ac6..25c1af0 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/ListenerData.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/ListenerData.java @@ -9,11 +9,13 @@ */ package com.ardor3d.audio; +import com.ardor3d.math.Vector3; + /** * The listenerData class is used to store information about the * listener's position and orientation. A ListenerData object can be obtained * using SoundSystem's getListenerData() method. See - * {@link com.ardor3d.audio.Vector3D Vector3D} for more information about 3D + * {@link com.ardor3d.math.Vector3 Vector3} for more information about 3D * coordinates and vectors. *<br><br> *<b><i> SoundSystem License:</b></i><br><b><br> @@ -53,19 +55,19 @@ public class ListenerData /** * Listener's position in 3D space */ - public Vector3D position; + public Vector3 position; /** * A normalized vector indicating the direction the listener is facing */ - public Vector3D lookAt; + public Vector3 lookAt; /** * A normalized vector indicating the up direction */ - public Vector3D up; + public Vector3 up; /** * Listener's velocity in world-space */ - public Vector3D velocity; + public Vector3 velocity; /** * Used for easy rotation along the x/z plane (for use in a first-person @@ -78,10 +80,10 @@ public class ListenerData */ public ListenerData() { - position = new Vector3D( 0.0f, 0.0f, 0.0f ); - lookAt = new Vector3D( 0.0f, 0.0f, -1.0f ); - up = new Vector3D( 0.0f, 1.0f, 0.0f ); - velocity = new Vector3D( 0.0f, 0.0f, 0.0f ); + position = new Vector3( 0.0f, 0.0f, 0.0f ); + lookAt = new Vector3( 0.0f, 0.0f, -1.0f ); + up = new Vector3( 0.0f, 1.0f, 0.0f ); + velocity = new Vector3( 0.0f, 0.0f, 0.0f ); angle = 0.0f; } @@ -102,10 +104,10 @@ public class ListenerData public ListenerData( float pX, float pY, float pZ, float lX, float lY, float lZ, float uX, float uY, float uZ, float a ) { - position = new Vector3D( pX, pY, pZ ); - lookAt = new Vector3D( lX, lY, lZ ); - up = new Vector3D( uX, uY, uZ ); - velocity = new Vector3D( 0.0f, 0.0f, 0.0f ); + position = new Vector3( pX, pY, pZ ); + lookAt = new Vector3( lX, lY, lZ ); + up = new Vector3( uX, uY, uZ ); + velocity = new Vector3( 0.0f, 0.0f, 0.0f ); angle = a; } @@ -117,12 +119,12 @@ public class ListenerData * @param u Normalized vector indicating the up direction. * @param a Angle in radians that the listener is turned counterclockwise around the y-axis. */ - public ListenerData( Vector3D p, Vector3D l, Vector3D u, float a ) + public ListenerData( Vector3 p, Vector3 l, Vector3 u, float a ) { - position = p.clone(); - lookAt = l.clone(); - up = u.clone(); - velocity = new Vector3D( 0.0f, 0.0f, 0.0f ); + position = new Vector3(p); + lookAt = new Vector3(l); + up = new Vector3(u); + velocity = new Vector3( 0.0f, 0.0f, 0.0f ); angle = a; } @@ -143,15 +145,15 @@ public class ListenerData public void setData( float pX, float pY, float pZ, float lX, float lY, float lZ, float uX, float uY, float uZ, float a ) { - position.x = pX; - position.y = pY; - position.z = pZ; - lookAt.x = lX; - lookAt.y = lY; - lookAt.z = lZ; - up.x = uX; - up.y = uY; - up.z = uZ; + position.setX(pX); + position.setY(pY); + position.setZ(pZ); + lookAt.setX(lX); + lookAt.setY(lY); + lookAt.setZ(lZ); + up.setX(uX); + up.setY(uY); + up.setZ(uZ); angle = a; } @@ -163,17 +165,17 @@ public class ListenerData * @param u Normalized vector indicating the up direction. * @param a Angle in radians that the listener is turned counterclockwise around the y-axis. */ - public void setData( Vector3D p, Vector3D l, Vector3D u, float a ) + public void setData( Vector3 p, Vector3 l, Vector3 u, float a ) { - position.x = p.x; - position.y = p.y; - position.z = p.z; - lookAt.x = l.x; - lookAt.y = l.y; - lookAt.z = l.z; - up.x = u.x; - up.y = u.y; - up.z = u.z; + position.setX(p.getX()); + position.setY(p.getY()); + position.setZ(p.getZ()); + lookAt.setX(l.getX()); + lookAt.setY(l.getY()); + lookAt.setZ(l.getZ()); + up.setX(u.getX()); + up.setY(u.getY()); + up.setZ(u.getZ()); angle = a; } @@ -183,15 +185,15 @@ public class ListenerData */ public void setData( ListenerData l ) { - position.x = l.position.x; - position.y = l.position.y; - position.z = l.position.z; - lookAt.x = l.lookAt.x; - lookAt.y = l.lookAt.y; - lookAt.z = l.lookAt.z; - up.x = l.up.x; - up.y = l.up.y; - up.z = l.up.z; + position.setX(l.position.getX()); + position.setY(l.position.getY()); + position.setZ(l.position.getZ()); + lookAt.setX(l.lookAt.getX()); + lookAt.setY(l.lookAt.getY()); + lookAt.setZ(l.lookAt.getZ()); + up.setX(l.up.getX()); + up.setY(l.up.getY()); + up.setZ(l.up.getZ()); angle = l.angle; } @@ -203,20 +205,20 @@ public class ListenerData */ public void setPosition( float x, float y, float z ) { - position.x = x; - position.y = y; - position.z = z; + position.setX(x); + position.setY(y); + position.setZ(z); } /** * Change this listener's position using the specified vector. * @param p New position. */ - public void setPosition( Vector3D p ) + public void setPosition( Vector3 p ) { - position.x = p.x; - position.y = p.y; - position.z = p.z; + position.setX(p.getX()); + position.setY(p.getY()); + position.setZ(p.getZ()); } /** @@ -231,12 +233,12 @@ public class ListenerData public void setOrientation( float lX, float lY, float lZ, float uX, float uY, float uZ ) { - lookAt.x = lX; - lookAt.y = lY; - lookAt.z = lZ; - up.x = uX; - up.y = uY; - up.z = uZ; + lookAt.setX(lX); + lookAt.setY(lY); + lookAt.setZ(lZ); + up.setX(uX); + up.setY(uY); + up.setZ(uZ); } /** @@ -244,25 +246,25 @@ public class ListenerData * @param l Normalized vector representing the look-at direction. * @param u Normalized vector representing the up direction. */ - public void setOrientation( Vector3D l, Vector3D u ) + public void setOrientation( Vector3 l, Vector3 u ) { - lookAt.x = l.x; - lookAt.y = l.y; - lookAt.z = l.z; - up.x = u.x; - up.y = u.y; - up.z = u.z; + lookAt.setX(l.getX()); + lookAt.setY(l.getY()); + lookAt.setZ(l.getZ()); + up.setX(u.getX()); + up.setY(u.getY()); + up.setZ(u.getZ()); } /** * Change this listener's velocity in world-space. * @param v New velocity. */ - public void setVelocity( Vector3D v ) + public void setVelocity( Vector3 v ) { - velocity.x = v.x; - velocity.y = v.y; - velocity.z = v.z; + velocity.setX(v.getX()); + velocity.setY(v.getY()); + velocity.setZ(v.getZ()); } /** @@ -273,9 +275,9 @@ public class ListenerData */ public void setVelocity( float x, float y, float z ) { - velocity.x = x; - velocity.y = y; - velocity.z = z; + velocity.setX(x); + velocity.setY(y); + velocity.setZ(z); } /** @@ -285,7 +287,7 @@ public class ListenerData public void setAngle( float a ) { angle = a; - lookAt.x = -1.0f * (float) Math.sin( angle ); - lookAt.z = -1.0f * (float) Math.cos( angle ); + lookAt.setX(-1.0f * (float) Math.sin( angle )); + lookAt.setZ(-1.0f * (float) Math.cos( angle )); } } diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java index 09ac50d..bd96fdb 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java @@ -12,6 +12,7 @@ package com.ardor3d.audio; import java.net.URL; import java.util.LinkedList; import java.util.ListIterator; +import com.ardor3d.math.Vector3; import com.ardor3d.audio.sampled.AudioFormat; /** @@ -134,7 +135,7 @@ public class Source /** * This source's position in 3D space. */ - public Vector3D position; + public Vector3 position; /** * Attenuation model to use for this source. @@ -149,7 +150,7 @@ public class Source /** * Source's velocity in world-space, for use in Doppler effect. */ - public Vector3D velocity; + public Vector3 velocity; /** * This source's volume (a float between 0.0 - 1.0). This value is used @@ -286,10 +287,10 @@ public class Source this.sourcename = sourcename; this.filenameURL = filenameURL; this.soundBuffer = soundBuffer; - position = new Vector3D( x, y, z ); + position = new Vector3( x, y, z ); this.attModel = attModel; this.distOrRoll = distOrRoll; - this.velocity = new Vector3D( 0, 0, 0 ); + this.velocity = new Vector3( 0, 0, 0 ); this.temporary = temporary; if( toStream && filenameURL != null ) @@ -311,10 +312,10 @@ public class Source toLoop = old.toLoop; sourcename = old.sourcename; filenameURL = old.filenameURL; - position = old.position.clone(); + position = new Vector3(old.position); attModel = old.attModel; distOrRoll = old.distOrRoll; - velocity = old.velocity.clone(); + velocity = new Vector3(old.velocity); temporary = old.temporary; sourceVolume = old.sourceVolume; @@ -352,10 +353,10 @@ public class Source this.sourcename = sourcename; this.filenameURL = null; this.soundBuffer = null; - position = new Vector3D( x, y, z ); + position = new Vector3( x, y, z ); this.attModel = attModel; this.distOrRoll = distOrRoll; - this.velocity = new Vector3D( 0, 0, 0 ); + this.velocity = new Vector3( 0, 0, 0 ); this.temporary = false; rawDataStream = true; @@ -730,9 +731,9 @@ public class Source */ public void setPosition( float x, float y, float z ) { - position.x = x; - position.y = y; - position.z = z; + position.setX(x); + position.setY(y); + position.setZ(z); } /** @@ -788,9 +789,9 @@ public class Source */ public void setVelocity( float x, float y, float z ) { - this.velocity.x = x; - this.velocity.y = y; - this.velocity.z = z; + this.velocity.setX(x); + this.velocity.setY(y); + this.velocity.setZ(z); } /** @@ -861,9 +862,9 @@ public class Source this.sourcename = sourcename; this.filenameURL = filenameURL; this.soundBuffer = soundBuffer; - position.x = x; - position.y = y; - position.z = z; + position.setX(x); + position.setY(y); + position.setZ(z); this.attModel = attModel; this.distOrRoll = distOrRoll; this.temporary = temporary; diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/Vector3D.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/Vector3D.java deleted file mode 100644 index de1e8c0..0000000 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/Vector3D.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright (c) 2008-2014 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ -package com.ardor3d.audio; - -/** - * The Vector3D class contains methods to simplify common 3D vector functions, - * such as cross and dot product, normalize, etc. - *<br><br> - *<b><i> SoundSystem License:</b></i><br><b><br> - * You are free to use this library for any purpose, commercial or otherwise. - * You may modify this library or source code, and distribute it any way you - * like, provided the following conditions are met: - *<br> - * 1) You may not falsely claim to be the author of this library or any - * unmodified portion of it. - *<br> - * 2) You may not copyright this library or a modified version of it and then - * sue me for copyright infringement. - *<br> - * 3) If you modify the source code, you must clearly document the changes - * made before redistributing the modified source code, so other users know - * it is not the original code. - *<br> - * 4) You are not required to give me credit for this library in any derived - * work, but if you do, you must also mention my website: - * http://www.paulscode.com - *<br> - * 5) I the author will not be responsible for any damages (physical, - * financial, or otherwise) caused by the use if this library or any part - * of it. - *<br> - * 6) I the author do not guarantee, warrant, or make any representations, - * either expressed or implied, regarding the use of this library or any - * part of it. - * <br><br> - * Author: Paul Lamb - * <br> - * http://www.paulscode.com - * </b> - */ -public class Vector3D -{ - -/** - * The vector's X coordinate. - */ - public float x; - -/** - * The vector's Y coordinate. - */ - public float y; - -/** - * The vector's Z coordinate. - */ - public float z; - -/** - * Constructor: Places the vector at the origin. - */ - public Vector3D() - { - x = 0.0f; - y = 0.0f; - z = 0.0f; - } - -/** - * Constructor: Places the vector at the specified 3D coordinates. - * @param nx X coordinate for the new vector. - * @param ny Y coordinate for the new vector. - * @param nz Z coordinate for the new vector. - */ - public Vector3D( float nx, float ny, float nz ) - { - x = nx; - y = ny; - z = nz; - } - -/** - * Returns a new instance containing the same information as this one. - * @return A new Vector3D. - */ - @Override - public Vector3D clone() - { - return new Vector3D( x, y, z ); - } - -/** - * Returns a vector containing the cross-product: A cross B. - * @param A First vector in the cross product. - * @param B Second vector in the cross product. - * @return A new Vector3D. - */ - public Vector3D cross( Vector3D A, Vector3D B ) - { - return new Vector3D( - A.y * B.z - B.y * A.z, - A.z * B.x - B.z * A.x, - A.x * B.y - B.x * A.y ); - } - -/** - * Returns a vector containing the cross-product: (this) cross B. - * @param B Second vector in the cross product. - * @return A new Vector3D. - */ - public Vector3D cross( Vector3D B ) - { - return new Vector3D( - y * B.z - B.y * z, - z * B.x - B.z * x, - x * B.y - B.x * y ); - - } - -/** - * Returns the dot-product result of: A dot B. - * @param A First vector in the dot product. - * @param B Second vector in the dot product. - * @return Dot product. - */ - public float dot( Vector3D A, Vector3D B ) - { - return( (A.x * B.x) + (A.y * B.y) + (A.z * B.z) ); - } - -/** - * Returns the dot-product result of: (this) dot B. - * @param B Second vector in the dot product. - * @return Dot product. - */ - public float dot( Vector3D B ) - { - return( (x * B.x) + (y * B.y) + (z * B.z) ); - } - -/** - * Returns the vector represented by: A + B. - * @param A First vector. - * @param B Vector to add to A. - * @return A new Vector3D. - */ - public Vector3D add( Vector3D A, Vector3D B ) - { - return new Vector3D( A.x + B.x, A.y + B.y, A.z + B.z ); - } - -/** - * Returns the vector represented by: (this) + B. - * @param B Vector to add to this one. - * @return A new Vector3D. - */ - public Vector3D add( Vector3D B ) - { - return new Vector3D( x + B.x, y + B.y, z + B.z ); - } - -/** - * Returns the vector represented by: A - B. - * @param A First vector. - * @param B Vector to subtract from A. - * @return A new Vector3D. - */ - public Vector3D subtract( Vector3D A, Vector3D B ) - { - return new Vector3D( A.x - B.x, A.y - B.y, A.z - B.z ); - } - -/** - * Returns the vector represented by: (this) - B. - * @param B Vector to subtract from this one. - * @return A new Vector3D. - */ - public Vector3D subtract( Vector3D B ) - { - return new Vector3D( x - B.x, y - B.y, z - B.z ); - } - -/** - * Returns the length of this vector. - * @return Length. - */ - public float length() - { - return (float) Math.sqrt( x * x + y * y + z * z ); - } - -/** - * Changes the length of this vector to 1.0. - */ - public void normalize() - { - double t = Math.sqrt( x*x + y*y + z*z ); - x = (float) (x / t); - y = (float) (y / t); - z = (float) (z / t); - } - -/** - * Returns a string depicting this vector. - * @return "Vector3D (x, y, z)". - */ - @Override - public String toString() - { - return "Vector3D (" + x + ", " + y + ", " + z + ")"; - } -} |