private void Initialize(ILevelControllerOptions options) { // Constructs all the in-level components, then stores the ones that'll be needed later in member variables. // Done this way rather than directly initializing the member variables because this way if they're reordered, // the compiler will complain if something's being constructed before its dependency. var surface = GeodesicSphereFactory.Build(options); var simulation = new SimulationController(surface, options); var cameraController = new CameraController(options); var meshManager = new MeshManager(surface); var cursorTracker = new CursorTracker(cameraController.Camera, meshManager); var fieldManipulator = new FieldManipulator(surface, cursorTracker, options); var colorMapView = new ColorMapView(surface, meshManager.Mesh, options); var particleMapView = new ParticleMapView(surface, options); var rawValuesView = new RawValuesView(cursorTracker); var timeDilationView = new TimeView(50, options.Timestep); var latLongGridView = new LatLongGridView(options.Radius); _simulationController = simulation; _colorMapView = colorMapView; _particleMapView = particleMapView; _rawValuesView = rawValuesView; _timeView = timeDilationView; _latLongGridView = latLongGridView; _cameraController = cameraController; _cursorTracker = cursorTracker; _fieldManipulator = fieldManipulator; }
public void adjustDetails(FullTerrainOperator op) { var dratio = new Vector2(op.fieldUnit.x / op.detailUnit.x, op.fieldUnit.y / op.detailUnit.y); var m = new FieldManipulator(min, max, op.detailUnitR, op.detailLength); var layers = m.getDetailSupportedLayers(op.td); foreach (var layer in layers) { var ds = m.getDetails(op.td, layer); 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.detailUnit); var height = hs[(int)(iy * dratio.y), (int)(ix * dratio.x)] * op.fieldUnitHeight; var pos = new Vector3(spos.x, height, spos.y); if ((pos - center).sqrMagnitude <= sqrradius) { ds[iy, ix] = 0; } } } m.setDetails(op.td, ds, layer); } }
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); }
public void adjustHeights(SimpleTerrainOperator op) { var m = new FieldManipulator(min, max, op.fieldUnitR, op.fieldLength); var hs = m.getHeights(op.td); var tofs = new Vector3(op.terrainPosition.x, op.terrainPositionHeight, op.terrainPosition.y); 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.fieldUnit) + 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)) { hs[iy, ix] = (res.point.y - op.terrainPositionHeight) * op.fieldUnitHeightR; } } } m.setHeights(op.td, hs); }
public FieldAdjusterForExplosionShpere(Vector3 center, float radius, float impact, SimpleTerrainOperator op) { sqrradius = radius * radius; sradius = new Vector2(radius, radius); scenter = new Vector2(center.x, center.z) - op.terrainPosition; centerHeight = center.y - op.terrainPositionHeight; this.center = new Vector3(scenter.x, centerHeight, scenter.y); min = scenter - sradius; max = scenter + sradius; this.impact = impact; hm = new FieldManipulator(min, max, op.fieldUnitR, op.fieldLength); hs = hm.getHeights(op.td); }