//Methods public void Init() { Parameters inst = Parameters.Instance; entityManager = World.Active.GetOrCreateManager <EntityManager>(); city = new BioCity(); city.CellMeshes = new List <MeshInstanceRenderer>(); city.AgentMeshes = new List <MeshInstanceRenderer>(); city.CloudMeshes = new List <MeshInstanceRenderer>(); if (!inst.BioCloudsActive) { DeactivateBioclouds(); return; } city.BioEntityManager = entityManager; city.BioParameters = Object.FindObjectOfType <Parameters>(); var folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); var bioCloudsFolder = System.IO.Directory.CreateDirectory(folder + "\\VHLAB\\BioClouds"); var expFolder = System.IO.Directory.CreateDirectory(folder + "\\VHLAB\\BioClouds\\Experiments"); exp = LoadExperiment(city.BioParameters.ExperimentPath); r.InitState((uint)exp.SeedState); Debug.Log("domain: " + exp.Domain); city.BioParameters.DefaultDomainMinX = exp.Domain.minX; //0 city.BioParameters.DefaultDomainMinY = exp.Domain.minY; //1 city.BioParameters.DefaultDomainMaxX = exp.Domain.maxX; //2 city.BioParameters.DefaultDomainMaxY = exp.Domain.maxY; //3 densityQuad.transform.position = new Vector3((exp.Domain.minX + exp.Domain.maxX) / 2, (exp.Domain.minY + exp.Domain.maxY) / 2, 5); densityQuad.transform.localScale = new Vector3(exp.Domain.maxX - exp.Domain.minX, exp.Domain.maxY - exp.Domain.minY, 1); background.transform.position = new Vector3((exp.Domain.minX + exp.Domain.maxX) / 2, (exp.Domain.minY + exp.Domain.maxY) / 2, 10); background.transform.localScale = new Vector3(exp.Domain.maxX - exp.Domain.minX, exp.Domain.maxY - exp.Domain.minY, 1); collisionMask.transform.position = new Vector3((exp.Domain.minX + exp.Domain.maxX) / 2, (exp.Domain.minY + exp.Domain.maxY) / 2, 10); collisionMask.transform.localScale = new Vector3(exp.Domain.maxX - exp.Domain.minX, exp.Domain.maxY - exp.Domain.minY, 1.01f); inst.IDToRecord = exp.IDToRecord; float z = 0; Camera cam = mainCamera.GetComponent <Camera>(); if (cam.orthographic) { z = -15; } else { z = -((exp.Domain.maxX - exp.Domain.minX) / 2) / math.tan(math.radians(cam.fieldOfView / 2)); } mainCamera.transform.localPosition = new Vector3((exp.Domain.minX + exp.Domain.maxX) / 2, (exp.Domain.minY + exp.Domain.maxY) / 2, z); Parameters.Instance.MaxSimulationFrames = exp.FramesToRecord; GridConverter.Width = city.BioParameters.CellWidth; GridConverter.SetDomain(city.BioParameters.DefaultDomainMinX, city.BioParameters.DefaultDomainMinY, city.BioParameters.DefaultDomainMaxX, city.BioParameters.DefaultDomainMaxY); city.CloudArchetype = city.BioEntityManager.CreateArchetype(typeof(Position), typeof(Rotation), typeof(CloudData), typeof(CloudGoal), typeof(CloudMoveStep), typeof(SpawnedAgentsCounter), typeof(CloudSplitData)); city.CellArchetype = city.BioEntityManager.CreateArchetype(typeof(Position), typeof(Rotation), typeof(CellData)); foreach (MeshMaterial m in city.BioParameters.FixedParameters.CloudRendererData) { city.CloudMeshes.Add(new MeshInstanceRenderer() { mesh = m.mesh, material = m.mat }); } Texture2D noise = CreateNoiseTexture.GetNoiseTexture(512, 512, 1, new float2(0.0f, 0.0f)); noise.wrapMode = TextureWrapMode.Mirror; Texture2D density = new Texture2D(inst.Rows, inst.Cols); density.wrapMode = TextureWrapMode.Clamp; density.filterMode = FilterMode.Point; CloudHeatMap.DensityRenderer = densityQuad.GetComponent <MeshRenderer>(); CloudHeatMap.DensityRenderer.material.SetTexture("_DensityTex", density); CloudHeatMap.DensityRenderer.material.SetTexture("_NoiseTex", noise); CloudHeatMap.DensityRenderer.material.SetInt("_Rows", inst.Rows); CloudHeatMap.DensityRenderer.material.SetInt("_Cols", inst.Cols); CloudHeatMap.DensityRenderer.material.SetFloat("_CellWidth", inst.CellWidth); CloudHeatMap.DensityRenderer.material.SetTexture("_HeatMapScaleTex", inst.GetHeatScaleTexture()); if (!city.BioParameters.DrawCloudToMarkerLines) { World.Active.GetExistingManager <CloudCellDrawLineSystem>().Enabled = false; } if (!city.BioParameters.EnableRightPreference) { World.Active.GetExistingManager <CloudRightPreferenceSystem>().Enabled = false; } // Setup the Collision Mask GetComponent <CollisionMaskSettings>().Init(); }