Private Sub SetVertexBufferData(ByRef vs As CustomVertex.PositionNormal(), ByVal vxbf As VertexBuffer, ByVal D9 As Device)
'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.PositionNormal())
'So we have to convert it to an array of TransformedColored vertices.
'Remember: TransformColored vertices come with X, Y, Z, and Regularly Holding Wone, along with color.
'PositionColored has no RHW: only X, Y, Z (position) and Color.
'z = 0, 0,0,0
vs(0) = New CustomVertex.PositionNormal(0.0F, 0.0F, 0.0F, -1.0F / RootThree, -1.0F / RootThree, -1.0F / RootThree)
vs(1) = New CustomVertex.PositionNormal(2.0F, 0.0F, 0.0F, 1.0F / RootThree, -1.0F / RootThree, -1.0F / RootThree)
vs(2) = New CustomVertex.PositionNormal(0.0F, 2.0F, 0.0F, -1.0F / RootThree, 1.0F / RootThree, -1.0F / RootThree)
'z = 0, 2,2,0
vs(3) = New CustomVertex.PositionNormal(2.0F, 2.0F, 0.0F, 1.0F / RootThree, 1.0F / RootThree, -1.0F / RootThree)
vs(4) = vs(2)
vs(5) = vs(1)
'x = 0, 0,0,0
vs(6) = vs(0)
vs(7) = vs(2)
vs(8) = New CustomVertex.PositionNormal(0.0F, 0.0F, 2.0F, -1.0F / RootThree, -1.0F / RootThree, 1.0F / RootThree)
'x = 0, 0,2,2
vs(9) = New CustomVertex.PositionNormal(0.0F, 2.0F, 2.0F, -1.0F / RootThree, 1.0F / RootThree, 1.0F / RootThree)
vs(10) = vs(8)
vs(11) = vs(2)
'y = 0, 0,0,0
vs(12) = vs(0)
vs(13) = vs(8)
vs(14) = vs(1)
'y = 0, 2,0,2
vs(15) = New CustomVertex.PositionNormal(2.0F, 0.0F, 2.0F, 1.0F / RootThree, -1.0F / RootThree, 1.0F / RootThree)
vs(16) = vs(1)
vs(17) = vs(8)
'z = 2, 0,0,2
vs(18) = vs(8)
vs(19) = vs(9)
vs(20) = vs(15)
'z = 2, 2,2,2
vs(21) = New CustomVertex.PositionNormal(2.0F, 2.0F, 2.0F, 1.0F / RootThree, 1.0F / RootThree, 1.0F / RootThree)
vs(22) = vs(15)
vs(23) = vs(9)
'y = 2, 0,2,0
vs(24) = vs(2)
vs(25) = vs(3)
vs(26) = vs(9)
'y = 2, 2,2,2
vs(27) = vs(21)
vs(28) = vs(9)
vs(29) = vs(3)
'x = 2, 2,0,0
vs(30) = vs(1)
vs(31) = vs(15)
vs(32) = vs(3)
'x = 2, 2,2,2
vs(33) = vs(21)
vs(34) = vs(3)
vs(35) = vs(15)
'It's important to unlock the vertex buffer, so that D9 can see what we put in there.
vxbf.Unlock()
End Sub |