public StatisticsScenarioItemView(ScenarioBase scenario, bool registered) { InitializeComponent(); DataContext = new StatisticsScenarioItemModel(scenario, registered); }
public GeolocationView(ScenarioBase scenario) : this() { DataContext = new ScenarioModel(scenario); itemView.Click += ItemView_Click; }
public FixtureShouldHaveWhens(ScenarioBase scenario) : base(scenario, "No whens found; a when should be specified by calling When in the constructor") { }
public MapScenarioScriptingAssembly(ScenarioBase scenario, IMapFile mapFile) { m_scenario = scenario; m_mapFile = mapFile; }
public async Task <bool> SetScenario(ScenarioBase scenario) { if (scenario != null) { using (StuckUILoadingWindow.Loading("Компоновка окна...")) { try { _originalSenario = scenario; _clonedScenario = (ScenarioBase)Lazurite.Windows.Utils.Utils.CloneObject(_originalSenario); if (_clonedScenario is SingleActionScenario s) { await _clonedScenario.Initialize(); contentPresenter.Content = _constructorView = new SingleActionScenarioView(s); } else if (_clonedScenario is CompositeScenario c) { await _clonedScenario.Initialize(); contentPresenter.Content = _constructorView = new CompositeScenarioView(c); } else if (_clonedScenario is RemoteScenario r) { contentPresenter.Content = _constructorView = new RemoteScenarioView(r); } buttonsView.SetScenario(_clonedScenario); IsModified = false; _constructorView.Modified += () => { Modified?.Invoke(); buttonsView.ScenarioModified(); IsModified = true; }; _constructorView.Failed += () => { buttonsView.Failed(); IsFailed = true; }; _constructorView.Succeed += () => { buttonsView.Success(); IsFailed = false; }; EmptyScenarioModeOff(); return(true); } catch (Exception e) { EmptyScenarioModeOn(); Log.Error($"Ошибка инициализации сценария [{scenario.Name}]", e); return(false); } } } else { EmptyScenarioModeOn(); return(false); } }
public GivenFailed(ScenarioBase scenario, string stepName, Exception innerException) : base(scenario, $"'{stepName}' failed", innerException) { }
internal void Initialize(ScenarioBase parentScenario, RandomizerTagManager parentTagManager) { m_Scenario = parentScenario; m_TagManager = parentTagManager; }
public void Revert(ScenarioBase scenario) { _scenario = scenario; Refresh(); }
public void SetScenario(ScenarioBase scenario) { _scenario = scenario; Refresh(); }
public void SetTargetScenario(ScenarioBase scenario) { _scenario = scenario; }
/// <summary> /// Begins calculating a light mapping solution. /// </summary> /// <exception cref="System.ApplicationException"> /// Thrown when no BSP is in the current scene graph. /// </exception> public void Begin() { // MdxRender.RenderDebug = false; SetOperation("Loading scenario..."); _scenario = Prometheus.Instance.ProjectManager.ScenarioTag as ScenarioBase; if (_scenario == null) { throw new RadiosityException("The current project has no scenario tag or the scenario tag is invalid."); } if (_scenario.BspList.Count <= 0) { throw new RadiosityException("The current project's scenario tag does not contain a bsp tag or the bsp tag is invalid."); } SetOperation("Retrieving lighting information..."); m_bsp = _scenario.BspList; WorldBounds bounds = m_bsp[0].WorldBounds; foreach (IBsp bsp in m_bsp) { bounds &= bsp.WorldBounds; } // We need to find the six planes of world bounds. m_worldBounds = bounds.CalculatePlanes(); // Try and obtain any lighting information. if (Prometheus.Instance.ProjectManager.ScenarioTag != null) { this.m_lights = _scenario.WorldLighting; this.m_models = _scenario.StaticModels; if (m_models == null) { m_models = new List <IModel>(); } } else { ICamera camera = MdxRender.Camera; List <RadiosityLight> lights = new List <RadiosityLight>(); this.m_lights = new List <ILight>(); m_lights.Add(new RadiosityLight(camera.Position, new RealColor(1f, 1f, 1.0f), 20f)); } // Get each lightmap from the currently loaded BSP. for (int i = 0; i < m_bsp.Count; i++) { // Add the DirectX texture to the high dynamic range texture collection. foreach (BaseTexture _texture in m_bsp[i].Lightmaps) { TextureMap _lightmap = new TextureMap(_texture); m_textures.AddTexture(_lightmap); } } // TODO: Figure out the number of photons each light gets. For now, set them all to use the same amount. float totalPower = 0f; float maxPower = 0f; foreach (ILight light in m_lights) { totalPower += light.Power; maxPower = Math.Max(light.Power, maxPower); } int directionalPhotons = 0; foreach (ILight light in m_lights) { int photonCount = (int)((float)m_maxPhotons * light.Power / totalPower);//(int)Math.Round((light.Power / totalPower) * (float)m_maxPhotons); light.PhotonCount = photonCount; light.Color.Multiply(light.Power); if (light is DirectionalLight) { directionalPhotons += photonCount; } } bool[,] importance; int count; ChangeStage(RadiosityStage.CreatingImportanceMap, directionalPhotons); SetOperation("Optimizing Pass..."); for (int l = 0; l < m_lights.Count; l++) { if (m_lights[l] is DirectionalLight) { DirectionalLight light = m_lights[l] as DirectionalLight; if (light.PhotonCount > 0) { importance = CreateImportanceMap(light.Direction, light.PhotonCount, bounds, out count); } else { importance = null; count = 0; } RadiosityHelper.ImportanceMap = importance; RadiosityHelper.ImportanceMapOnPixels = count; } } //currentOperation = "Saving any unsaved data..."; //this.SaveAll(); photonMap = new PhotonMap(m_maxBounces * m_maxPhotons); SetOperation("Perform radiosity..."); // Process collisions. this.ProcessCollisions(); ChangeStage(RadiosityStage.Done, 100); Interfaces.Output.Write(Interfaces.OutputTypes.Information, m_photonsLost + " photon(s) lost during radiosity."); if (OnComplete != null) { OnComplete(); } }
private void CreateLightmaps() { // Stage 2: Render onto lightmaps // * Step 1: Initialize // * Step 2: Iterate through textures // * Iterate through materials // * Compute a pixel rectangle for the current material // * Iterate through the pixels in the material // * Convert the UV pixel coordinates to a 3D point // * Gather n photons that are on that surface int screenWidth = MdxRender.Device.Viewport.Width; int screenHeight = MdxRender.Device.Viewport.Height; float dist2 = RadiosityHelper.GatherDistance * RadiosityHelper.GatherDistance; if (m_bsp == null) { _scenario = Prometheus.Instance.ProjectManager.ScenarioTag as ScenarioBase; if (_scenario == null) { throw new RadiosityException("The current project has no scenario tag or the scenario tag is invalid."); } if (_scenario.BspList.Count <= 0) { throw new RadiosityException("The current project's scenario tag does not contain a bsp tag or the bsp tag is invalid."); } SetOperation("Retrieving lighting information..."); m_bsp = _scenario.BspList; WorldBounds bounds = m_bsp[0].WorldBounds; foreach (IBsp bsp in m_bsp) { bounds &= bsp.WorldBounds; } // We need to find the six planes of world bounds. m_worldBounds = bounds.CalculatePlanes(); for (int i = 0; i < m_bsp.Count; i++) { // Add the DirectX texture to the high dynamic range texture collection. foreach (BaseTexture _texture in m_bsp[i].Lightmaps) { TextureMap _lightmap = new TextureMap(_texture); m_textures.AddTexture(_lightmap); } } } Vector3 badPoint = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); string path = (Prometheus.Instance.ProjectManager.ProjectFolder as DiskFileLibrary).RootPath + "LightMaps\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } //float dist2 = RadiosityHelper.GatherDistance * RadiosityHelper.GatherDistance; if ((photonMap != null) && (photonMap.store.Length > 0)) { int totalPixels = 0; foreach (TextureMap texMap in m_textures) { totalPixels += (int)Math.Ceiling(texMap.Width * texMap.Height * RadiosityHelper.LightmapScale * RadiosityHelper.LightmapScale); } ChangeStage(RadiosityStage.TextureGeneration, totalPixels); int texIndex = 0; float hemisphereSizeDivisor = 1f / ((float)Math.PI * dist2); float maxIntensity = float.MinValue; foreach (TextureMap texMap in m_textures) { CreateLightmap(dist2, badPoint, path, texIndex, hemisphereSizeDivisor, texMap, ref maxIntensity); texIndex++; } } UpdateViewportLightmaps(); }