void DrawPathFencesOnMap(TerrainMap map, GCRoute path) { float xs = map.xSize / (float)map.resolution; float zs = map.zSize / (float)map.resolution; Vector3 alongRow = new Vector3(xs, 0, 0); Vector3 nextRow = new Vector3(-map.xSize, 0, zs); Vector3 g = new Vector3((map.xSize - xs) / -2, 0, (map.zSize - zs) / -2); for (int j = 0; j < map.resolution; j++) { for (int i = 0; i < map.resolution; i++) { float outside = path.HowFarOutsidePath(g); float wallThickness = 1.0f; // set map cells adjacent to the outside edge of the path if ((outside > 0) && (outside < wallThickness)) { map.SetMapBit(i, j, true); } // clear all other off-path map cells if (outside > wallThickness) { map.SetMapBit(i, j, false); } g += alongRow; } g += nextRow; } }
void DrawBoundaryFencesOnMap(TerrainMap map) { // QQQ it would make more sense to do this with a "draw line // QQQ on map" primitive, may need that for other things too int cw = map.Cellwidth(); int ch = map.Cellheight(); int r = cw - 1; int a = cw >> 3; int b = cw - a; int o = cw >> 4; int p = (cw - o) >> 1; int q = (cw + o) >> 1; for (int i = 0; i < cw; i++) { for (int j = 0; j < ch; j++) { bool c = i > a && i < b && (i <p || i> q); if (i == 0 || j == 0 || i == r || j == r || (c && (i == j || i + j == r))) { map.SetMapBit(i, j, true); } } } }
void ClearCenterOfMap(TerrainMap map) { int o = map.Cellwidth() >> 4; int p = (map.Cellwidth() - o) >> 1; int q = (map.Cellwidth() + o) >> 1; for (int i = p; i <= q; i++) { for (int j = p; j <= q; j++) { map.SetMapBit(i, j, false); } } }
void DrawRandomClumpsOfRocksOnMap(TerrainMap map) { if (useRandomRocks) { int spread = 4; int r = map.Cellwidth(); int k = Random2(50, 150); for (int p = 0; p < k; p++) { int i = Random2(0, r - spread); int j = Random2(0, r - spread); int c = Random2(0, 10); for (int q = 0; q < c; q++) { int m = Random2(0, spread); int n = Random2(0, spread); map.SetMapBit(i + m, j + n, true); } } } }
void DrawRandomClumpsOfRocksOnMap(TerrainMap map) { if (useRandomRocks) { int spread = 4; int r = map.Cellwidth(); int k = Random2(50, 150); for (int p = 0; p < k; p++) { int i = Random2(0, r - spread); int j = Random2(0, r - spread); int c = Random2(0, 10); for (int q = 0; q < c; q++) { int m = Random2(0, spread); int n = Random2(0, spread); map.SetMapBit(i + m, j + n, true); } } } }
void DrawPathFencesOnMap(TerrainMap map, GCRoute path) { float xs = map.xSize / (float)map.resolution; float zs = map.zSize / (float)map.resolution; Vector3 alongRow = new Vector3(xs, 0, 0); Vector3 nextRow = new Vector3(-map.xSize, 0, zs); Vector3 g = new Vector3((map.xSize - xs) / -2, 0, (map.zSize - zs) / -2); for (int j = 0; j < map.resolution; j++) { for (int i = 0; i < map.resolution; i++) { float outside = path.HowFarOutsidePath(g); float wallThickness = 1.0f; // set map cells adjacent to the outside edge of the path if ((outside > 0) && (outside < wallThickness)) map.SetMapBit(i, j, true); // clear all other off-path map cells if (outside > wallThickness) map.SetMapBit(i, j, false); g += alongRow; } g += nextRow; } }
void DrawBoundaryFencesOnMap(TerrainMap map) { // QQQ it would make more sense to do this with a "draw line // QQQ on map" primitive, may need that for other things too int cw = map.Cellwidth(); int ch = map.Cellheight(); int r = cw - 1; int a = cw >> 3; int b = cw - a; int o = cw >> 4; int p = (cw - o) >> 1; int q = (cw + o) >> 1; for (int i = 0; i < cw; i++) { for (int j = 0; j < ch; j++) { bool c = i > a && i < b && (i < p || i > q); if (i == 0 || j == 0 || i == r || j == r || (c && (i == j || i + j == r))) map.SetMapBit(i, j, true); } } }
void ClearCenterOfMap(TerrainMap map) { int o = map.Cellwidth() >> 4; int p = (map.Cellwidth() - o) >> 1; int q = (map.Cellwidth() + o) >> 1; for (int i = p; i <= q; i++) for (int j = p; j <= q; j++) map.SetMapBit(i, j, false); }