Beispiel #1
0
        private bool Open(string meshFile)
        {
            if (!File.Exists(meshFile))
            {
                return(false);
            }

            m_operations.Open(meshFile, m_operations.Input.WindingOrder);

            m_visualizedMaxLevel = m_operations.Context.Octree.MaxLevels;
            m_showOriginalMesh   = true;

            m_camera.cameraYaw = (float)(Math.PI * 0.5);

            m_camera.cameraPosition = m_operations.Context.Octree.Root.Center - new Vector3(-(m_operations.Context.Octree.MeshBounds.MinX - m_operations.Context.Octree.MeshBounds.MaxX), 0, 0);
            m_camera.Speed          = (m_operations.Context.Octree.Root.Bounds.MaxX - m_operations.Context.Octree.Root.Bounds.MinX) / 10.0f;
            m_camera.FastSpeed      = m_camera.Speed * 10.0f;

            m_camera.FarPlane  = (m_operations.Context.Octree.Root.Bounds.MaxX - m_operations.Context.Octree.Root.Bounds.MinX) * 4;
            m_camera.NearPlane = m_camera.FarPlane * m_camera.NearFarRatio;

            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);

            return(true);
        }
Beispiel #2
0
        public static void Run(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ProgramOptions options = new ProgramOptions();

            string            settingPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Oxel.Settings.xml");
            VoxelizationInput input       = VoxelizationInput.Load(settingPath);

            if (input == null)
            {
                input = new VoxelizationInput();
            }

            if (args.Contains("-c"))
            {
                // Make sure user can see console output
                AttachConsole(PARENT_PROCESS_ID);

                input.Clone(options);

                if (!CommandLineParser.Parse <ProgramOptions>(args, ref options))
                {
                    return;
                }

                options.Clone(input);
            }
            else
            {
                CommandLineParser.Parse <VoxelizationInput>(args, ref input);
            }

            if (options.UseCommandLine)
            {
                Logger.IsCommandLine = true;

                Operations operations = new Operations();
                operations.Initialize(input);
                operations.Open(options.InputMesh, input.WindingOrder);
                WaitHandle waitHandle = operations.GenerateOccluder((VoxelizationProgress vp) => {
                    string coverage =
                        String.Format("Volume Coverage     : {0,5:0.##}%", (100 * vp.VolumeCoverage)) + "    " +
                        String.Format("Silhouette Coverage : {0,5:0.##}%", (100 * vp.SilhouetteCoverage));

                    if (!String.IsNullOrEmpty(vp.Status))
                    {
                        Console.WriteLine(vp.Status + "\r\n");
                    }

                    Console.WriteLine(coverage);
                }, new Action(() => { }));
                waitHandle.WaitOne();
                operations.Save(options.OutputMesh);
            }
            else
            {
                using (MainWindow window = new MainWindow(input))
                {
                    window.ShowDialog();
                }
            }
        }