/// <summary>
        ///    Sets the texture coordinates for the left edge of the border.
        /// </summary>
        /// <remarks>
        ///    The border panel uses 8 panels for the border (9 including the center).
        ///    Imagine a table with 3 rows and 3 columns. The corners are always the same size,
        ///    but the edges stretch depending on how big the panel is. Those who have done
        ///    resizable HTML tables will be familiar with this approach.
        ///    <p/>
        ///    We only require 2 sets of uv coordinates, one for the top-left and one for the
        ///    bottom-right of the panel, since it is assumed the sections are aligned on the texture.
        /// </remarks>
        /// <param name="cell">Index of the cell to update.</param>
        /// <param name="u1">Top left u.</param>
        /// <param name="v1">Top left v.</param>
        /// <param name="u2">Bottom right u.</param>
        /// <param name="v2">Bottom right v.</param>
        public void SetCellUV(BorderCell cell, float u1, float v1, float u2, float v2)
        {
            int cellIndex = (int)cell;

            // no choice but to lock/unlock each time here, locking only what we want to modify
            HardwareVertexBuffer buffer =
                renderOp2.vertexData.vertexBufferBinding.GetBuffer(TEXCOORDS);

            // can't use discard, or it will discard the whole buffer, wiping out the positions too
            IntPtr data = buffer.Lock(
                cellIndex * 8 * Marshal.SizeOf(typeof(float)),
                Marshal.SizeOf(typeof(float)) * 8,
                BufferLocking.Normal);

            int index = 0;

            unsafe {
                float *texPtr = (float *)data.ToPointer();

                texPtr[index++] = u1; texPtr[index++] = v1;
                texPtr[index++] = u1; texPtr[index++] = v2;
                texPtr[index++] = u2; texPtr[index++] = v1;
                texPtr[index++] = u2; texPtr[index++] = v2;
            }

            buffer.Unlock();
        }
Example #2
0
		/// <summary>
		///    Sets the texture coordinates for the left edge of the border.
		/// </summary>
		/// <remarks>
		///    The border panel uses 8 panels for the border (9 including the center).
		///    Imagine a table with 3 rows and 3 columns. The corners are always the same size,
		///    but the edges stretch depending on how big the panel is. Those who have done
		///    resizable HTML tables will be familiar with this approach.
		///    <p/>
		///    We only require 2 sets of uv coordinates, one for the top-left and one for the
		///    bottom-right of the panel, since it is assumed the sections are aligned on the texture.
		/// </remarks>
		/// <param name="cell">Index of the cell to update.</param>
		/// <param name="u1">Top left u.</param>
		/// <param name="v1">Top left v.</param>
		/// <param name="u2">Bottom right u.</param>
		/// <param name="v2">Bottom right v.</param>
		public void SetCellUV( BorderCell cell, float u1, float v1, float u2, float v2 )
		{
			var cellIndex = (int)cell;

			// no choice but to lock/unlock each time here, locking only what we want to modify
			var buffer = this.renderOp2.vertexData.vertexBufferBinding.GetBuffer( TEXCOORDS );

			// can't use discard, or it will discard the whole buffer, wiping out the positions too
			var data = buffer.Lock( cellIndex*8*Memory.SizeOf( typeof ( float ) ), Memory.SizeOf( typeof ( float ) )*8,
			                        BufferLocking.Normal );

			var index = 0;

#if !AXIOM_SAFE_ONLY
			unsafe
#endif
			{
				var texPtr = data.ToFloatPointer();

				texPtr[ index++ ] = u1;
				texPtr[ index++ ] = v1;
				texPtr[ index++ ] = u1;
				texPtr[ index++ ] = v2;
				texPtr[ index++ ] = u2;
				texPtr[ index++ ] = v1;
				texPtr[ index++ ] = u2;
				texPtr[ index ] = v2;
			}

			buffer.Unlock();
		}
        /// <summary>
        ///    Sets the texture coordinates for the left edge of the border.
        /// </summary>
        /// <remarks>
        ///    The border panel uses 8 panels for the border (9 including the center). 
        ///    Imagine a table with 3 rows and 3 columns. The corners are always the same size,
        ///    but the edges stretch depending on how big the panel is. Those who have done
        ///    resizable HTML tables will be familiar with this approach.
        ///    <p/>
        ///    We only require 2 sets of uv coordinates, one for the top-left and one for the
        ///    bottom-right of the panel, since it is assumed the sections are aligned on the texture.
        /// </remarks>
        /// <param name="cell">Index of the cell to update.</param>
        /// <param name="u1">Top left u.</param>
        /// <param name="v1">Top left v.</param>
        /// <param name="u2">Bottom right u.</param>
        /// <param name="v2">Bottom right v.</param>
        public void SetCellUV(BorderCell cell, float u1, float v1, float u2, float v2)
        {
            int cellIndex = (int)cell;

            // no choice but to lock/unlock each time here, locking only what we want to modify
            HardwareVertexBuffer buffer =
                renderOp2.vertexData.vertexBufferBinding.GetBuffer(TEXCOORDS);

            // can't use discard, or it will discard the whole buffer, wiping out the positions too
            IntPtr data = buffer.Lock(
                cellIndex * 8 * Marshal.SizeOf(typeof(float)),
                Marshal.SizeOf(typeof(float)) * 8,
                BufferLocking.Normal);

            int index = 0;

            unsafe {
                float* texPtr = (float*)data.ToPointer();

                texPtr[index++] = u1; texPtr[index++] = v1;
                texPtr[index++] = u1; texPtr[index++] = v2;
                texPtr[index++] = u2; texPtr[index++] = v1;
                texPtr[index++] = u2; texPtr[index++] = v2;
            }

            buffer.Unlock();
        }