Example #1
0
        private void UpdateVertex()
        {
            VertexPool pool = mVertexSegment.Pool;

            for (int i = 0; i < Granularity; i++)
            {
                int     num     = mVertexSegment.VertStart + i * 3;
                float   num2    = (float)i / (float)Granularity;
                float   tl      = num2 * mFadeT;
                Vector2 zero    = Vector2.zero;
                Vector3 vector  = mSpline.InterpolateByLen(tl);
                Vector3 vector2 = mSpline.InterpolateNormalByLen(tl);
                Vector3 vector3 = vector + vector2.normalized * mTrailWidth * 0.5f;
                Vector3 vector4 = vector - vector2.normalized * mTrailWidth * 0.5f;
                pool.Vertices[num]     = vector3;
                pool.Colors[num]       = MyColor;
                zero.x                 = 0f;
                zero.y                 = num2;
                pool.UVs[num]          = zero;
                pool.Vertices[num + 1] = vector;
                pool.Colors[num + 1]   = MyColor;
                zero.x                 = 0.5f;
                zero.y                 = num2;
                pool.UVs[num + 1]      = zero;
                pool.Vertices[num + 2] = vector4;
                pool.Colors[num + 2]   = MyColor;
                zero.x                 = 1f;
                zero.y                 = num2;
                pool.UVs[num + 2]      = zero;
            }
            mVertexSegment.Pool.UVChanged    = true;
            mVertexSegment.Pool.VertChanged  = true;
            mVertexSegment.Pool.ColorChanged = true;
        }
Example #2
0
        void UpdateVertex()
        {
            if (mSpline.Segments.Count == 0)
            {
                return;
            }

            VertexPool pool = mVertexSegment.Pool;


            for (int i = 0; i < Granularity; i++)
            {
                int baseIdx = mVertexSegment.VertStart + i * 3;

                float uvSegment = (float)i / Granularity;


                float fadeT = uvSegment * mFadeT;

                Vector2 uvCoord = Vector2.zero;

                Vector3 pos = mSpline.InterpolateByLen(fadeT);

                //Debug.DrawRay(pos, Vector3.up, Color.red);

                Vector3 up   = mSpline.InterpolateNormalByLen(fadeT);
                Vector3 pos0 = pos + (up.normalized * mTrailWidth * 0.5f);
                Vector3 pos1 = pos - (up.normalized * mTrailWidth * 0.5f);


                // pos0
                pool.Vertices[baseIdx] = pos0;
                pool.Colors[baseIdx]   = MyColor;
                uvCoord.x         = 0f;
                uvCoord.y         = uvSegment;
                pool.UVs[baseIdx] = uvCoord;

                //pos
                pool.Vertices[baseIdx + 1] = pos;
                pool.Colors[baseIdx + 1]   = MyColor;
                uvCoord.x             = 0.5f;
                uvCoord.y             = uvSegment;
                pool.UVs[baseIdx + 1] = uvCoord;

                //pos1
                pool.Vertices[baseIdx + 2] = pos1;
                pool.Colors[baseIdx + 2]   = MyColor;
                uvCoord.x             = 1f;
                uvCoord.y             = uvSegment;
                pool.UVs[baseIdx + 2] = uvCoord;
            }

            mVertexSegment.Pool.UVChanged    = true;
            mVertexSegment.Pool.VertChanged  = true;
            mVertexSegment.Pool.ColorChanged = true;
        }