Ejemplo n.º 1
0
    public void ObserverPreCull(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = planes.Count - 1; i >= 0; i--)
            {
                var plane = planes[i];

                if (plane != null)
                {
                    var planeTransform = plane.transform;
                    var oldPosition    = planeTransform.position;
                    var observerDir    = (oldPosition - observer.transform.position).normalized;

                    plane.TempPosition = oldPosition;

                    SgtHelper.BeginStealthSet(planeTransform);
                    {
                        planeTransform.position += observerDir * ObserverOffset;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
    // Shift all bounds on top of the observer, so it never exits the view frustum
    public override void ObserverPreCull(SgtObserver observer)
    {
        base.ObserverPreCull(observer);

        FollowObservers = false;

        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                var models = group.Models;

                for (var j = models.Count - 1; j >= 0; j--)
                {
                    var model = models[j];

                    if (model != null)
                    {
                        var modelMesh = model.Mesh;

                        if (modelMesh != null)
                        {
                            var center = model.transform.InverseTransformPoint(observer.transform.position);

                            modelMesh.bounds = new Bounds(center, Size);
                        }
                    }
                }
            }
        }
    }
    // Shift all bounds on top of the observer, so it never exits the view frustum
    public override void ObserverPreCull(SgtObserver observer)
    {
        base.ObserverPreCull(observer);

        FollowObservers = false;

        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                var models = group.Models;

                for (var j = models.Count - 1; j >= 0; j--)
                {
                    var model = models[j];

                    if (model != null)
                    {
                        var modelMesh = model.Mesh;

                        if (modelMesh != null)
                        {
                            var center = model.transform.InverseTransformPoint(observer.transform.position);

                            modelMesh.bounds = new Bounds(center, Size);
                        }
                    }
                }
            }
        }
    }
    public void ObserverPreCull(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = models.Count - 1; i >= 0; i--)
            {
                var model = models[i];

                if (model != null)
                {
                    var modelTransform = model.transform;
                    var oldPosition    = modelTransform.position;
                    var observerDir    = (oldPosition - observer.transform.position).normalized;

                    model.TempPosition = oldPosition;

                    SgtHelper.BeginStealthSet(modelTransform);
                    {
                        modelTransform.position += observerDir * ObserverOffset;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 5
0
    protected void CameraPreRender(Camera camera)
    {
        if (Models != null)
        {
            for (var i = Models.Count - 1; i >= 0; i--)
            {
                var model = Models[i];

                if (model != null)
                {
                    model.Restore(camera);
                }
            }
        }

        if (Material != null)
        {
            var velocity = StretchVector;
            var observer = SgtObserver.Find(camera);

            if (observer != null)
            {
                Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);

                velocity += observer.Velocity * StretchScale;
            }

            if (Stretch == true)
            {
                Material.SetVector("_StretchVector", velocity);
                Material.SetVector("_StretchDirection", velocity.normalized);
                Material.SetFloat("_StretchLength", velocity.magnitude);
            }
        }
    }
Ejemplo n.º 6
0
    public virtual void ObserverPreCull(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);

                    if (StretchToObservers == true)
                    {
                        var velocity = (StretchOverride == true ? StretchVector : observer.Velocity) * StretchScale;

                        group.Material.SetVector("_StretchVector", velocity);
                        group.Material.SetVector("_StretchDirection", velocity.normalized);
                        group.Material.SetFloat("_StretchLength", velocity.magnitude);
                    }
                }

                if (FollowObservers == true)
                {
                    group.TempPosition = group.transform.position;

                    SgtHelper.BeginStealthSet(group.transform);
                    {
                        group.transform.position = observer.transform.position;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 7
0
 private void ObserverPreRender(SgtObserver observer)
 {
     if (Material != null)
     {
         Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);
     }
 }
Ejemplo n.º 8
0
    private void ObserverPreRender(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null && group.Material != null)
            {
                group.Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);
            }
        }
    }
Ejemplo n.º 9
0
    protected void CameraPreRender(Camera camera)
    {
        if (Material != null)
        {
            var observer = SgtObserver.Find(camera);

            if (observer != null)
            {
                Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);
            }
        }
    }
