Private Sub SetVertexBufferData(ByRef vs() As CustomVertex.PositionNormalTextured, ByVal vxbf As VertexBuffer, ByVal D9 As Device)
Dim LX, LY As Single, Ctr As Integer
'After that workout, we now have to actually set the vertices.
'We do this by locking the surface out of D9 while we "operate" on it.
Dim A As Array = vxbf.Lock(0, LockFlags.None)
'It returns a vanilla array...
vs = DirectCast(A, CustomVertex.PositionNormalTextured())
'So we have to convert it to an array of the appropriate vertices.
'z = 0, 0,0,0
vs(0) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(1) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(2) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
'z = 0, 2,2,0
vs(3) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(4) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(5) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'x = 0, 0,0,0
vs(6) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(7) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(8) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'x = 0, 0,2,2
vs(9) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(10) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(11) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
'y = 0, 0,0,0
vs(12) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(13) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(14) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
'y = 0, 2,0,2
vs(15) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(16) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(17) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'z = 2, 0,0,2
vs(18) = New CustomVertex.PositionNormalTextured(0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(19) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(20) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
'z = 2, 2,2,2
vs(21) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(22) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(23) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'y = 2, 0,2,0
vs(24) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(25) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(26) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'y = 2, 2,2,2
vs(27) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(28) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(29) = New CustomVertex.PositionNormalTextured(0.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
'x = 2, 2,0,0
vs(30) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F)
vs(31) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
vs(32) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
'x = 2, 2,2,2
vs(33) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F)
vs(34) = New CustomVertex.PositionNormalTextured(2.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
vs(35) = New CustomVertex.PositionNormalTextured(2.0F, 2.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F)
NormalizeTriangles(vs, PrT)
'It's important to unlock the vertex buffer, so that D9 can see what we put in there.
vxbf.Unlock()
End Sub |