Esempio n. 1
0
        public Mesh Generate(IEnumerable <Vector2> line)
        {
            var mesh = ThirdPartyMeshGenerator.Generate(line);

            var result = new Mesh();

            result.vertices  = CalculateVertices(mesh);
            result.triangles = CalculateTriangles(mesh);
            result.uv        = uvCalculator.Calculate(mesh);

            return(result);
        }
Esempio n. 2
0
        public void StatelessDraw(Rect rect, ISample sample)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            EditorGUI.DrawRect(rect, Color.gray);

            if (!sample.IsDrawn)
            {
                return;
            }

            var factor = Factor(rect, sample.Vertices);

            if ((layers.Value & Layer.HandMade) == Layer.HandMade)
            {
                var verticles = NormalizedVertices(sample.Vertices, factor);
                DrawDots(rect, verticles, Color.red);
            }

            if (layers.Value == Layer.HandMade)
            {
                return;
            }

            if (!sample.IsPropagated)
            {
                return;
            }

            if ((layers.Value & Layer.Propogated) == Layer.Propogated)
            {
                var equalDistance = NormalizedVertices(sample.EqualDistance, factor);
                DrawDots(rect, equalDistance, Color.green);
            }

            if ((layers.Value & Layer.SubSample) == Layer.SubSample)
            {
                pool?.Draw(rect.Intend(dotSize));
            }

            if (!sample.HasCircuit)
            {
                return;
            }

            var meshCircuit = NormalizedVertices(sample.Circuit, factor);
            var mesh        = ThirdPartyMeshGenerator.Generate(meshCircuit);

            if ((layers.Value & Layer.MeshSegments) == Layer.MeshSegments)
            {
                DrawTriangles(rect, mesh);
            }

            if ((layers.Value & Layer.MeshCircuit) == Layer.MeshCircuit)
            {
                var circuit = NormalizedVertices(sample.Circuit, factor);
                DrawLine(rect, circuit, Color.magenta);
            }

            if ((layers.Value & Layer.MeshVerticles) == Layer.MeshVerticles)
            {
                DrawVertices(rect, mesh, Color.blue);
            }

            if ((layers.Value & Layer.Texture) == Layer.Texture)
            {
                var trueMesh = new MeshGenerator(UvAlgorithm.Mask).Generate(meshCircuit);
                DrawMeshPreview(rect, trueMesh);
            }
        }