void render() { Bitmap rendering = new Bitmap(1920, 1080); Sphere[] spheres = new Sphere[] { new Sphere(new Vector3(0, -1, 3), 1, new Color(255, 0, 0), 500, 0.06f), new Sphere(new Vector3(-2, 1, 3), 1, new Color(0, 0, 255), 500, 0.1f), new Sphere(new Vector3(2, 1, 3), 1, new Color(0, 255, 0), 10, 0), new Sphere(new Vector3(0, -5001, 0), 5000, new Color(255, 255, 0), 10, 0f) }; Light[] lights = new Light[] { new Light(LightType.ambient, 0.2f, new Vector3(0, 0, 0), new Vector3(0, 0, 0)), new Light(LightType.point, 0.6f, new Vector3(2, 1, 0), new Vector3(0, 0, 0)), new Light(LightType.directional, 0.2f, new Vector3(1, 4, 4), new Vector3(0, 0, 0)) }; Scene scene = new Scene(spheres, lights); Camera cam = new Camera(new Vector3(0, 0, -5)); Raytracer tracer = new Raytracer(cam, new Viewport((float)rendering.Width / (float)rendering.Height, 1, 1), rendering, scene, new Color(255, 255, 255)); tracer.Render(); rendering.RotateFlip(RotateFlipType.Rotate180FlipNone); this.pictureBox1.Image = rendering; //for mac development rendering.Save("renderresult.png"); }
public MainForm() { InitializeComponent(); rayTracer = new Raytracer(); rayTracer.OnProgress += new Raytracer.ProgressHandler(rt_OnProgress); RayDepthNumericUpDown.Value = rayTracer.RayDepth = 3; RayDepthNumericUpDown.ValueChanged += new EventHandler(RayDepthNumericUpDown_ValueChanged); }
public Form1() { InitializeComponent(); rt = new Raytracer(); rt.OnProgress += new Raytracer.ProgressHandler(rt_OnProgress); numericUpDown1.Value = rt.RayDepth = 3; numericUpDown1.ValueChanged += new EventHandler(numericUpDown1_ValueChanged); }
public Camera(Raytracer rt, Vector3 position) { this.rt = rt; this.Position = position; }
public object ThreadPoolCallback(Object threadContext) { Debug.WriteLine("Loading scene... "); Stopwatch stopwatch = Stopwatch.StartNew(); Raytracer raytracer = new Raytracer(); raytracer.prepareScene(m_sceneFileName); stopwatch.Stop(); Debug.WriteLine("Finished: loading scene [" + stopwatch.Elapsed.ToString()+"]"); Debug.WriteLine("Start: rendering"); stopwatch = Stopwatch.StartNew(); raytracer.startRaytracing(m_display); stopwatch.Stop(); Debug.WriteLine("Finished: rendering ["+ stopwatch.Elapsed.ToString()+"]"); return null; }