void Update() { // case needs to update PV information if (id >= 0) { // case this object is currently playing: update the emission, and update the output if (source) { PlaneverbContext.UpdateEmission(id, transform.position); PlaneverbDSPContext.UpateEmitter(id, transform.position, transform.forward); output = PlaneverbContext.GetOutput(id); } // case this emission has ended since the last frame: end emission and reset the id else { OnEndEmission(); id = -1; } if (PlaneverbContext.GetInstance().debugDraw) { Debug.DrawRay(transform.position, transform.forward); } } }
void OnDestroy() { // remove from context when object is destroyed if (id != INVALID_ID) { PlaneverbContext.RemoveGeometry(id); } }
void Start() { // enable singleton pattern Debug.AssertFormat(instance == null, "More than one instance of the PlaneverbListener created! Singleton violated."); instance = this; // init listener information in both contexts PlaneverbContext.SetListenerPosition(transform.position); PlaneverbDSPContext.SetListenerTransform(transform.position, transform.forward); }
private void Awake() { PlaneverbInit(config.gridSizeInMeters.x, config.gridSizeInMeters.y, (int)config.gridResolution, (int)config.gridBoundaryType, config.tempFileDirectory, config.maxThreadUsage, (int)config.threadExecutionType); Debug.AssertFormat(contextInstance == null, "More than one instance of the PlaneverbContext created! Singleton violated."); contextInstance = this; }
void Start() { // calculate AABB and add to context bounds = GetMaxBounds(); isInHeadSlice = IsWithinPlayerHeadSlice(bounds); if (isInHeadSlice) { AABB properties = CalculateAABB(bounds); id = PlaneverbContext.AddGeometry(properties); } }
void Update() { // update listener information in both contexts PlaneverbContext.SetListenerPosition(transform.position); PlaneverbDSPContext.SetListenerTransform(transform.position, transform.forward); oldPosition = transform.position; if (PlaneverbContext.GetInstance().debugDraw) { Debug.DrawRay(transform.position, transform.forward, new Color(0f, 0f, 1f)); } }
// two versions of Emit. one for playing stored Clip, other for AudioSource.PlayOneShot functionality public void Emit() { // start the emission and create the source id = PlaneverbContext.Emit(transform.position); PlaneverbDSPContext.UpateEmitter(id, transform.position, transform.forward); PlaneverbDSPContext.SetEmitterDirectivityPattern(id, DirectivityPattern); output = PlaneverbContext.GetOutput(id); source = PlaneverbAudioManager.pvDSPAudioManager.Play(Clip, id, this, Loop); if (source == null) { OnEndEmission(); } }
void Update() { // only add if object is at player head slice bounds = GetMaxBounds(); isInHeadSlice = IsWithinPlayerHeadSlice(bounds); if (isInHeadSlice) { // calculate the AABB AABB properties = CalculateAABB(bounds); // update geometry in the context if (id == INVALID_ID) { id = PlaneverbContext.AddGeometry(properties); } else { PlaneverbContext.UpdateGeometry(id, properties); } } else if (id != INVALID_ID) { PlaneverbContext.RemoveGeometry(id); id = INVALID_ID; } if (PlaneverbContext.GetInstance().debugDraw) { Color drawColor; if (isInHeadSlice) { drawColor = new Color(0f, 1f, 0f); } else { drawColor = new Color(1f, 0f, 0f); } // debug draw the bounds Vector3 c = bounds.center; Vector3 e = bounds.extents; // half extents Vector3 bbl = c - e; // bottom back left Vector3 bbr = new Vector3(c.x + e.x, c.y - e.y, c.z - e.z); // bottom back right Vector3 tbl = new Vector3(c.x - e.x, c.y + e.y, c.z - e.z); // top back left Vector3 tbr = new Vector3(c.x + e.x, c.y + e.y, c.z - e.z); // top back right Vector3 bfl = new Vector3(c.x - e.x, c.y - e.y, c.z + e.z); // bottom front left Vector3 bfr = new Vector3(c.x + e.x, c.y - e.y, c.z + e.z); // bottom front right Vector3 tfl = new Vector3(c.x - e.x, c.y + e.y, c.z + e.z); // top front left Vector3 tfr = c + e; // top front right // connect all the points Debug.DrawLine(bbl, bbr, drawColor); Debug.DrawLine(bbl, bfl, drawColor); Debug.DrawLine(bbl, tbl, drawColor); Debug.DrawLine(bbr, tbr, drawColor); Debug.DrawLine(bbr, bfr, drawColor); Debug.DrawLine(bfl, bfr, drawColor); Debug.DrawLine(bfl, tfl, drawColor); Debug.DrawLine(bfr, tfr, drawColor); Debug.DrawLine(tbl, tbr, drawColor); Debug.DrawLine(tbl, tfl, drawColor); Debug.DrawLine(tbr, tfr, drawColor); Debug.DrawLine(tfl, tfr, drawColor); } }
public void OnEndEmission() { // end the emission in planeverb, and reset ID PlaneverbContext.EndEmission(id); id = -1; }