public override void Build() { int idx = 0; var vertices = new Vertex[4 * _CountX * _CountY]; // 4 for BeginMode.Quads var tile_size = Texture.Regions[0].Size; for (int j = 0; j < _CountY; j++) { float height_mag = (float)(j + 1) / (float)(_CountY); for (int i = 0; i < _CountX; i++) { double x0 = Texture.Regions[IndexMap[i, j]].Low.X / Texture.Width; double y0 = Texture.Regions[IndexMap[i, j]].Low.Y / Texture.Height; double x1 = Texture.Regions[IndexMap[i, j]].High.X / Texture.Width; double y1 = Texture.Regions[IndexMap[i, j]].High.Y / Texture.Height; var A = new Vertex(tile_size.X * i, tile_size.Y * j, 1.0, x0, -y0, 1.0f, 1.0f, 1.0f, height_mag); var B = new Vertex(tile_size.X * (i + 1), A.Position.Y, 1.0, x1, -y0, 1.0f, 1.0f, 1.0f, height_mag); var C = new Vertex(B.Position.X, tile_size.Y * (j + 1), 1.0, x1, -y1, 1.0f, 1.0f, 1.0f, height_mag); var D = new Vertex(A.Position.X, C.Position.Y, 1.0, x0, -y1, 1.0f, 1.0f, 1.0f, height_mag); vertices[idx++] = A; vertices[idx++] = B; vertices[idx++] = C; vertices[idx++] = D; //new BlueprintQuad(A.Position, B.Position, C.Position, D.Position, _RenderSet); } } VBO = new VertexBuffer(vertices); }
public virtual void Dispose() { if (_VBO != null) { _VBO.Dispose (); _VBO = null; } _Texture = null; }
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); }