/// <summary> /// Get the rendering options for the scenes that a scene depends upon. /// </summary> /// <param name="scene"></param> /// <param name="options"></param> /// <returns></returns> internal IEnumerable <PovrayOptions> GetDependentScenes(Scene scene, PovrayOptions options) { foreach (Scene dependentScene in scene.DependentScenes) { PovrayOptions opt = new PovrayOptions(scene.PovrayOptions); opt.SetOptions(options); opt.SetOptions(dependentScene.PovrayOptions); opt.SceneParsing.InputFileName = dependentScene.OutputFile; opt.FileOutput.OutputFileName = dependentScene.OutputImageFile; foreach (PovrayOptions child in this.GetDependentScenes(dependentScene, opt)) { yield return(child); } yield return(opt); } }
/// <summary>Renders a scene.</summary> /// <param name="options">Povray options, overriding the values that are set in the scene (if any).</param> /// <param name="scene">The scene to render.</param> /// <returns></returns> public bool Render(Scene scene, PovrayOptions options = null) { // Duplicate the scene's options, and copy the provided values. PovrayOptions mergedOptions = new PovrayOptions(scene.PovrayOptions); mergedOptions.SetOptions(options); // Write the scene file. if (string.IsNullOrEmpty(mergedOptions.SceneParsing.InputFileName)) { mergedOptions.SceneParsing.InputFileName = "pov.pov"; } scene.PovVersion = this.Version; scene.WriteFile(mergedOptions.SceneParsing.InputFileName, mergedOptions.FileOutput.OutputFileName); if (scene.DependentScenes.Count > 0) { foreach (PovrayOptions dependent in this.GetDependentScenes(scene, options)) { dependent.DisplayOutput.PauseWhenDone = false; this.Render(dependent); } } bool result = this.Render(mergedOptions); if (options != null) { // Copy the output file onto the provided options. options.FileOutput.OutputFileName = mergedOptions.FileOutput.OutputFileName; } return(result); }