public void adjustAlphamaps(TerrainOperator op) { var mratio = new Vector2(op.fieldUnit.x / op.mapUnit.x, op.fieldUnit.y / op.mapUnit.y); var m = new FieldManipulator(min, max, op.mapUnitR, op.mapLength); var ms = m.getAlphamaps(op.td); for (var iy = 0; iy < m.len.y; iy++) { for (var ix = 0; ix < m.len.x; ix++) { var spos = m.getIterationPosition(ix, iy, op.mapUnit); var height = hs[(int)(iy * mratio.y), (int)(ix * mratio.x)] * op.fieldUnitHeight; var pos = new Vector3(spos.x, height, spos.y); if ((pos - center).sqrMagnitude <= sqrradius) { ms[iy, ix, 0] = 0.3f; ms[iy, ix, 1] = 0.0f; ms[iy, ix, 2] = 0.0f; ms[iy, ix, 3] = 0.0f; } } } m.setAlphamaps(op.td, ms); }
public void adjustAlphamaps(TerrainOperator op) { var m = new FieldManipulator(min, max, op.mapUnitR, op.mapLength); var ms = m.getAlphamaps(op.td); for (var iy = 0; iy < m.len.y; iy++) { for (var ix = 0; ix < m.len.x; ix++) { var pos = m.getIterationPosition3d(ix, iy, op.mapUnit) + tofs; var start = pos + Vector3.up * 512.0f; var end = pos + Vector3.down * 512.0f; var ray = new Ray(start, end - start); var res = new RaycastHit(); if (mc.Raycast(ray, out res, 1024.0f)) { ms[iy, ix, 0] = 0.0f; ms[iy, ix, 1] = 1.0f; ms[iy, ix, 2] = 0.0f; ms[iy, ix, 3] = 0.0f; } } } m.setAlphamaps(op.td, ms); }