public Foreman(Weltschmerz weltschmerz, Terra terra, Registry registry, ITerraMesher mesher, int viewDistance, float fov, int preparationThreads, ITerraSemaphore preparation, ITerraSemaphore generation) { this.preparationThreads = preparationThreads; this.preparation = preparation; this.generation = generation; this.weltschmerz = weltschmerz; this.terra = terra; this.octree = terra.GetOctree(); queue = new ConcurrentQueue <Tuple <int, int, int> > (); maxViewDistance = viewDistance; this.fov = fov; this.mesher = mesher; chunkSpeed = new List <long> (); stopwatch = new Stopwatch(); this.leafOctants = new ConcurrentDictionary <Tuple <int, int, int>, OctreeNode> (); List <Position> localCenters = new List <Position> (); for (int l = -maxViewDistance; l < maxViewDistance; l += 8) { for (int y = -Utils.GetPosFromFOV(fov, l); y < Utils.GetPosFromFOV(fov, l); y += 8) { for (int x = -Utils.GetPosFromFOV(fov, l); x < Utils.GetPosFromFOV(fov, l); x += 8) { localCenters.Add(new Position(x, y, -l)); } } } this.localCenters = localCenters.ToArray(); localCenters.Clear(); maxSize = this.localCenters.Length; }
public override void _Ready() { Registry reg = new Registry(); PrimitiveResources.Register(reg); mesher = (GodotMesher)GetParent().FindNode("GameMesher"); mesher.SetRegistry(reg); chunkFiller = new ChunkFiller(1, 2); weltschmerz = new Weltschmerz(); Thread thread = new Thread(); thread.Start(this, nameof(Generate)); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { currentDirectoryPath = ConfigManager.BASE_CONFIG_FILE_DIRECTORY_PATH; currentConfigPath = ConfigManager.BASE_CONFIG_FILE_PATH; config = ConfigManager.GetConfig(currentConfigPath); weltschmerz = new Weltschmerz(config); biomMap = IOManager.LoadImage(BIOME_DISTRIBUTION_PATH); biomMap.Lock(); Controler controler = (Controler)FindNode("Sliders"); controler.Init(config); Init(); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { registry = new Registry(); PrimitiveResources.Register(registry); weltschmerz = new Weltschmerz(); Config config = weltschmerz.GetConfig(); config.elevation.max_elevation = MAX_ELEVATION; config.elevation.min_elevation = MIN_ELEVATION; config.map.latitude = LATITUDE; config.map.longitude = LONGITUDE; if (LONGITUDE < 2) { LONGITUDE = 2; } if (LATITUDE < 2) { LATITUDE = 2; } if (MAX_ELEVATION < 2) { MAX_ELEVATION = 2; } Position boundries = new Position(); boundries.x = LONGITUDE; boundries.y = MAX_ELEVATION; boundries.z = LATITUDE; terra = new Terra(boundries, this); GodotSemaphore semaphore1 = new GodotSemaphore(); GodotSemaphore semaphore2 = new GodotSemaphore(); foreman = new Foreman(weltschmerz, registry, terra, LOAD_RADIUS); GameClient client = (GameClient)FindNode("GameClient"); GodotMesher mesher = (GodotMesher)FindNode("GameMesher"); mesher.SetRegistry(registry); client.AddServer(this, mesher); }
public Precipitation(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { }
public ImageElevationGenerator(Image map, Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { this.map = map; map.Lock(); }
public ElevationGenerator(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { }
public Generator(Weltschmerz weltschmerz, Config config) { this.config = config; this.weltschmerz = weltschmerz; Update(); }
public TemperatureGenerator(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { }
public void Prepare(Camera camera, LoadMarker marker) { registry = new Registry(); PrimitiveResources.Register(registry); weltschmerz = new Weltschmerz(); Config config = weltschmerz.GetConfig(); config.elevation.max_elevation = MAX_ELEVATION; config.elevation.min_elevation = MIN_ELEVATION; config.map.latitude = LATITUDE; config.map.longitude = LONGITUDE; mesher = (GodotMesher)FindNode("GameMesher"); mesher.SetRegistry(registry); if (LONGITUDE < 2) { LONGITUDE = 2; } if (LATITUDE < 2) { LATITUDE = 2; } if (MAX_ELEVATION < 2) { MAX_ELEVATION = 2; } GD.Print("Using " + GENERATION_THREADS + " threads"); Position boundries = new Position(); boundries.x = LONGITUDE; boundries.y = MAX_ELEVATION; boundries.z = LATITUDE; terra = new Terra(boundries, this); picker = new Picker(terra, mesher); GodotSemaphore semaphore1 = new GodotSemaphore(); GodotSemaphore semaphore2 = new GodotSemaphore(); foreman = new Foreman(weltschmerz, terra, registry, mesher, VIEW_DISTANCE, camera.Fov, GENERATION_THREADS, semaphore1, semaphore2); for (int t = 0; t < GENERATION_THREADS; t++) { Thread thread = new Thread(); thread.Start(this, nameof(Generation)); } for (int t = 0; t < PROCESS_THREADS; t++) { Thread thread = new Thread(); thread.Start(this, nameof(Loading)); } foreman.SetMaterials(registry); marker.Attach(foreman); foreman.AddLoadMarker(marker); }
public Chunk GenerateChunk(float posX, float posY, float posZ, Weltschmerz weltschmerz) { Run run = new Run(); Chunk chunk = new Chunk(); chunk.Borders = new int[384]; chunk.x = (uint)posX; chunk.y = (uint)posY; chunk.z = (uint)posZ; chunk.Materials = 1; Run[] voxels = new Run[Constants.CHUNK_SIZE3D]; chunk.IsEmpty = true; int posx = (int)(posX * 4); int posz = (int)(posZ * 4); int posy = (int)(posY * 4); int lastPosition = 0; chunk.IsSurface = false; for (int z = 0; z < Constants.CHUNK_SIZE1D; z++) { for (int x = 0; x < Constants.CHUNK_SIZE1D; x++) { int elevation = (int)weltschmerz.GetElevation(x + posx, z + posz); if (elevation / Constants.CHUNK_SIZE1D == posy / Constants.CHUNK_SIZE1D) { if (elevation > 0) { int position = elevation % Constants.CHUNK_SIZE1D; if (lastPosition > 0) { run = voxels[lastPosition - 1]; if (run.value == dirtID) { run.lenght = position + run.lenght; voxels[lastPosition - 1] = run; } else { run.lenght = position; run.value = dirtID; voxels[lastPosition] = run; lastPosition++; } } else { run.lenght = position; run.value = dirtID; voxels[lastPosition] = run; lastPosition++; } run.lenght = 1; run.value = grassID; voxels[lastPosition] = run; lastPosition++; run.lenght = Constants.CHUNK_SIZE1D - (elevation % Constants.CHUNK_SIZE1D) - 1; run.value = 0; voxels[lastPosition] = run; lastPosition++; chunk.IsSurface = true; chunk.IsEmpty = false; } else { int position = Constants.CHUNK_SIZE1D; if (lastPosition > 0) { run = voxels[lastPosition - 1]; if (run.value == 0) { run.lenght = position + run.lenght; voxels[lastPosition - 1] = run; continue; } } run.lenght = position; run.value = 0; voxels[lastPosition] = run; lastPosition++; } } else if (elevation / Constants.CHUNK_SIZE1D > posy / Constants.CHUNK_SIZE1D) { int position = Constants.CHUNK_SIZE1D; if (lastPosition > 0) { run = voxels[lastPosition - 1]; if (run.value == dirtID) { run.lenght = position + run.lenght; voxels[lastPosition - 1] = run; continue; } } run.lenght = position; run.value = dirtID; voxels[lastPosition] = run; lastPosition++; chunk.IsEmpty = false; } else if (elevation / Constants.CHUNK_SIZE1D < posy / Constants.CHUNK_SIZE1D) { int position = Constants.CHUNK_SIZE1D; if (lastPosition > 0) { run = voxels[lastPosition - 1]; if (run.value == 0) { run.lenght = position + run.lenght; voxels[lastPosition - 1] = run; continue; } } run.lenght = position; run.value = 0; voxels[lastPosition] = run; lastPosition++; } } } if (chunk.IsSurface) { chunk.Materials = 3; } chunk.Voxels = voxels; return(chunk); }
public Elevation(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { tau = 2 * Math.PI; multiplier = 1.0 / tau; }
public CirculationGenerator(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { }
public Circulation(Weltschmerz weltschmerz, Config config) : base(weltschmerz, config) { }