예제 #1
0
        void FormMain_Load(object sender, EventArgs e)
        {
            scene = new Scene();
            scene.ProgressReport = new Progress<int>((i) => progBar.Increment(1));

            UpdateRenderControl();

            cBoxResolution.Items.AddRange(new object[] { "320x240", "640x360", "640x480", "960x540", "1024x768", "1280x720", "1920x1080", "2560x1440", "3840x2160" });
            cBoxResolution.Text = cBoxResolution.Items[0].ToString();

            cBoxSuSas.Items.AddRange(samples.Select<int, object>((i) => "x" + i).ToArray());
            cBoxSuSas.Text = cBoxSuSas.Items[0].ToString();
            settings.samples = samples[0];

            cBoxSuSaMode.Items.AddRange(modes.Select<SuperSampleMode, object>((s) => s.ToString()).ToArray());
            cBoxSuSaMode.Text = cBoxSuSaMode.Items[0].ToString();
            settings.mode = modes[0];

            ParseResolution();
        }
예제 #2
0
파일: Scene.cs 프로젝트: kruzifix/RayTracor
        public static Scene ParseJson(string path)
        {
            JObject root = JObject.Parse(File.ReadAllText(path));

            Scene scene = new Scene();

            scene.camera = Camera.FromJToken(root["camera"]);
            if (root["bgcolor"] == null)
                throw new Exception("Scene: 'bgcolor' not defined.");
            scene.backgroundColor = Utility.ColorFromHexString(root["bgcolor"].ToString()).ToVector();

            foreach(JToken tok in root["lights"].Children())
                scene.lights.Add(ILight.ParseJToken(tok));
            foreach(JToken tok in root["materials"].Children())
            {
                Material m = Material.FromJToken(tok);
                if (scene.materials.ContainsKey(m.Name))
                    throw new Exception(string.Format("Materials: 'name' has to be unique. Duplicate: '{0}'", m.Name));
                scene.materials.Add(m.Name, m);
            }

            foreach(JToken tok in root["objects"].Children())
            {
                IObject obj = IObject.ParseJToken(tok);
                if (!scene.materials.ContainsKey(obj.Material))
                    throw new Exception(string.Format("Objects: Unknown Material '{0}'", obj.Material));
                scene.objects.Add(obj);
            }

            return scene;
        }
예제 #3
0
 private void bLoad_Click(object sender, EventArgs e)
 {
     //XmlDocument doc = new XmlDocument();
     //doc.Load("scenes/AO_test.xml");
     //scene = Scene.ParseXml(doc);
     scene = Scene.ParseJson("scenes/mesh_test.json");
     scene.ProgressReport = new Progress<int>((i) => progBar.Increment(1));
     
     UpdateRenderControl();
 }