Ejemplo n.º 1
0
        public void OnDrawGizmos()
        {
            if (MeshFilter.mesh == null)
            {
                MeshFilter.mesh = new Mesh();
            }

            if (Points == null || Points.Count < 3)
            {
                return;
            }

            VertList = new List <VertexDefinition>();

            float colorNum = 0f;

            var lastVert = new VertexDefinition(Points.First().position, ColorUtility.HsvtoRgb(0, .8f, 1f));

            foreach (var point in Points)
            {
                var thisVert = new VertexDefinition(point.position,
                                                    ColorUtility.HsvtoRgb(colorNum, .8f, 1f),
                                                    lastVert.Position,
                                                    point.position);

                colorNum += COLOR_MOD;
                VertList.Add(thisVert);
                lastVert.NextPosition = thisVert.Position;
                lastVert = thisVert;
            }

            // last point required here to complete triangle

            MeshFilter.mesh.Clear();

            MeshFilter.mesh.vertices = VertList.Select(vertex => vertex.Position).ToArray();
            MeshFilter.mesh.colors   = VertList.Select(vertex => vertex.Color).ToArray();
            MeshFilter.mesh.normals  = VertList.Select(vertex => vertex.NextPosition - vertex.Position).ToArray();
            MeshFilter.mesh.tangents = VertList.Select(vertex => (vertex.LastPosition - vertex.Position).ConvertToVector4()).ToArray();


            var indices = new List <int>();

            for (var i = 0; i < VertList.Count; i++)
            {
                indices.Add(i);
            }

            MeshFilter.mesh.SetIndices(indices.ToArray(), MeshTopology.LineStrip, 0);

            MeshFilter.mesh.UploadMeshData(false);
        }
Ejemplo n.º 2
0
        protected override Color ColorLerp(MutableObject mutable, Color a, Color b, float proportion)
        {
            float H1, S1, V1;
            float H2, S2, V2;

            ColorUtility.RGBToHSV(a, out H1, out S1, out V1);
            ColorUtility.RGBToHSV(b, out H2, out S2, out V2);

            float endH = ApplyHLerpField.GetFirstValue(mutable) ? H1 + (H2 - H1) * proportion : H2;
            float endS = ApplySLerpField.GetFirstValue(mutable) ? S1 + (S2 - S1) * proportion : S2;
            float endV = ApplyVLerpField.GetFirstValue(mutable) ? V1 + (V2 - V1) * proportion : V2;

            Color endColor = ColorUtility.HsvtoRgb(endH, endS, endV);

            endColor.a = DoApplyAlphaField.GetFirstValue(mutable)?a.a + (b.a - a.a) * proportion:b.a;

            return(endColor);
        }