Ejemplo n.º 1
0
 public BatchItem(TextureCoordinates texcoords, Vector position, Vector size, float rotation)
 {
     Texcoords = texcoords;
     Position  = position;
     Size      = size;
     Rotation  = rotation;
 }
Ejemplo n.º 2
0
 public BatchItem(TextureCoordinates texcoords, ShapeCache cache, Vector position, Vector size, float rotation, Image image, Color color)
 {
     Cache     = cache;
     Texcoords = texcoords;
     Position  = position;
     Size      = size;
     Rotation  = rotation;
     Image     = image;
     Color     = color;
 }
Ejemplo n.º 3
0
        public void Draw(TextureCoordinates c, Vector position, Vector size, float angle)
        {
            Debug.Assert(beginHasBeenCalled);

            if (iTexture >= BufferSize)
            {
                Flush();
            }

            Matrix matrix =
                Matrix.CreateScale((float)size.X, (float)size.Y, 1f)
                * Matrix.CreateRotationZ(angle)
                * Matrix.CreateTranslation((float)position.X, (float)position.Y, 0);

            Vector3[] transformedPoints = new Vector3[VerticesPerTexture];
            for (int i = 0; i < transformedPoints.Length; i++)
            {
                transformedPoints[i] = Vector3.Transform(Vertices[i], matrix);
            }

            uint startIndex = (iTexture * VerticesPerTexture);

            for (int i = 0; i < VerticesPerTexture; i++)
            {
                uint bi = (uint)((iTexture * VerticesPerTexture) + i);
                vertexBuffer[bi].Position = transformedPoints[i];
            }

            var color = System.Drawing.Color.FromArgb(255, 255, 255, 255);

            // Triangle 1
            vertexBuffer[startIndex + 0].TexCoords = new Vector2((float)c.TopLeft.X, (float)c.TopLeft.Y);
            vertexBuffer[startIndex + 0].SetColor(color);
            vertexBuffer[startIndex + 1].TexCoords = new Vector2((float)c.BottomLeft.X, (float)c.BottomLeft.Y);
            vertexBuffer[startIndex + 1].SetColor(color);
            vertexBuffer[startIndex + 2].TexCoords = new Vector2((float)c.TopRight.X, (float)c.TopRight.Y);
            vertexBuffer[startIndex + 2].SetColor(color);

            // Triangle 2
            vertexBuffer[startIndex + 3].TexCoords = new Vector2((float)c.BottomLeft.X, (float)c.BottomLeft.Y);
            vertexBuffer[startIndex + 3].SetColor(color);
            vertexBuffer[startIndex + 4].TexCoords = new Vector2((float)c.BottomRight.X, (float)c.BottomRight.Y);
            vertexBuffer[startIndex + 4].SetColor(color);
            vertexBuffer[startIndex + 5].TexCoords = new Vector2((float)c.TopRight.X, (float)c.TopRight.Y);
            vertexBuffer[startIndex + 5].SetColor(color);

            iTexture++;
        }
Ejemplo n.º 4
0
        public void AddImage(Matrix4x4 matrix, Image image, TextureCoordinates texcoords, Vector position, Vector size, float rotation)
        {
            if (!ImageBatches.ContainsKey(image))
            {
                ImageBatches.Add(image, new Dictionary <Matrix4x4, List <BatchItem> >());
            }
            Dictionary <Matrix4x4, List <BatchItem> > batch = ImageBatches[image];

            if (batch.TryGetValue(matrix, out List <BatchItem> list))
            {
                if (list == null)
                {
                    list          = new List <BatchItem>();
                    batch[matrix] = list;
                }
                list.Add(new BatchItem(texcoords, position, size, rotation));
            }
            else
            {
                batch.Add(matrix, new List <BatchItem>());
                batch[matrix].Add(new BatchItem(texcoords, position, size, rotation));
            }
        }
Ejemplo n.º 5
0
 public void AddShader(Matrix4x4 matrix, IShader shader, Image image, TextureCoordinates texcoords, Vector position, Vector size, float rotation)
 {
     AddShader(matrix, shader, image, default, null, texcoords, position, size, rotation);