Esempio n. 1
0
        static void GenerateOutline(SpriteCache sprite, ITextureDataProvider textureDataProvider,
                                    out List <Vertex2D> vertices, out List <int> indices, out List <Edge> edges)
        {
            if (textureDataProvider == null ||
                textureDataProvider.texture == null)
            {
                vertices = new List <Vertex2D>();
                indices  = new List <int>();
                edges    = new List <Edge>();
                return;
            }

            const float detail         = 0.05f;
            const byte  alphaTolerance = 200;

            var smd = new SpriteMeshData
            {
                spriteID = new GUID(sprite.id),
                frame    = sprite.textureRect,
                pivot    = sprite.pivotNormalized
            };

            var meshDataController = new SpriteMeshDataController
            {
                spriteMeshData = smd
            };

            meshDataController.OutlineFromAlpha(new OutlineGenerator(), textureDataProvider, detail, alphaTolerance);
            meshDataController.Triangulate(new Triangulator());

            vertices = smd.vertices;
            indices  = smd.indices;
            edges    = smd.edges;
        }
Esempio n. 2
0
        private void OnBoneDepthChanged(BoneCache bone)
        {
            var sprites    = skinningCache.GetSprites();
            var controller = new SpriteMeshDataController();

            foreach (var sprite in sprites)
            {
                var mesh = sprite.GetMesh();

                if (mesh.ContainsBone(bone))
                {
                    controller.spriteMeshData = mesh;
                    controller.SortTrianglesByDepth();
                    skinningCache.events.meshChanged.Invoke(mesh);
                }
            }

            DataModified();
        }