private TriangleList GenerateVertexAndIndicesH2O() { var vertices = new List <VertexPositionNormalColored>(); var indices = new List <int>(); if (MH2OArray != null) { float offset_x = (533.33333f / 16) / 8; float offset_z = (533.33333f / 16) / 8; int VertexCounter = 0; int _TempVertexCounter = 0; for (int My = 0; My < 16; My++) { for (int Mx = 0; Mx < 16; Mx++) { float[,] MH2OHeightMap; bool[,] MH2ORenderMap; _TempVertexCounter = VertexCounter; float x = MCNKArray[Mx, My].x; float z = MCNKArray[Mx, My].z; MH2O mh2O = MH2OArray[Mx, My]; float y_pos = mh2O.heightLevel1; if (mh2O.used) { Color clr = GetColor(mh2O.type); MH2OHeightMap = mh2O.GetMapHeightsMatrix(); MH2ORenderMap = mh2O.GetRenderBitMapMatrix(); for (int r = 0; r < 9; r++) { for (int c = 0; c < 9; c++) { float x_pos = x - (c * offset_x); float z_pos = z - (r * offset_z); if (((r >= mh2O.yOffset) && ((r - mh2O.yOffset) <= mh2O.height)) && ((c >= mh2O.xOffset) && ((c - mh2O.xOffset) <= mh2O.width))) { y_pos = MH2OHeightMap[r - mh2O.yOffset, c - mh2O.xOffset]; // +_MH2O.heightLevel1; var position = new Vector3(x_pos, y_pos, z_pos); vertices.Add(new VertexPositionNormalColored(position, clr, Vector3.Up)); _TempVertexCounter++; } } } for (int r = mh2O.yOffset; r < mh2O.yOffset + mh2O.height; r++) { for (int c = mh2O.xOffset; c < mh2O.xOffset + mh2O.width; c++) { int row = r - mh2O.yOffset; int col = c - mh2O.xOffset; //if ((MH2ORenderMap[row, c]) || ((_MH2O.height == 8) && (_MH2O.width == 8))) { indices.Add(VertexCounter + ((row + 1) * (mh2O.width + 1) + col)); indices.Add(VertexCounter + (row * (mh2O.width + 1) + col)); indices.Add(VertexCounter + (row * (mh2O.width + 1) + col + 1)); indices.Add(VertexCounter + ((row + 1) * (mh2O.width + 1) + col + 1)); indices.Add(VertexCounter + ((row + 1) * (mh2O.width + 1) + col)); indices.Add(VertexCounter + (row * (mh2O.width + 1) + col + 1)); } } } VertexCounter = _TempVertexCounter; } } } } return(new TriangleList(indices, vertices)); }