Exemplo n.º 1
0
        public bool ProcessBarrier(Mp3_TravelingBall b, Transform shadowXform)
        {
            bool castShadow = false;

            if (Barrier.PtInfrontOf(b.GetPosition()))
            {
                float   d         = Barrier.DistantToPoint(b.GetPosition());
                Vector3 onBarrier = b.GetPosition() - Barrier.GetNormal() * d;

                if (Barrier.InActiveZone(onBarrier))
                {
                    castShadow = true;
                    // first, process shadow
                    Quaternion q = Quaternion.FromToRotation(Vector3.up, Barrier.GetNormal());
                    shadowXform.localRotation = q;
                    shadowXform.localPosition = onBarrier + Barrier.GetNormal() * 0.1f; // slight offet
                    shadowXform.localScale    = new Vector3(1f, 0.1f, 1f);

                    if (Mathf.Abs(d) < 0.1f) // close enough
                    {
                        if (b.TravelTowards(Barrier.GetNormal()))
                        {
                            b.ReflectDir(Barrier.GetNormal());
                        }
                    }
                }
            }
            return(castShadow);
        }