예제 #1
0
        public List <int> GetIntersectingParts(Point p, Skin skin)
        {
            int mesh  = 0;
            var parts = new List <int>();

            foreach (Mesh m in Meshes)
            {
                foreach (Face f in m.Faces)
                {
                    var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999));

                    foreach (Vector2 c in f.TexCoords)
                    {
                        var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height);
                        bounds.AddPoint(new Point((int)coord.X, (int)coord.Y));
                    }

                    if (bounds.ToRectangle().Contains(p))
                    {
                        parts.Add(mesh);
                        break;
                    }
                }

                mesh++;
            }

            return(parts);
        }
예제 #2
0
        // P: polygon support required? used bounds 'n stuff but, you know...
        public Rectangle GetTextureFaceBounds(Point p, Skin skin)
        {
            foreach (Mesh m in Meshes)
            {
                foreach (Face f in m.Faces)
                {
                    var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999));

                    foreach (Vector2 c in f.TexCoords)
                    {
                        var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height);
                        bounds.AddPoint(new Point((int)coord.X, (int)coord.Y));
                    }

                    if (bounds.ToRectangle().Contains(p))
                    {
                        return(bounds.ToRectangle());
                    }
                }
            }

            return(new Rectangle());
        }
예제 #3
0
파일: Model.cs 프로젝트: rmbzlib/mcskin3d
        // P: polygon support required? used bounds 'n stuff but, you know...
        public Rectangle GetTextureFaceBounds(Point p, Skin skin)
        {
            foreach (Mesh m in Meshes)
            {
                foreach (Face f in m.Faces)
                {
                    var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999));

                    foreach (Vector2 c in f.TexCoords)
                    {
                        var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height);
                        bounds.AddPoint(new Point((int)coord.X, (int)coord.Y));
                    }

                    if (bounds.ToRectangle().Contains(p))
                        return bounds.ToRectangle();
                }
            }

            return new Rectangle();
        }
예제 #4
0
파일: Model.cs 프로젝트: rmbzlib/mcskin3d
        public List<int> GetIntersectingParts(Point p, Skin skin)
        {
            int mesh = 0;
            var parts = new List<int>();

            foreach (Mesh m in Meshes)
            {
                foreach (Face f in m.Faces)
                {
                    var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999));

                    foreach (Vector2 c in f.TexCoords)
                    {
                        var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height);
                        bounds.AddPoint(new Point((int)coord.X, (int)coord.Y));
                    }

                    if (bounds.ToRectangle().Contains(p))
                    {
                        parts.Add(mesh);
                        break;
                    }
                }

                mesh++;
            }

            return parts;
        }
예제 #5
0
파일: Skin.cs 프로젝트: rmbzlib/mcskin3d
        public void CheckTransparentPart(ColorGrabber grabber, int index)
        {
            foreach (Face f in Model.Meshes[index].Faces)
            {
                var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999));

                foreach (Vector2 c in f.TexCoords)
                {
                    var coord = new Vector2(c.X * Width, c.Y * Height);
                    bounds.AddPoint(new Point((int) coord.X, (int) coord.Y));
                }

                Rectangle rect = bounds.ToRectangle();
                bool gotOne = false;

                for (int y = rect.Y; !gotOne && y < rect.Y + rect.Height; ++y)
                {
                    for (int x = rect.X; x < rect.X + rect.Width; ++x)
                    {
                        ColorPixel pixel = grabber[x, y];

                        if (pixel.Alpha != 255)
                        {
                            gotOne = true;
                            break;
                        }
                    }
                }

                if (gotOne)
                {
                    TransparentParts[index] = gotOne;
                    return;
                }
            }

            TransparentParts[index] = false;
        }