Aufgrund einer Wartung wird GitLab am 25.01 zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 25.01 between 8:00 and 9:00 am.

VAUListener.cs 1.43 KB
Newer Older
1
2
3
4
5
6
7
8
using UnityEngine;
using System;
using System.Collections;
using VA;


public class VAUListener : MonoBehaviour {

9
10
11
12
    public string listenername = "MyListener";
    public int auramode = 123;
    private int Listener;
    private VANet _VA = null;
13
14
    private Quaternion q;
    private Transform t;
15
16
17
18
19
20
21
22
23

    public int ID
    {
        get
        {
            return Listener;
        }
    }

24
25
26
    // Use this for initialization
    void Start()
    {
27
28
        _VA = VAUAdapter.VA;
        Listener = _VA.CreateListener(listenername, auramode, VAUAdapter.DefaultHRIR);
29
        Debug.Log("Listener " + Listener + " created");
30
        _VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
31
32
33
34
35
    }
	
	// Update is called once per frame
	void Update ()
    {
36
37
        t = GetComponent<Transform>();
        q = t.rotation;
38
39
        Vector3 up = q * Vector3.up;
        Vector3 view = q * Vector3.forward;
40
41
42
        Vector3 view_ogl = new Vector3(view.x, view.y, -view.z);
        Vector3 up_ogl = new Vector3(up.x, up.y, -up.z);

43
        _VA.SetListenerPosition(Listener, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
44
45
46
47
48
        _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);
49
50
    }
}