Commit b6df6209 authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas

Prefabs CameraRig nur temporär

parent 0d65e825
using UnityEngine;
using System;
using System.Linq;
using System.Collections;
using VA;
......@@ -14,8 +14,8 @@ public class VAUListener : MonoBehaviour {
private Quaternion q;
private Transform t;
private AudioReverbZone[] reverbZones;
private AudioReverbZone[] shadowReverbZones;
private double currentArtificialReverberationTime = 1;
private float currentArtificialReverberationTime = 0f;
private float shadowReverbTime;
public int ID
{
......@@ -35,7 +35,8 @@ public class VAUListener : MonoBehaviour {
Debug.Log("[VAU]" + listenername + " created");
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
SetListenerPositionOrientation();
_VA.SetArtificalReverbarationTime(VAAudioRenderer, 2);
_VA.SetArtificalReverbarationTime(VAAudioRenderer, 2.0f);
reverbZones = FindObjectsOfType(typeof(AudioReverbZone)) as AudioReverbZone[];
}
void OnEnable()
......@@ -66,42 +67,39 @@ public class VAUListener : MonoBehaviour {
void SetActiveReverbZones()
{
double actReverbTime = currentArtificialReverberationTime;
reverbZones = FindObjectsOfType(typeof(AudioReverbZone)) as AudioReverbZone[];
if (reverbZones == shadowReverbZones)
return;
if (reverbZones == null)
{
if (actReverbTime != currentArtificialReverberationTime)
_VA.SetArtificalReverbarationTime(VAAudioRenderer, actReverbTime);
return;
}
shadowReverbZones = reverbZones;
float actReverbTime = 0f;
int i = 0;
foreach (AudioReverbZone reverbZone in reverbZones)
{
float actdistance = Vector3.Distance(reverbZone.transform.position, gameObject.transform.position);
if (actdistance < reverbZone.maxDistance)
if (i >= maxreverbZones)
break;
float actDistance = Vector3.Distance(reverbZone.transform.position, gameObject.transform.position);
if ((actDistance < reverbZone.maxDistance))
{
if (i <= maxreverbZones)
if (actDistance > reverbZone.minDistance)
{
actReverbTime += reverbZone.decayTime;
i++;
actReverbTime += reverbZone.decayTime * (actDistance - reverbZone.minDistance) / (reverbZone.maxDistance - reverbZone.minDistance);
}
if (actdistance > reverbZone.minDistance)
else
{
actReverbTime += reverbZone.decayTime;
}
i++;
}
}
if (shadowReverbTime == actReverbTime)
return;
shadowReverbTime = actReverbTime;
if ( i > 0)
if (i > 0)
actReverbTime /= i;
_VA.SetArtificalReverbarationTime(VAAudioRenderer, actReverbTime);
if( actReverbTime != currentArtificialReverberationTime)
_VA.SetArtificalReverbarationTime(VAAudioRenderer, actReverbTime);
}
void OnListenerAuralizationModeChanged(string AuraMode)
......
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