public static Pixel[] start() { Pixel[] pixels = new Pixel[Constants.WIN_X * Constants.WIN_Y]; Point3 viewPlane = new Point3(-Constants.WIN_X / 2, -Constants.WIN_X / 2, 0); createScene(); for (int y = 0; y < Constants.WIN_Y; y++) { for (int x = 0; x < Constants.WIN_X; x++) { Pixel p = new Pixel(); p.rect.X = x; p.rect.Y = Constants.WIN_Y - 1 - y; Point3 viewPixel = new Point3(); viewPixel.x = viewPlane.x + x; viewPixel.y = viewPlane.y + y; viewPixel.z = viewPlane.z; Ray r = new Ray(); r.direction = Point3.vectorize(layout.Cam.Eye, viewPixel); r.start = layout.Cam.Eye; p.color = fireRay(r, Constants.MIN_DEPTH, null); pixels[y * Constants.WIN_X + x] = p; } } return pixels; }
public static double distance(Point3 p1, Point3 p2) { return Math.Sqrt( Math.Pow(p1.x - p2.x, 2) + Math.Pow(p1.y - p2.y, 2) + Math.Pow(p1.z - p2.z, 2) ); }
public static Vector3 vectorize(Point3 p1, Point3 p2) { Vector3 v = new Vector3(); v.X = p2.x - p1.x; v.Y = p2.y - p1.y; v.Z = p2.z - p1.z; v.Normalize(); return v; }
public Light(Point3 location, Color3 color) { this._Location = location; this._Color = color; }
public Sphere(SphereMaterial sp) : base(sp) { this.center = sp.Center; this.radius = sp.Radius; normals = new Dictionary<Point3, Vector3>(); }