//creation private void makeLODVB(ref VertexBuffer vb, ref uint numVerts, eLODLevel lod) { VertexTypes.Pos[] verts = null; uint width = BTerrainQuadNodeDesc.cMaxWidth; uint vd = width + 1; uint tw = width; uint td = width; int counter = 0; switch (lod) { case eLODLevel.cLOD0: { numVerts = (BTerrainQuadNodeDesc.cMaxWidth + 1) * (BTerrainQuadNodeDesc.cMaxHeight + 1) * 6; //*3 (TRILIST) *2 (per tile) verts = new VertexTypes.Pos[numVerts]; vd = width * 2; // width + 1; 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); verts[counter++].x = (k + vd); verts[counter++].x = (k + 1); verts[counter++].x = (k + 1); verts[counter++].x = (k + vd); verts[counter++].x = (k + vd + 1); } } } break; case eLODLevel.cLOD1: { numVerts = (1 + (width >> 1)) * (1 + (width >> 1)) * 6; //*3 (TRILIST) *2 (per tile) verts = new VertexTypes.Pos[numVerts]; vd = (width >> 1) * 2; // width + 1; tw = (width >> 1); td = (width >> 1); for (int z = 0; z < td; z++) { for (int x = 0; x < tw; x++) { int k = z + (int)(x * vd); verts[counter++].x = (k); verts[counter++].x = (k + vd); verts[counter++].x = (k + 1); verts[counter++].x = (k + 1); verts[counter++].x = (k + vd); verts[counter++].x = (k + vd + 1); } } } break; case eLODLevel.cLOD2: { numVerts = (1 + (width >> 2)) * (1 + (width >> 2)) * 6; //*3 (TRILIST) *2 (per tile) verts = new VertexTypes.Pos[numVerts]; vd = (width >> 2) * 2; // width + 1; tw = (width >> 2); td = (width >> 2); for (int z = 0; z < td; z++) { for (int x = 0; x < tw; x++) { int k = z + (int)(x * vd); verts[counter++].x = (k); verts[counter++].x = (k + vd); verts[counter++].x = (k + 1); verts[counter++].x = (k + 1); verts[counter++].x = (k + vd); verts[counter++].x = (k + vd + 1); } } } break; case eLODLevel.cLOD3: { numVerts = (1 + (width >> 3)) * (1 + (width >> 3)) * 6; //*3 (TRILIST) *2 (per tile) verts = new VertexTypes.Pos[numVerts]; vd = (width >> 3) * 2; // width + 1; tw = (width >> 3); td = (width >> 3); for (int z = 0; z < td; z++) { for (int x = 0; x < tw; x++) { int k = z + (int)(x * vd); verts[counter++].x = (k); verts[counter++].x = (k + vd); verts[counter++].x = (k + 1); verts[counter++].x = (k + 1); verts[counter++].x = (k + vd); verts[counter++].x = (k + vd + 1); } } } 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 setStaticLODLevel(eLODLevel level) { mStaticLODLevel = level; }
//queary //lodVB public void getLODVB(ref VertexBuffer vb, ref uint numVerts, eLODLevel lod) { vb = mVertexBuffers[(int)lod]; numVerts = mNumVerts[(int)lod]; }
public void getCursorLODVB(ref VertexBuffer vb, ref uint numVerts, eLODLevel lod) { mLODData.getCursorLODVB(ref vb, ref numVerts, lod); }