private void makeCursorLODVB(ref VertexBuffer vb, ref uint numVerts, BTerrainVisual.eLODLevel lod) { VertexTypes.Pos[] verts = null; uint width = BTerrainQuadNode.getMaxNodeWidth(); uint vd = width * 2; uint tw = width; uint td = width; int counter = 0; switch (lod) { case BTerrainVisual.eLODLevel.cLOD0: { numVerts = (width + 1) * (width + 1); verts = new VertexTypes.Pos[numVerts]; vd = width * 2; tw = width; td = width; for (int z = 0; z < td; z++) { for (int x = 0; x < tw; x++) { int k = z + (int)(x * vd); verts[counter++].x = (k); } } } break; case BTerrainVisual.eLODLevel.cLOD1: { numVerts = (1 + (width >> 1)) * (1 + (width >> 1)); verts = new VertexTypes.Pos[numVerts]; tw = width >> 1; td = width >> 1; vd = 2 * (width >> 1); for (int x = 0; x < tw; x++) { for (int z = 0; z < td; z++) { int k = z + (int)(x * vd); verts[counter++].x = (k); } } } break; case BTerrainVisual.eLODLevel.cLOD2: { numVerts = (1 + (width >> 2)) * (1 + (width >> 2)); verts = new VertexTypes.Pos[numVerts]; tw = width >> 2; td = width >> 2; vd = 2 * (width >> 2); for (int x = 0; x < tw; x++) { for (int z = 0; z < td; z++) { int k = z + (int)(x * vd); verts[counter++].x = (k); } } } break; case BTerrainVisual.eLODLevel.cLOD3: { numVerts = (1 + (width >> 3)) * (1 + (width >> 3)); verts = new VertexTypes.Pos[numVerts]; tw = width >> 3; td = width >> 3; vd = 2 * (width >> 3); for (int x = 0; x < tw; x++) { for (int z = 0; z < td; z++) { int k = z + (int)(x * vd); verts[counter++].x = (k); } } } break; default: return; } vb = new VertexBuffer(typeof(VertexTypes.Pos), (int)numVerts, BRenderDevice.getDevice(), Usage.None, VertexFormats.Position, Pool.Managed); GraphicsStream stream = vb.Lock(0, (int)numVerts * sizeof(float) * 3, LockFlags.None); stream.Write(verts); vb.Unlock(); verts = null; }
public void getCursorLODVB(ref VertexBuffer vb, ref uint numVerts, BTerrainVisual.eLODLevel lod) { vb = mCursorVertexBuffers[(int)lod]; numVerts = mNumCursorVerts[(int)lod]; }