Ejemplo n.º 1
0
        public static Vertices CreatePolygonFromTextureData(Nez.Textures.Subtexture subtexture)
        {
            var data = new uint[subtexture.SourceRect.Width * subtexture.SourceRect.Height];

            subtexture.Texture2D.GetData(0, subtexture.SourceRect, data, 0, data.Length);
            return(TextureConverter.DetectVertices(data, subtexture.Texture2D.Width));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Detects the vertices by analyzing the texture data.
 /// </summary>
 /// <param name="data">The texture data.</param>
 /// <param name="width">The texture width.</param>
 /// <param name="hullTolerance">The hull tolerance.</param>
 /// <param name="alphaTolerance">The alpha tolerance.</param>
 /// <param name="multiPartDetection">if set to <c>true</c> it will perform multi part detection.</param>
 /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
 /// <returns></returns>
 public static List <Vertices> CreatePolygonFromTextureData(uint[] data, int width, float hullTolerance,
                                                            byte alphaTolerance, bool multiPartDetection,
                                                            bool holeDetection)
 {
     return(TextureConverter.DetectVertices(data, width, hullTolerance, alphaTolerance,
                                            multiPartDetection, holeDetection));
 }
Ejemplo n.º 3
0
        public static Vertices CreatePolygonFromTextureData(Texture2D texture)
        {
            var data = new uint[texture.Width * texture.Height];

            texture.GetData(data, 0, data.Length);
            return(TextureConverter.DetectVertices(data, texture.Width));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Detects the vertices of the supplied texture data. (PolygonDetectionType.Integrated)
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <returns></returns>
        public static Vertices DetectVertices(uint[] data, int width)
        {
            TextureConverter tc = new TextureConverter(data, width);

            List <DetectedVertices> detectedVerticesList = tc.DetectVertices();

            return(detectedVerticesList[0]);
        }
        /// <summary>
        /// Detects the vertices by analyzing the texture data.
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
        /// <returns></returns>
        public static Vertices CreatePolygon(int[] data, int width, bool holeDetection)
        {
#if UNITY_FLASH
            return(new Vertices());
#else
            return(TextureConverter.DetectVertices(data, width, holeDetection));
#endif
        }
        /// <summary>
        /// Detects the vertices by analyzing the texture data.
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <param name="hullTolerance">The hull tolerance.</param>
        /// <param name="alphaTolerance">The alpha tolerance.</param>
        /// <param name="multiPartDetection">if set to <c>true</c> it will perform multi part detection.</param>
        /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
        /// <returns></returns>
        public static List <Vertices> CreatePolygon(int[] data, int width, float hullTolerance,
                                                    byte alphaTolerance, bool multiPartDetection, bool holeDetection)
        {
#if UNITY_FLASH
            return(new List <Vertices>());
#else
            return(TextureConverter.DetectVertices(data, width, hullTolerance, alphaTolerance,
                                                   multiPartDetection, holeDetection));
#endif
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Detects the vertices of the supplied texture data.
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
        /// <param name="hullTolerance">The hull tolerance.</param>
        /// <param name="alphaTolerance">The alpha tolerance.</param>
        /// <param name="multiPartDetection">if set to <c>true</c> it will perform multi part detection.</param>
        /// <returns></returns>
        public static List <Vertices> DetectVertices(uint[] data, int width, float hullTolerance,
                                                     byte alphaTolerance, bool multiPartDetection, bool holeDetection)
        {
            TextureConverter tc =
                new TextureConverter(data, width)
            {
                HullTolerance      = hullTolerance,
                AlphaTolerance     = alphaTolerance,
                MultipartDetection = multiPartDetection,
                HoleDetection      = holeDetection
            };

            List <DetectedVertices> detectedVerticesList = tc.DetectVertices();
            List <Vertices>         result = new List <Vertices>();

            for (int i = 0; i < detectedVerticesList.Count; i++)
            {
                result.Add(detectedVerticesList[i]);
            }

            return(result);
        }
Ejemplo n.º 8
0
 public static Vertices CreatePolygon(uint[] data, int width, int height, bool holeDetection)
 {
     return(TextureConverter.CreateVertices(data, width, height, holeDetection));
 }
Ejemplo n.º 9
0
 public static Vertices CreatePolygon(uint[] data, int width, int height)
 {
     return(TextureConverter.CreateVertices(data, width, height));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Detects the vertices by analyzing the texture data.
 /// </summary>
 /// <param name="data">The texture data.</param>
 /// <param name="width">The texture width.</param>
 /// <returns></returns>
 public static Vertices CreatePolygon(uint[] data, int width)
 {
     return(TextureConverter.DetectVertices(data, width));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Detects the vertices of the supplied texture data.
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
        /// <param name="hullTolerance">The hull tolerance.</param>
        /// <param name="alphaTolerance">The alpha tolerance.</param>
        /// <param name="multiPartDetection">if set to <c>true</c> it will perform multi part detection.</param>
        /// <returns></returns>
        public static List<Vertices> DetectVertices(uint[] data, int width, float hullTolerance,
                                                    byte alphaTolerance, bool multiPartDetection, bool holeDetection)
        {
            TextureConverter tc =
                new TextureConverter(data, width)
                {
                    HullTolerance = hullTolerance,
                    AlphaTolerance = alphaTolerance,
                    MultipartDetection = multiPartDetection,
                    HoleDetection = holeDetection
                };

            List<DetectedVertices> detectedVerticesList = tc.DetectVertices();
            List<Vertices> result = new List<Vertices>();

            for (int i = 0; i < detectedVerticesList.Count; i++)
            {
                result.Add(detectedVerticesList[i]);
            }

            return result;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Detects the vertices of the supplied texture data.
        /// </summary>
        /// <param name="data">The texture data.</param>
        /// <param name="width">The texture width.</param>
        /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
        /// <returns></returns>
        public static Vertices DetectVertices(uint[] data, int width, bool holeDetection)
        {
            TextureConverter tc =
                new TextureConverter(data, width)
                {
                    HoleDetection = holeDetection
                };

            List<DetectedVertices> detectedVerticesList = tc.DetectVertices();

            return detectedVerticesList[0];
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Detects the vertices by analyzing the texture data.
 /// </summary>
 /// <param name="data">The texture data.</param>
 /// <param name="width">The texture width.</param>
 /// <param name="holeDetection">if set to <c>true</c> it will perform hole detection.</param>
 /// <returns></returns>
 public static Vertices CreatePolygonFromTextureData(uint[] data, int width, bool holeDetection)
 {
     return(TextureConverter.DetectVertices(data, width, holeDetection));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Detects the vertices by analyzing the texture data.
 /// </summary>
 /// <param name="data">The texture data.</param>
 /// <param name="width">The texture width.</param>
 /// <returns></returns>
 public static Vertices createPolygonFromTextureData(uint[] data, int width)
 {
     return(TextureConverter.detectVertices(data, width));
 }