Beispiel #1
0
            public void Build()
            {
                double w, h, w_half, h_half, x0, y0, x1, y1, xx, yy, corner_x, corner_y;

                if (_Texture.Regions != null && _Texture.Regions.Length > 0)
                {
                    TextureRegion region = _Texture.Regions[_TextureRegionIndex];
                    x0       = region.Low.X;
                    y0       = region.Low.Y;
                    x1       = region.High.X;
                    y1       = region.High.Y;
                    w        = x1 - x0;
                    h        = y1 - y0;
                    xx       = x0 + x1;
                    yy       = y0 + y1;
                    x0       = (xx - w * _TileX) * 0.5;
                    y0       = (yy - h * _TileY) * 0.5;
                    x1       = (xx + w * _TileX) * 0.5;
                    y1       = (yy + h * _TileY) * 0.5;
                    x0      /= _Texture.Width;
                    x1      /= _Texture.Width;
                    y0      /= _Texture.Height;
                    y1      /= _Texture.Height;
                    corner_x = region.OriginOffsetX;
                    corner_y = region.OriginOffsetY;
                }
                else
                {
                    w        = _Texture.Width;
                    h        = _Texture.Height;
                    x0       = 0.0;
                    y0       = 0.0;
                    x1       = _TileX;
                    y1       = _TileY;
                    corner_x = 0;
                    corner_y = 0;
                }
                w_half = w * 0.5;
                h_half = h * 0.5;
                var A = new VertexLite(corner_x - w_half, corner_y - h_half, 1.0, x0, -y0);
                var B = new VertexLite(corner_x + w_half, corner_y - h_half, 1.0, x1, -y0);
                var C = new VertexLite(corner_x + w_half, corner_y + h_half, 1.0, x1, -y1);
                var D = new VertexLite(corner_x - w_half, corner_y + h_half, 1.0, x0, -y1);

                _VBO = new VertexBuffer(A, B, C, D);
                //BPVBO = new VertexBuffer(A, B, C, D);
            }
Beispiel #2
0
 public void Build()
 {
     double w, h, w_half, h_half, x0, y0, x1, y1, xx, yy, corner_x, corner_y;
     if (_Texture.Regions != null && _Texture.Regions.Length > 0)
     {
         TextureRegion region = _Texture.Regions[_TextureRegionIndex];
         x0 = region.Low.X;
         y0 = region.Low.Y;
         x1 = region.High.X;
         y1 = region.High.Y;
         w = x1 - x0;
         h = y1 - y0;
         xx = x0 + x1;
         yy = y0 + y1;
         x0 = (xx - w * _TileX) * 0.5;
         y0 = (yy - h * _TileY) * 0.5;
         x1 = (xx + w * _TileX) * 0.5;
         y1 = (yy + h * _TileY) * 0.5;
         x0 /= _Texture.Width;
         x1 /= _Texture.Width;
         y0 /= _Texture.Height;
         y1 /= _Texture.Height;
         corner_x = region.OriginOffsetX;
         corner_y = region.OriginOffsetY;
     }
     else
     {
         w = _Texture.Width;
         h = _Texture.Height;
         x0 = 0.0;
         y0 = 0.0;
         x1 = _TileX;
         y1 = _TileY;
         corner_x = 0;
         corner_y = 0;
     }
     w_half = w * 0.5;
     h_half = h * 0.5;
     var A = new VertexLite(corner_x - w_half, corner_y - h_half, 1.0, x0, -y0);
     var B = new VertexLite(corner_x + w_half, corner_y - h_half, 1.0, x1, -y0);
     var C = new VertexLite(corner_x + w_half, corner_y + h_half, 1.0, x1, -y1);
     var D = new VertexLite(corner_x - w_half, corner_y + h_half, 1.0, x0, -y1);
     _VBO = new VertexBuffer(A, B, C, D);
     //BPVBO = new VertexBuffer(A, B, C, D);
 }