Commit 85307ecf authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas

Rotationsübertragung von Linkshändisch in Rechtshändisch

Directivity Variable hinzugefügt
parent 5e781de8
......@@ -64,6 +64,13 @@ namespace VA
NativeSetListenerOrientationYPR(_NetClient, iListenerID, yaw, pitch, roll);
}
public void SetListenerOrientationVU( int iListenerID,
double vx, double vy, double vz,
double ux, double uy, double uz)
{
NativeSetListenerOrientationVU(_NetClient, iListenerID, vx, vy, vz, ux, uy, uz);
}
public int CreateSoundSource(string sName, int iAuralizationMode, double dVolume)
{
return NativeCreateSoundSource(_NetClient, sName, iAuralizationMode, dVolume);
......@@ -78,6 +85,12 @@ namespace VA
NativeSetSoundSourceOrientationYPR(_NetClient, iSoundSourceID, yaw, pitch, roll);
}
public void SetSoundSourceOrientationVU(int iSoundSourceID,
double vx, double vy, double vz,
double ux, double uy, double uz)
{
NativeSetListenerOrientationVU(_NetClient, iSoundSourceID, vx, vy, vz, ux, uy, uz);
}
public int LoadHRIRDataset(string FilePath, string Name)
{
Console.WriteLine("test");
......@@ -186,6 +199,25 @@ namespace VA
{
NativeSetListenerHRIRDataset(_NetClient,iListenerID, iHRIRDatasetID);
}
public void GetListenerPositionOrientationVU(int iListenerID,
double px, double py, double pz,
double vx, double vy, double vz,
double ux, double uy, double uz)
{
NativeGetListenerPositionOrientationVU(_NetClient, iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz);
}
public void SetListenerPositionOrientationVU(int iListenerID,
double px, double py, double pz,
double vx, double vy, double vz,
double ux, double uy, double uz)
{
NativeSetListenerPositionOrientationVU(_NetClient, iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz);
}
public void SetSoundSourceDirectivity(int iSoundSourceID, int iDirectivityID)
{
NativeSetSoundSourceDirectivity(_NetClient, iSoundSourceID, iDirectivityID);
}
/*
* Native imported functions from C++ unmanaged library declared private, so they can not be accessed
* directly through C# class method
......
......@@ -10,10 +10,12 @@ using VA;
public class VAUAdapter : MonoBehaviour {
public static string HostIP = "localhost";
public static int Port = 12340;
public static string DefaultHRIRPath = "$(DefaultHRIR)";
private static string HostIP = "localhost";
private static int Port = 12340;
private static string DefaultHRIRPath = "$(DefaultHRIR)";
private static string DefaultDirectivityPath = "$(DefaultDirectivity)";
private static int defaulthrir;
private static int defaultdirectivity;
private static VANet _VA = null;
// No public construction allowed
......@@ -41,6 +43,7 @@ public class VAUAdapter : MonoBehaviour {
_VA.Connect(HostIP, Port);
_VA.Reset();
defaulthrir = _VA.LoadHRIRDataset(DefaultHRIRPath, "DefaultHRIR");
//defaultdirectivity = _VA.LoadDirectivity(DefaultDirectivityPath, "DefaultDirectivity");
}
catch(ExternalException e)
{
......@@ -56,7 +59,15 @@ public class VAUAdapter : MonoBehaviour {
}
}
public static int DefaultDirectivity
{
get
{
return defaultdirectivity;
}
}
// Use this for initialization
void Awake()
{
......
......@@ -10,9 +10,16 @@ public class VAUListener : MonoBehaviour {
public int auramode = 123;
private int Listener;
private VANet _VA = null;
private Vector3 viewvec;
private Vector3 upvec;
private Quaternion q;
private Transform t;
// Use this for initialization
void Start()
{
upvec.Set(0, 1, 0);
viewvec.Set(0, 0, 1);
_VA = VAUAdapter.VA;
Listener = _VA.CreateListener(listenername, auramode, VAUAdapter.DefaultHRIR);
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
......@@ -21,11 +28,22 @@ public class VAUListener : MonoBehaviour {
// Update is called once per frame
void Update ()
{
Transform t = GetComponent<Transform>();
t = GetComponent<Transform>();
q = t.rotation;
Vector3 up = q * upvec;
Vector3 view = q * viewvec;
Vector3 view_ogl = new Vector3(view.x, view.y, -view.z);
Vector3 up_ogl = new Vector3(up.x, up.y, -up.z);
_VA.SetListenerPosition(Listener, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetListenerOrientationYPR(Listener, -t.transform.rotation.eulerAngles.x, -t.transform.rotation.eulerAngles.y, t.transform.rotation.eulerAngles.z);
_VA.SetListenerOrientationVU(Listener, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
//Quaternion q_ogl = new Quaternion(q.x, q.y, -q.z, -q.w);
//Vector3 t1 = new Vector3(0, 0, 1);
//Vector3 t1_ogl = ( q_ogl * t1 ); // result: 0 0 -1
// Debug.Log(t1_ogl);
}
//void OnDestroy()
//{
// _VA.DeleteListener(Listener);
......
......@@ -12,6 +12,10 @@ public class VAUSoundSource : MonoBehaviour {
public string SignalSource = "";
private VANet _VA = null;
private int SoundSource;
private Vector3 viewvec;
private Vector3 upvec;
private Quaternion q;
private Transform t;
private bool islooping;
private bool ismuted;
......@@ -35,9 +39,15 @@ public class VAUSoundSource : MonoBehaviour {
void Update()
{
//position and oritentation -> VA
Transform t = GetComponent<Transform>();
t = GetComponent<Transform>();
q = t.rotation;
Vector3 up = q * upvec;
Vector3 view = q * viewvec;
Vector3 view_ogl = new Vector3(view.x, view.y, -view.z);
Vector3 up_ogl = new Vector3(up.x, up.y, -up.z);
_VA.SetSoundSourcePosition(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetSoundSourceOrientationYPR(SoundSource, -t.transform.rotation.eulerAngles.x, -t.transform.rotation.y, t.transform.rotation.eulerAngles.z);
_VA.SetSoundSourceOrientationVU(SoundSource, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
ismuted = GetComponent<AudioSource>().mute;
_VA.SetSoundSourceMuted(SoundSource, ismuted);
//_VA.SetSoundSourceVolume(SoundSource, Volume); <- flaot ändern
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment