OSDN Git Service

Maybe rotations are better.
authorMojito Sorbet <mojitotech@gmail.com>
Mon, 31 May 2010 21:53:17 +0000 (21:53 +0000)
committerMojito Sorbet <mojitotech@gmail.com>
Mon, 31 May 2010 21:53:17 +0000 (21:53 +0000)
git-svn-id: https://radegast.googlecode.com/svn/branches/sounds@666 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/Media/BufferSound.cs
Radegast/Core/Media/MediaManager.cs

index 4b7baec..07bdcd2 100644 (file)
@@ -190,7 +190,7 @@ namespace Radegast.Media
                     return;\r
                 }\r
 \r
-                Logger.Log("Opening sound " + Id.ToString(), Helpers.LogLevel.Debug);\r
+//                Logger.Log("Opening sound " + Id.ToString(), Helpers.LogLevel.Debug);\r
 \r
                 // Decode the Ogg Vorbis buffer.\r
                 AssetSound s = asset as AssetSound;\r
index ccf6c31..e795545 100644 (file)
@@ -122,7 +122,8 @@ namespace Radegast.Media
                 }
                 catch (Exception e)
                 {
-                    Logger.Log("Error in sound action: " + e.Message,
+
+                    Logger.Log("Error in sound action:\n    " + e.Message + "\n" + e.StackTrace,
                         Helpers.LogLevel.Error);
                 }
             }
@@ -263,6 +264,7 @@ namespace Radegast.Media
 
                 AgentManager my = Instance.Client.Self;
                 Vector3 newPosition = new Vector3(my.SimPosition);
+                float newFace = my.SimRotation.W;
 
                 // If we are standing still, nothing to update now, but
                 // FMOD needs a 'tick' anyway for callbacks, etc.  In looping
@@ -272,7 +274,7 @@ namespace Radegast.Media
                 // 500mm or turn more than 10 desgrees to bother with.
                 //
                 if (newPosition.ApproxEquals(lastpos, 0.5f) &&
-                    Math.Abs(my.Movement.BodyRotation.W - lastface) < 0.2)
+                    Math.Abs(newFace - lastface) < 0.2)
                 {
                     invoke(new SoundDelegate(delegate
                     {
@@ -283,7 +285,7 @@ namespace Radegast.Media
 
                 // We have moved or turned.  Remember new position.
                 lastpos = newPosition;
-                lastface = my.Movement.BodyRotation.W;
+                lastface = newFace;
 
                 // Convert coordinate spaces.
                 FMOD.VECTOR listenerpos = FromOMVSpace(newPosition);
@@ -293,9 +295,10 @@ namespace Radegast.Media
                 // hear things from unpredictable directions.
                 // By definition, facing.W = Cos( angle/2 )
                 // With angle=0 meaning East.
-                double angle = 2.0 * Math.Acos(my.Movement.BodyRotation.W);
+                double angle = 2.0 * Math.Acos(newFace);
 
                 // Construct facing unit vector in FMOD coordinates.
+                // Z is East, X is South, Y is up.
                 FMOD.VECTOR forward = new FMOD.VECTOR();
                 forward.x = (float)Math.Sin(-angle); // South
                 forward.y = 0.0f;