Esempio n. 1
0
        //public void OnRenderObject()
        //{
        //        //Material line_m = LineCreator.CreateLineMaterial();
        //        Material line_m = new Material(
        //         @"Shader ""Lines/Colored Blended"" {
        //             SubShader {
        //                 Tags { ""RenderType""=""Opaque"" }
        //                 Pass {
        //                     ZWrite On
        //                     ZTest LEqual
        //                     Cull Off
        //                     Fog { Mode Off }
        //                     BindChannels {
        //                         Bind ""vertex"", vertex Bind ""color"", color
        //                     }
        //                 }
        //             }
        //         }");
        //        line_m.SetPass(0);
        //        if (mTransforms.Length < 2)
        //            return;
        //        GL.PushMatrix();
        //        GL.Begin(GL.LINES);
        //        Vector3 prevPos = _splinePoints[0];
        //        for (int c = 1; c <= 100; c++)
        //        {
        //            Vector3 currPos = _splinePoints[c];
        //            GL.Color(new Color(0.1f, 0.1f, 0.1f, 0.5f));
        //            GL.Vertex3(prevPos.x, prevPos.y, prevPos.z);
        //            float angle = MathHelper.AngleBetween(currPos, prevPos);
        //            float dist = Vector3.Distance(currPos, prevPos);
        //            GL.Vertex3(currPos.x + dist/2 * Mathf.Cos(angle), currPos.y + dist/2 * Mathf.Sin(angle), currPos.z);
        //            prevPos = currPos;
        //        }
        //        GL.End();
        //        GL.PopMatrix();
        //}
        void Start()
        {
            _trail = Instantiate(GameValues.SplineLineTrail);

            _trail.transform.parent = transform;
            _trail.transform.localPosition = new Vector3(0, 0, -0.1f);

            mSplineInterp = GetComponent(typeof(SplineInterpolator)) as SplineInterpolator;

            mTransforms = GetTransforms();

            if (HideOnExecute)
                DisableTransforms();

            if (AutoStart)
                FollowSpline();

            PerformLineRenderer();
        }
Esempio n. 2
0
        void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
        {
            interp.Reset();

            float step = (AutoClose) ? Duration / trans.Length :
                Duration / (trans.Length - 1);

            int c;
            for (c = 0; c < trans.Length; c++)
            {
                if (OrientationMode == eOrientationMode.NODE)
                {
                    interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
                }
                else if (OrientationMode == eOrientationMode.TANGENT)
                {
                    Quaternion rot;
                    if (c != trans.Length - 1)
                        rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
                    else if (AutoClose)
                        rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
                    else
                        rot = trans[c].rotation;

                    interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
                }
            }

            if (AutoClose)
                interp.SetAutoCloseMode(step * c);
        }