Ejemplo n.º 10
0
    public void ObserverPostRender(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = models.Count - 1; i >= 0; i--)
            {
                var model = models[i];

                if (model != null)
                {
                    var modelTransform = model.transform;

                    SgtHelper.BeginStealthSet(modelTransform);
                    {
                        modelTransform.position = model.TempPosition;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
    public void ObserverPostRender(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = models.Count - 1; i >= 0; i--)
            {
                var model = models[i];

                if (model != null)
                {
                    var modelTransform = model.transform;

                    SgtHelper.BeginStealthSet(modelTransform);
                    {
                        modelTransform.position = model.TempPosition;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 12
0
    public void ObserverPostRender(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = planes.Count - 1; i >= 0; i--)
            {
                var plane = planes[i];

                if (plane != null)
                {
                    var planeTransform = plane.transform;

                    SgtHelper.BeginStealthSet(planeTransform);
                    {
                        planeTransform.position = plane.TempPosition;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 13
0
    protected virtual void CameraPreCull(Camera camera)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    var observer = SgtObserver.Find(camera);

                    if (observer != null)
                    {
                        group.Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);

                        if (StretchToObservers == true)
                        {
                            var velocity = (StretchOverride == true ? StretchVector : observer.Velocity) * StretchScale;

                            group.Material.SetVector("_StretchVector", velocity);
                            group.Material.SetVector("_StretchDirection", velocity.normalized);
                            group.Material.SetFloat("_StretchLength", velocity.magnitude);
                        }
                    }
                }

                if (FollowObservers == true)
                {
                    if (group.TempSet == false)
                    {
                        group.TempSet      = true;
                        group.TempPosition = group.transform.position;
                    }

                    group.transform.position = camera.transform.position;
                }
            }
        }
    }
    public override void ObserverPreCull(SgtObserver observer)
    {
        base.ObserverPreCull(observer);

        var dir    = (transform.position - observer.transform.position).normalized;
        var theta  = Mathf.Abs(Vector3.Dot(transform.up, dir));
        var bright = Mathf.Lerp(HorizontalBrightness, Brightness, Mathf.Pow(theta, HorizontalPower));
        var color  = SgtHelper.Brighten(Color, bright);

        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetColor("_Color", color);
                }
            }
        }
    }
    public override void ObserverPreCull(SgtObserver observer)
    {
        base.ObserverPreCull(observer);

        var dir    = (transform.position - observer.transform.position).normalized;
        var theta  = Mathf.Abs(Vector3.Dot(transform.up, dir));
        var bright = Mathf.Lerp(HorizontalBrightness, Brightness, Mathf.Pow(theta, HorizontalPower));
        var color  = SgtHelper.Brighten(Color, bright);

        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetColor("_Color", color);
                }
            }
        }
    }
Ejemplo n.º 16
0
    public void ObserverPostRender(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetFloat("_CameraRollAngle", 0.0f);
                }

                if (FollowObservers == true)
                {
                    SgtHelper.BeginStealthSet(group.transform);
                    {
                        group.transform.position = group.TempPosition;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 17
0
    public void ObserverPreCull(SgtObserver observer)
    {
        if (ObserverOffset != 0.0f)
        {
            for (var i = models.Count - 1; i >= 0; i--)
            {
                var model = models[i];

                if (model != null)
                {
                    var modelTransform = model.transform;
                    var oldPosition    = modelTransform.position;
                    var observerDir    = (oldPosition - observer.transform.position).normalized;

                    model.TempPosition = oldPosition;

                    SgtHelper.BeginStealthSet(modelTransform);
                    {
                        modelTransform.position += observerDir * ObserverOffset;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 18
0
    public void ObserverPreCull(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null && group.Material != null)
            {
                group.Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);
            }
        }
    }
Ejemplo n.º 19
0
    public void ObserverPostRender(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetFloat("_CameraRollAngle", 0.0f);
                }

                if (FollowObservers == true)
                {
                    SgtHelper.BeginStealthSet(group.transform);
                    {
                        group.transform.position = group.TempPosition;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }
Ejemplo n.º 20
0
    public virtual void ObserverPreCull(SgtObserver observer)
    {
        for (var i = groups.Count - 1; i >= 0; i--)
        {
            var group = groups[i];

            if (group != null)
            {
                if (group.Material != null)
                {
                    group.Material.SetFloat("_CameraRollAngle", observer.RollAngle * Mathf.Deg2Rad);

                    if (StretchToObservers == true)
                    {
                        var velocity = (StretchOverride == true ? StretchVector : observer.Velocity) * StretchScale;

                        group.Material.SetVector("_StretchVector", velocity);
                        group.Material.SetVector("_StretchDirection", velocity.normalized);
                        group.Material.SetFloat("_StretchLength", velocity.magnitude);
                    }
                }

                if (FollowObservers == true)
                {
                    group.TempPosition = group.transform.position;

                    SgtHelper.BeginStealthSet(group.transform);
                    {
                        group.transform.position = observer.transform.position;
                    }
                    SgtHelper.EndStealthSet();
                }
            }
        }
    }