Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Parser          parser          = new Parser();
            DatabaseHandler databaseHandler = new DatabaseHandler();
            //SceneDatabase sceneDatabase = new SceneDatabase();

            //DatabaseHandler.CreateTestProject(sceneDatabase);

            //DatabaseHandler.Save(sceneDatabase, ""); // Removed so the xml can be manipulated

            DataSet data = new DataSet();

            DataTableHelper.ReadXmlIntoDataSet(data, "database.xml");
            //DataTableHelper.ShowDataSet(data);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            List <Scene> scenes = parser.LoadScene(data);

            foreach (Scene scene in scenes)
            {
                Renderer renderer = new Renderer(scene, scene.allObjects);
                Console.WriteLine("Raytracing started.");
                int          time   = Environment.TickCount;
                RenderWindow window = renderer.Render();
                time = -time + Environment.TickCount;
                Console.WriteLine("Raytracing finished.");
                window.ShowImage();
                Console.WriteLine("Intersection calculating time: \t" + scene.intersectionCalculationCount + "\nRender time: \t\t" + time + "ms");
                Application.Run(window);
            }
        }
Exemplo n.º 2
0
        private void MenuItem_Load_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog fDialog = new System.Windows.Forms.OpenFileDialog();

            if (fDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            string  filename = fDialog.FileName;
            DataSet data     = new DataSet();

            RayTracer.Parser parser = new RayTracer.Parser();

            RayTracer.Database.DataTableHelper.ReadXmlIntoDataSet(data, filename);
            List <RayTracer.Scene> scenes = parser.LoadScene(data);

            addFloor = false;
            DragCanvas canvas = (DragCanvas)this.FindName("canvas");

            canvas.Children.Clear();
            objects.Clear();
            ContextMenu contextMenu = (ContextMenu)this.FindName("selectContextMenu");

            contextMenu.Items.Clear();


            foreach (Scene scene in scenes)
            {
                this.camera = scene.camera;
                this.light  = scene.light;

                foreach (AObject aObject in scene.allObjects)
                {
                    if (aObject.GetType() == typeof(RayTracer.Floor))
                    {
                        addFloor = true;
                    }
                    else if (aObject.GetType() == typeof(RayTracer.Block))
                    {
                        CreateBlock((RayTracer.Block)aObject);
                    }
                    else if (aObject.GetType() == typeof(RayTracer.Sphere))
                    {
                        CreateEllipse((RayTracer.Sphere)aObject);
                    }
                }

                break;
            }
        }