static void Main(string[] args) { // init structures objects = new List<RTObject>(); lights = new List<Light>(); random = new Random(01478650229); Bitmap canvas = new Bitmap(CANVAS_WIDTH, CANVAS_HEIGHT); // add some objects for (int i = 0; i < 30; i++) { float x = (float)(random.NextDouble() * 10.0f) - 5.0f; // Range -5 to 5 float y = (float)(random.NextDouble() * 10.0f) - 5.0f; // Range -5 to 5 float z = (float)(random.NextDouble() * 10.0f); // Range 0 to 10 Color c = Color.FromArgb(255, random.Next(255), random.Next(255), random.Next(255)); Sphere s = new Sphere(new Vector3f(x, y, z), (float)(random.NextDouble()), c); objects.Add(s); } //Sphere debugSphere = new Sphere(new Vector3f(0, 0, 5.0f), 0.2f, Color.ForestGreen); //objects.Add(debugSphere); Plane floor = new Plane(new Vector3f(0, 1.0f, 0), -10.0f, Color.Aquamarine); objects.Add(floor); // add some lights lights.Add(new Light(new Vector3f(2.0f, 0.0f, 0))); lights.Add(new Light(new Vector3f(0, 10.0f, 7.5f))); // calculate width and height of a pixel in world space coords pixelWidth = (screenBottomRightPos.x - screenTopLeftPos.x) / CANVAS_WIDTH; pixelHeight = (screenTopLeftPos.y - screenBottomRightPos.y) / CANVAS_HEIGHT; // render it int dotPeriod = CANVAS_HEIGHT / 10; System.Console.WriteLine("Rendering...\n"); System.Console.WriteLine("|0%---100%|"); RenderRow(canvas, dotPeriod, 0); // save the pretties canvas.Save("output.png"); }
//static void Main(string[] args) { public static void Main() { // init structures objects = new List<RTObject>(); lights = new List<Light>(); random = new Random(1478650229); stopwatch = new Stopwatch(); speedSamples = new List<double>(); checkNumber = 0; Bitmap canvas = new Bitmap(CANVAS_WIDTH, CANVAS_HEIGHT); // attach canvas to main form Document.canvas.Image = canvas; // add some objects // in the original test it was 30 and not 300 for (int i = 0; i < 300; i++) { number x = (number)(random.NextDouble() * 10.0f) - 5.0f; // Range -5 to 5 number y = (number)(random.NextDouble() * 10.0f) - 5.0f; // Range -5 to 5 number z = (number)(random.NextDouble() * 10.0f); // Range 0 to 10 Color c = Color.FromArgb(255, random.Next(255), random.Next(255), random.Next(255)); Sphere s = new Sphere(new Vector3f(x, y, z), (number)(random.NextDouble()), c); objects.Add(s); } //Sphere debugSphere = new Sphere(new Vector3f(0, 0, 5.0f), 0.2f, Color.ForestGreen); //objects.Add(debugSphere); Plane floor = new Plane(new Vector3f(0, 1.0f, 0), -10.0f, Color.Aquamarine); objects.Add(floor); // add some lights lights.Add(new Light(new Vector3f(2.0f, 0.0f, 0))); lights.Add(new Light(new Vector3f(0, 10.0f, 7.5f))); // calculate width and height of a pixel in world space coords pixelWidth = (screenBottomRightPos.x - screenTopLeftPos.x) / CANVAS_WIDTH; pixelHeight = (screenTopLeftPos.y - screenBottomRightPos.y) / CANVAS_HEIGHT; // render it int dotPeriod = CANVAS_HEIGHT / 10; Console.WriteLine("Rendering...\n"); Console.WriteLine("|0%---100%|"); RenderRow(canvas, dotPeriod, 0); }
static void Main(string[] args) { // init structures objects = new List<RTObject>(); random = new Random(45734); Bitmap canvas = new Bitmap(CANVAS_WIDTH, CANVAS_HEIGHT); // add some objects Sphere s = new Sphere(new Vector3f(-2.0f, 2.0f, 0), 1.0f, Color.FromArgb(255, 127, 0, 0)); objects.Add(s); s = new Sphere(new Vector3f(0, 2.0f, 0), 1.0f, Color.OldLace); s.isEmitter = true; // this one's a light source objects.Add(s); s = new Sphere(new Vector3f(2.0f, 2.0f, 0), 1.0f, Color.FromArgb(255, 0, 127, 0)); objects.Add(s); // ceiling and floor // pathtracing needs things for photons to bounce off! otherwise // most photons exit the scene early before doing their max // number of bounces Plane floor = new Plane(new Vector3f(0, 1.0f, 0), 1.0f, Color.FromArgb(255, 200, 200, 200)); objects.Add(floor); Plane ceiling = new Plane(new Vector3f(0, -1.0f, 0), -5.0f, Color.FromArgb(255, 200, 200, 200)); objects.Add(ceiling); Plane leftWall = new Plane(new Vector3f(1.0f, 0, 0), -3.0f, Color.FromArgb(255, 75, 75, 200)); objects.Add(leftWall); Plane rightWall = new Plane(new Vector3f(-1.0f, 0, 0), -3.0f, Color.FromArgb(255, 200, 75, 75)); objects.Add(rightWall); Plane backWall = new Plane(new Vector3f(0, 0, -1), -3.0f, Color.FromArgb(255, 200, 200, 200)); objects.Add(backWall); // calculate width and height of a pixel in world space coords pixelWidth = (screenBottomRightPos.x - screenTopLeftPos.x) / CANVAS_WIDTH; pixelHeight = (screenTopLeftPos.y - screenBottomRightPos.y) / CANVAS_HEIGHT; // render it int dotPeriod = CANVAS_HEIGHT / 20; System.Console.WriteLine("Rendering...\n"); System.Console.WriteLine("|0%-----------100%|"); RenderRow(canvas, dotPeriod, 0); // save the pretties canvas.Save("output.png"); }