protected override void UpdatePositionGeometry()
{
/*
0-----2
| /|
| / |
|/ |
1-----3
*/
float left, right, top, bottom;
/* Convert positions into -1, 1 coordinate space (homogenous clip space).
- Left / right is simple range conversion
- Top / bottom also need inverting since y is upside down - this means
that top will end up greater than bottom and when computing texture
coordinates, we have to flip the v-axis (ie. subtract the value from
1.0 to get the actual correct value).
*/
left = this.DerivedLeft * 2 - 1;
right = left + ( width * 2 );
top = -( ( this.DerivedTop * 2 ) - 1 );
bottom = top - ( height * 2 );
// get a reference to the position buffer
HardwareVertexBuffer buffer =
renderOperation.vertexData.vertexBufferBinding.GetBuffer( POSITION );
// lock the buffer
IntPtr data = buffer.Lock( BufferLocking.Discard );
int index = 0;
// Use the furthest away depth value, since materials should have depth-check off
// This initialised the depth buffer for any 3D objects in front
float zValue = Root.Instance.RenderSystem.MaximumDepthInputValue;
unsafe
{
float* posPtr = (float*)data.ToPointer();
posPtr[ index++ ] = left;
posPtr[ index++ ] = top;
posPtr[ index++ ] = zValue;
posPtr[ index++ ] = left;
posPtr[ index++ ] = bottom;
posPtr[ index++ ] = zValue;
posPtr[ index++ ] = right;
posPtr[ index++ ] = top;
posPtr[ index++ ] = zValue;
posPtr[ index++ ] = right;
posPtr[ index++ ] = bottom;
posPtr[ index ] = zValue;
}
// unlock the position buffer
buffer.Unlock();
}