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 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));
            }
        }
Exemple #3
0
        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);
            }
        }