Example #1
0
        public VolumeRenderer(Volume volume)
        {
            Viewport            = new Viewport();
            TransferFunction    = new TransferFunction();
            RenderConfiguration = new RenderConfiguration();
            this.Volume         = volume;

            SetLocalRenderingParameters();
        }
        public ConfigurationEditor(VolumeRenderer volumeRenderer, Action renderConfigUpdated)
        {
            _volumeRenderer      = volumeRenderer;
            _renderConfiguration = volumeRenderer.RenderConfiguration;
            _renderConfigUpdated = renderConfigUpdated;

            InitializeComponent();

            foreach (RenderingMode value in Enum.GetValues(typeof(RenderingMode)))
            {
                comboBoxRenderMode.Items.Add(value.ToFriendlyString());
            }
            comboBoxRenderMode.SelectedIndex = 0;
        }
Example #3
0
        public int HandleCli(string[] Args)
        {
            _Configuration = new RenderConfiguration(_ColourPalette, _Metrics);

            // *** Function returns TRUE if the command line is invalid and the program should NOT proceed.
            if (HandleCommandLineArguments(Args))
            {
                return(0);
            }


            // *** World path is mandatory.
            if (_Configuration.WorldPath == "")
            {
                Console.WriteLine("A world must be specified.");
                ShowHelp();
                return(0);
            }

            // *** Load the world
            Console.WriteLine("Opening world file:");
            Console.WriteLine("    " + _Configuration.WorldPath + "...");
            AnvilWorld World;


            // *** Try and open the world.  If it fails, handle it gracefully
            try
            {
                World = AnvilWorld.Open(_Configuration.WorldPath);
            }
            catch (Exception Ex)
            {
                Console.WriteLine("World could not be opened for reading:");
                Console.WriteLine(Ex.ToString());
                Console.WriteLine("Please check that the world exists and is valid.");
                return(0);
            }


            // *** Read world and compute metrics (size, chunk count, more?)
            Console.WriteLine("Determining world boundaries");
            _StepTimer.Reset();
            _StepTimer.Start();
            _Metrics.Measure(World.GetChunkManager(_Configuration.Dimension));
            _StepTimer.Stop();
            Console.WriteLine("Took " + _StepTimer.Elapsed.ToString("m\\ms\\sff"));
            Console.WriteLine("Boundaries: (" + _Metrics.MinX.ToString() + ", " + _Metrics.MinZ.ToString() + ") to (" + _Metrics.MaxX.ToString() + ", " + _Metrics.MaxZ.ToString() + ")");


            // *** Render dimension, if applicable
            if (_Configuration.SaveFilename != "")
            {
                _StepTimer.Reset();
                _StepTimer.Start();

                // *** Load palettes.  Start with palettes in EXE directory, then append all palettes in the force-load list.
                Console.WriteLine("Loading Palettes...");
                // ReSharper disable once AssignNullToNotNullAttribute
                // *** It's probably safe to assume our EXE is gonna be in a folder.
                foreach (String PalFile in Directory.EnumerateFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "*.pal").Concat(_LoadAdditionalPalettes))
                {
                    string PaletteFile = PalFile;

                    if (!PaletteFile.EndsWith(".pal") && !File.Exists(PaletteFile)) //Append ".pal" to filename if it's been accidentally omitted
                    {
                        PaletteFile += ".pal";
                    }

                    if (File.Exists(PaletteFile))
                    {
                        try
                        {
                            _ColourPalette.LoadPalette(PaletteFile);
                        }
                        catch (BlockPalette.PaletteExecutionException Ex)
                        {
                            Console.WriteLine(Ex.Message);
                        }
                        catch (Exception Ex)
                        {
                            Console.WriteLine("Failed to load palette " + Path.GetFileNameWithoutExtension(PaletteFile) + ":");
                            if (Ex is BlockPalette.PaletteExecutionException)
                            {
                                Console.WriteLine(Ex.Message);
                            }
                            else
                            {
                                Console.WriteLine("Internal Error");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Skipped missing file " + PaletteFile);
                    }
                }

                _ColourPalette.AssembleLookupTables();

                Console.WriteLine("Palettes loaded.  Took " + _StepTimer.Elapsed.ToString("m\\ms\\sff"));
                _StepTimer.Reset();

                _StepTimer.Start();
                _Renderer = new StandardRenderer();

                // *** Set up the progress indicator
                Console.WriteLine("Using " + (_Configuration.EnableMultithreading ? "multi-threaded" : "single-threaded") + " " + _Renderer.RendererFriendlyName);


                _Renderer.ProgressUpdate += OnRenderProgressUpdate;
                _Renderer.RenderError    += OnRenderError;

                _Configuration.Chunks = World.GetChunkManager(_Metrics.Dimension);
                if (!_Configuration.RenderSubregion)
                {
                    _Configuration.SubregionChunks = new Rectangle(_Metrics.MinX, _Metrics.MinZ, (_Metrics.MaxX - _Metrics.MinX), (_Metrics.MaxZ - _Metrics.MinZ));
                }
                _Renderer.Configure(_Configuration);
                _Renderer.Initialize();

                if (!_Renderer.IsAborting)
                {
                    _Renderer.Render();
                }

                _StepTimer.Stop();

                if (_Renderer.IsAborting)
                {
                    Console.WriteLine("\r\nMap export failed.");
                }
                else
                {
                    Console.WriteLine("\r\nMap export complete.  Took " + _StepTimer.Elapsed.ToString("m\\ms\\sff"));
                }
            }


            // *** Produce sign information file, if applicable
            if (_Configuration.ScanFilename != "")
            {
                _StepTimer.Reset();
                _StepTimer.Start();

                SignExporter Exporter = new SignExporter();
                Exporter.Process(World.GetChunkManager(_Metrics.Dimension), _Metrics, _Configuration.ScanFilename);

                _StepTimer.Stop();
                Console.WriteLine("Took " + _StepTimer.Elapsed.ToString("m\\ms\\sff"));
            }


            // *** Write world metrics, if applicable
            if (_Configuration.MetricsFilename != "")
            {
                WriteMetricsFile(World);
            }

#if DEBUG
            System.Threading.Thread.Sleep(5500); // *** If debug mode, pause at the end to give me time to read any messages
#endif
            return(0);
        }
Example #4
0
 /// <summary>
 /// Initializes this map renderer with configuration.
 /// </summary>
 /// <param name="renderConfiguration"></param>
 public VectorMapRenderer(RenderConfiguration renderConfiguration)
 {
     configuration = renderConfiguration;
     blockSize     = MapRendererConstants.DEF_BLOCK_SIZE;
 }
Example #5
0
 public PlayerConfiguration()
 {
     Render   = new RenderConfiguration();
     Source   = new SourceConfiguration();
     Compress = new CompressConfiguration();
 }