Esempio n. 1
0
        private void GenerateGeometry(SpriteCache sprite, float outlineDetail, byte alphaTolerance, float subdivide)
        {
            Debug.Assert(sprite != null);

            var mesh = sprite.GetMesh();

            Debug.Assert(mesh != null);

            m_SpriteMeshDataController.spriteMeshData = mesh;
            m_SpriteMeshDataController.OutlineFromAlpha(m_OutlineGenerator, mesh.textureDataProvider, outlineDetail, alphaTolerance);
            m_SpriteMeshDataController.Triangulate(m_Triangulator);

            if (subdivide > 0f)
            {
                var largestAreaFactor = Mathf.Lerp(0.5f, 0.05f, Math.Min(subdivide, 100f) / 100f);
                m_SpriteMeshDataController.Subdivide(m_Triangulator, largestAreaFactor);
            }

            foreach (var vertex in mesh.vertices)
            {
                vertex.position -= sprite.textureRect.position;
            }
        }
 private void Triangulate()
 {
     m_SpriteMeshDataController.Triangulate(triangulator);
     m_SpriteMeshDataController.SortTrianglesByDepth();
 }