示例#1
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;
            }
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            light = new RayTracer.Light(1, new RayTracer.Point(-15, 10, 20));
            RayTracer.Point point = new RayTracer.Point(5.3368f, 8.0531f, 9.8769f);

            RayTracer.Vector direction = new RayTracer.Vector(-0.38363f, -0.42482f, -0.82f);

            RayTracer.Vector directionUp = new RayTracer.Vector(-0.16485f, 0.90515f, -0.391826f);

            this.camera = new RayTracer.Camera(-1, point, direction, directionUp, 60f);


            Button front = (Button)this.FindName("viewButtonFront");

            front.Foreground = new SolidColorBrush(Colors.Red);

            TextBox positionZ, depth;

            positionZ           = (TextBox)this.FindName("positionZ");
            positionZ.IsEnabled = false;
            depth           = (TextBox)this.FindName("rectangleDepth");
            depth.IsEnabled = false;
        }
示例#3
0
 public BranchTree()
 {
     light = new Light(0, 2, -1);
 }