예제 #1
0
        public void Draw(Skeleton skeleton, float Z)
        {
            List <Slot> DrawOrder = skeleton.DrawOrder;

            float depth        = Z;
            float depth_offset = 0.0001f;

            for (int i = 0; i < DrawOrder.Count; i++)
            {
                Slot             slot             = DrawOrder[i];
                RegionAttachment regionAttachment = slot.Attachment as RegionAttachment;
                if (regionAttachment != null)
                {
                    SpriteBatchItem item   = new SpriteBatchItem();
                    AtlasRegion     region = (AtlasRegion)regionAttachment.RendererObject;
                    item.Texture = (Texture)region.page.rendererObject;

                    byte r = (byte)(skeleton.R * slot.R * 255);
                    byte g = (byte)(skeleton.G * slot.G * 255);
                    byte b = (byte)(skeleton.B * slot.B * 255);
                    byte a = (byte)(skeleton.A * slot.A * 255);
                    item.vertexTL.Color = Color.FromArgb(r, g, b, a);
                    item.vertexBL.Color = Color.FromArgb(r, g, b, a);
                    item.vertexBR.Color = Color.FromArgb(r, g, b, a);
                    item.vertexTR.Color = Color.FromArgb(r, g, b, a);

                    float[] vertices = this.vertices;
                    regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertices);
                    item.vertexTL.Position.X = vertices[RegionAttachment.X1];
                    item.vertexTL.Position.Y = vertices[RegionAttachment.Y1];
                    item.vertexTL.Position.Z = depth;
                    item.vertexBL.Position.X = vertices[RegionAttachment.X2];
                    item.vertexBL.Position.Y = vertices[RegionAttachment.Y2];
                    item.vertexBL.Position.Z = depth;
                    item.vertexBR.Position.X = vertices[RegionAttachment.X3];
                    item.vertexBR.Position.Y = vertices[RegionAttachment.Y3];
                    item.vertexBR.Position.Z = depth;
                    item.vertexTR.Position.X = vertices[RegionAttachment.X4];
                    item.vertexTR.Position.Y = vertices[RegionAttachment.Y4];
                    item.vertexTR.Position.Z = depth;

                    float[] uvs = regionAttachment.UVs;
                    item.vertexTL.TextureCoordinate.X = uvs[RegionAttachment.X1];
                    item.vertexTL.TextureCoordinate.Y = uvs[RegionAttachment.Y1];
                    item.vertexBL.TextureCoordinate.X = uvs[RegionAttachment.X2];
                    item.vertexBL.TextureCoordinate.Y = uvs[RegionAttachment.Y2];
                    item.vertexBR.TextureCoordinate.X = uvs[RegionAttachment.X3];
                    item.vertexBR.TextureCoordinate.Y = uvs[RegionAttachment.Y3];
                    item.vertexTR.TextureCoordinate.X = uvs[RegionAttachment.X4];
                    item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];

                    this.DrawItem(item);
                    depth += depth_offset;
                }
            }
        }
        public void Draw(Skeleton skeleton)
        {
            List <Slot> drawOrder = skeleton.DrawOrder;

            for (int i = 0, n = drawOrder.Count; i < n; i++)
            {
                Slot             slot             = drawOrder[i];
                RegionAttachment regionAttachment = slot.Attachment as RegionAttachment;
                if (regionAttachment != null)
                {
                    SpriteBatchItem item = batcher.CreateBatchItem();
                    item.Texture = (Texture2D)regionAttachment.RendererObject;

                    byte r = (byte)(skeleton.R * slot.R * 255);
                    byte g = (byte)(skeleton.G * slot.G * 255);
                    byte b = (byte)(skeleton.B * slot.B * 255);
                    byte a = (byte)(skeleton.A * slot.A * 255);
                    item.vertexTL.Color.R = r;
                    item.vertexTL.Color.G = g;
                    item.vertexTL.Color.B = b;
                    item.vertexTL.Color.A = a;
                    item.vertexBL.Color.R = r;
                    item.vertexBL.Color.G = g;
                    item.vertexBL.Color.B = b;
                    item.vertexBL.Color.A = a;
                    item.vertexBR.Color.R = r;
                    item.vertexBR.Color.G = g;
                    item.vertexBR.Color.B = b;
                    item.vertexBR.Color.A = a;
                    item.vertexTR.Color.R = r;
                    item.vertexTR.Color.G = g;
                    item.vertexTR.Color.B = b;
                    item.vertexTR.Color.A = a;

                    float[] vertices = this.vertices;
                    regionAttachment.ComputeVertices(slot.Bone, vertices);
                    item.vertexTL.Position.X = vertices[RegionAttachment.X1];
                    item.vertexTL.Position.Y = vertices[RegionAttachment.Y1];
                    item.vertexTL.Position.Z = 0;
                    item.vertexBL.Position.X = vertices[RegionAttachment.X2];
                    item.vertexBL.Position.Y = vertices[RegionAttachment.Y2];
                    item.vertexBL.Position.Z = 0;
                    item.vertexBR.Position.X = vertices[RegionAttachment.X3];
                    item.vertexBR.Position.Y = vertices[RegionAttachment.Y3];
                    item.vertexBR.Position.Z = 0;
                    item.vertexTR.Position.X = vertices[RegionAttachment.X4];
                    item.vertexTR.Position.Y = vertices[RegionAttachment.Y4];
                    item.vertexTR.Position.Z = 0;

                    float[] uvs = regionAttachment.UVs;
                    item.vertexTL.TextureCoordinate.X = uvs[RegionAttachment.X1];
                    item.vertexTL.TextureCoordinate.Y = uvs[RegionAttachment.Y1];
                    item.vertexBL.TextureCoordinate.X = uvs[RegionAttachment.X2];
                    item.vertexBL.TextureCoordinate.Y = uvs[RegionAttachment.Y2];
                    item.vertexBR.TextureCoordinate.X = uvs[RegionAttachment.X3];
                    item.vertexBR.TextureCoordinate.Y = uvs[RegionAttachment.Y3];
                    item.vertexTR.TextureCoordinate.X = uvs[RegionAttachment.X4];
                    item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];
                }
            }
        }