Exemplo n.º 1
0
        public void AddSpriteSequence(SpriteSequence sequence, Vector2 position, Vector2i size, string layer, Color4ub? color = null)
        {
            var ro = new RenderObject()
            {
                SpriteSequence = sequence,
                Position = new Vector2[] { position },
                Size = size,
                Color = color.HasValue ? color.Value : new Color4ub(255, 255, 255, 255)
            };

            m_renderObjects[GetLayerId(layer)].Add(ro);
        }
Exemplo n.º 2
0
        public void AddTriangle(Vector2[] position, string layer, Vector2i? size = null, Color4ub? color = null)
        {
            var ro = new RenderObject()
            {
                Position = position,
                Size = size.HasValue ? size.Value : new Vector2i(1, 1),
                Color = color.HasValue ? color.Value : new Color4ub(255, 255, 255, 255)
            };

            m_renderObjects[GetLayerId(layer)].Add(ro);
        }
Exemplo n.º 3
0
        public void AddRenderObject(RenderObject obj)
        {
            //Si sprite on fait 2 triangles
            if (obj.Sprite != null)
            {
                var pos = obj.Position[0];
                var halfSize = obj.Size / 2;
                var pos1 = pos - halfSize;
                var pos2 = new Vector2(pos.X - halfSize.X, pos.Y + halfSize.Y);
                var pos3 = new Vector2(pos.X + halfSize.X, pos.Y - halfSize.Y);
                var pos4 = pos + halfSize;

                //Triangle 1
                var data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos1;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MinX, obj.Sprite.Coordinates.MaxY);

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos2;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MinX, obj.Sprite.Coordinates.MinY);

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos3;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MaxX, obj.Sprite.Coordinates.MaxY);

                m_datas.Add(data);

                //Triangle 2
                data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos2;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MinX, obj.Sprite.Coordinates.MinY);

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos3;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MaxX, obj.Sprite.Coordinates.MaxY);

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = pos4;
                data.TextureCoordinates = new Vector2(obj.Sprite.Coordinates.MaxX, obj.Sprite.Coordinates.MinY);

                m_datas.Add(data);
            }
            else
            {
                var data = new RendererData();

                data.Color = obj.Color;
                data.Position = obj.Position[0];

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = obj.Position[1];

                m_datas.Add(data);

                data = new RendererData();

                data.Color = obj.Color;
                data.Position = obj.Position[2];

                m_datas.Add(data);
            }
        }