Adding sound receiver tracking (aka real world pose in VA)

parent db7e14a4
using UnityEngine;
using System.Linq;
using System.Collections;
using VA;
public class VAUSoundReceiverTracking : MonoBehaviour
{
[Tooltip("Set the corresponding receiver that should be updated")]
public VAUSoundReceiver Receiver = null;
void Start()
{
if( Receiver && Receiver.ID > 0 )
SetSoundReceiverRealWorldHeadPose();
}
void OnEnable()
{
}
void Update()
{
if( Receiver && Receiver.ID > 0 )
SetSoundReceiverRealWorldHeadPose();
}
protected void SetSoundReceiverRealWorldHeadPose()
{
Vector3 p = GetComponent<Transform>().transform.position; // Unity coordinate system
VAVec3 v3PosOpenGL = new VAVec3(p.x, p.y, -p.z); // OpenGL coordinate system
Quaternion q = GetComponent<Transform>().transform.rotation; // Unity coordinate system
VAQuat qOrientOpenGL = new VAQuat( q.x, q.y, -q.z, q.w ); // OpenGL coordinate system
VAUAdapter.VA.SetSoundReceiverRealWorldHeadPose(Receiver.ID, v3PosOpenGL, qOrientOpenGL );
Debug.Log( "performed update, new q:" + p + q );
}
private void OnDestroy()
{
}
}
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