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

VAUListener.cs 1.46 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 Vector3 viewvec = new Vector3(0, 0, 1);
    private Vector3 upvec = new Vector3(0, 1, 0);
15 16
    private Quaternion q;
    private Transform t;
17 18 19
    // Use this for initialization
    void Start()
    {
20 21
        _VA = VAUAdapter.VA;
        Listener = _VA.CreateListener(listenername, auramode, VAUAdapter.DefaultHRIR);
22
        _VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
23 24 25 26 27
    }
	
	// Update is called once per frame
	void Update ()
    {
28 29 30 31 32 33 34
        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);

35
        _VA.SetListenerPosition(Listener, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
36 37 38 39 40
        _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);
41 42
    }

43 44 45 46 47

    void OnDestroy()
    {
        int i = _VA.DeleteListener(Listener);
    }
48

49 50

}