public Camera(Position position, Position lookAt) { this.position = position; this.lookAt = lookAt; //determine camera Coord System update(); }
private void button1_Click(object sender, System.EventArgs e) { try { double r = Convert.ToDouble(color_txtbox_r.Text); double g = Convert.ToDouble(color_txtbox_g.Text); double b = Convert.ToDouble(color_txtbox_b.Text); Color c = new Color(r,g,b); double x = Convert.ToDouble(txtbox_x.Text); double y = Convert.ToDouble(txtbox_y.Text); double z = Convert.ToDouble(txtbox_z.Text); Position p = new Position(x, y, z); LightSource l = new LightSource(p, c); RayTracer_Form.lights.AddLast(l); parent.updateLights(); Console.WriteLine("light created"); } catch { Console.WriteLine("ERROR: Invalid Input for Light source values"); } this.Hide(); }
public virtual Vector getNormalAt(Position point) { return normal; }
//constructors public Vector(Position a, Position b) { this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; }
private void button1_Click(object sender, EventArgs e) { string selection = (string)comboBox1.SelectedItem; if (o == null) { o = new Object(); } switch (selection) { case "Plane": try { double plane_normal_x = Convert.ToDouble(txtbox_x.Text); double plane_normal_y = Convert.ToDouble(txtbox_y.Text); double plane_normal_z = Convert.ToDouble(txtbox_z.Text); double plane_color_r = Convert.ToDouble(color_txtbox_r.Text); double plane_color_g = Convert.ToDouble(color_txtbox_g.Text); double plane_color_b = Convert.ToDouble(color_txtbox_b.Text); Color color = new Color(plane_color_r, plane_color_g, plane_color_b); Vector normal = new Vector(plane_normal_x, plane_normal_y, plane_normal_z); double distance = Convert.ToDouble(sphere_txtbox_radius.Text); o = new Plane(normal, distance, color); if (!RayTracer_Form.objects.Contains(o)) { RayTracer_Form.objects.AddLast(o); } parent.updateObjects(); Console.WriteLine("Plane Created"); } catch(Exception ex) { Console.WriteLine(ex); } break; case "Sphere": try { double sphere_x = Convert.ToDouble(txtbox_x.Text); double sphere_y = Convert.ToDouble(txtbox_y.Text); double sphere_z = Convert.ToDouble(txtbox_z.Text); double sphere_r = Convert.ToDouble(color_txtbox_r.Text); double sphere_g = Convert.ToDouble(color_txtbox_g.Text); double sphere_b = Convert.ToDouble(color_txtbox_b.Text); Position center = new Position(sphere_x, sphere_y, sphere_z); double radius = Convert.ToDouble(sphere_txtbox_radius.Text); Color c = new Color(sphere_r, sphere_g, sphere_b); o = new Sphere(radius, center, c); if (RayTracer_Form.objects.Contains(o)) { } else { RayTracer_Form.objects.AddLast(o); } parent.updateObjects(); Console.WriteLine("Sphere Created"); } catch (Exception ex) { Console.WriteLine(ex); } break; default: return; } this.Hide(); }
public override Vector getNormalAt(Position point) { return normal; }
private void RayTracer_Form_Load(object sender, System.EventArgs e) { objects = new LinkedList<Object>(); lights = new LinkedList<LightSource>(); objects.AddLast(new Plane(new Vector(0, 1, 0), -1, new Color(255, 0, 0))); objects.AddLast(new Sphere(1, new Position(0, 0, 0), new Color(0, 255, 0))); cam_pos = new Position(0, 1, -5); lookat = new Position(0, 0, 0); Color WHITE = new Color(255, 255, 255); LightSource l1 = new LightSource(new Position(0, 1, -10), WHITE); lights.AddLast(l1); this.camera = new Camera(cam_pos, lookat); pictureBox1.Image = Program.run_raytracer(objects, lights, camera, pictureBox1.Size); pictureBox1.Refresh(); updateObjects(); updateLights(); }
public Sphere(double radius, Position center, Color color) { this.radius = radius; this.color = color; this.center = center; }
public override Vector getNormalAt(Position point) { return new Vector(point, center); }