// tick: renders one frame public void Tick() { surface.Clear(0); inputManager.Update(); _raytracer.HandleInput(); _raytracer.Render(); }
// tick: renders one frame public void Tick() { //Check if there are keys pressed CheckMovement(); //Clear the screen and draw a line between the debugscreen and the raytracer screen.Clear(0); screen.Line(512, 0, 512, 512, 0xffffff); //Shoot rays for (int x = 0; x < camera.pixels.GetLength(0); x++) for (int y = 0; y < camera.pixels.GetLength(1); y++) { //Make sure we only draw an apropriate amount of debugrays if (y == 255 && x % 10 == 0) debugRay = true; screen.pixels[x + y * screen.width] = VectorToInt(ShootRay(camera.pixels[x, y], x, y, 0)); debugRay = false; } //Write suitable information on the screen screen.Print("FOV = " + camera.fov, 517, 5, 0xffffff); screen.Print("Camera Position = " + camera.origin.X + "; " + camera.origin.Y + "; " + camera.origin.Z + ";", 517, 25, 0xffffff); screen.Print("Camera Direction = " + camera.direction.X + "; " + camera.direction.Y + "; " + camera.direction.Z + ";", 517, 45, 0xffffff); screen.Print("Recursion = " + recursionMax + "; Debug recursion = " + debugRecusrionMax + ";", 517, 65, 0xffffff); //Draw the debugscreen DebugScreen(primitives, lights, camera, debugRays); debugRays.Clear(); }
public void Init() { lastframe = DateTime.Now; screen.Clear(0x000000); scene = Scene.ThreeBalls(); camera = new Camera(new Vector3(0, 0, 0), new Vector3(0, 0, 1), screen.width, screen.height, 0.8f); }
public void Tick() { KeyboardHandler.Update(); screen.Clear(0); rayTracer.Draw(viewScreen, debugScreen); AddSurface(0, 0, viewScreen); AddSurface(screen.width - debugScreen.width, 0, debugScreen); }
public static void SwapBuffers() { primaryRays = new Ray[primaryRaysBuffer.Count]; primaryRaysBuffer.CopyTo(primaryRays); shadowRays = new Ray[shadowRaysBuffer.Count]; shadowRaysBuffer.CopyTo(shadowRays); reflectedRays = new Ray[reflectedRaysBuffer.Count]; reflectedRaysBuffer.CopyTo(reflectedRays); normals = new Ray[normalsBuffer.Count]; normalsBuffer.CopyTo(normals); primaryRaysBuffer.Clear(); shadowRaysBuffer.Clear(); reflectedRaysBuffer.Clear(); normalsBuffer.Clear(); screen.Clear(0); DrawDebug(); }
// tick: renders one frame public void Tick() { screen.Clear( 0 ); rayTracer.Render(); }
// tick: renders one frame public void Tick() { screen.Clear(0); render.Print("Dit is raytracer, niet game! Kusje, Laura", 2, 2, 0xffffff); // geef camera weer op scherm //debug.Box(camera.location[0], camera.location[2], camera.location[0] + 0.1f, camera.location[2] + 0.1f, CreateColor(255,255,255)); List <primitive> primitieven = scene.getprimitives(); int color; int teller = 0; foreach (primitive primitieve in primitieven) { if (teller > 3) { teller = 0; } switch (teller) { case 0: color = CreateColor(255, 0, 0); // red break; case 1: color = CreateColor(0, 255, 0); // green break; case 2: color = CreateColor(0, 0, 255); // blue break; case 3: color = CreateColor(255, 0, 255); // pink?? break; default: color = CreateColor(255, 255, 255); // white break; } if (primitieve.GetType().Equals(typeof(plane))) { plane screenplane = (plane)primitieve; // vanuit positie camera en richting camera en FOV (hoek) en afstand camera tot scherm // (FOV is nu 90) // bepaal je de lengte van het scherm. float[] middenscreenplane = new float[3]; middenscreenplane = nieuwelocatie(camera.location, screenplane.distancetoorigin, camera.direction); float lengtehalfscherm = (float)(Math.Tan(45) * screenplane.distancetoorigin); float[] punt1 = nieuwelocatie(middenscreenplane, lengtehalfscherm, nieuwerichting(camera.direction, 1)); float[] punt2 = nieuwelocatie(middenscreenplane, lengtehalfscherm, nieuwerichting(camera.direction, 0)); debug.Line(0, punt1[2], punt2[0], punt2[2], CreateColor(0, 255, 0)); // op basis van de lengte van het scherm en de normaal (of de kijkrichting) bepaal je // de uiterste punten van de plane, zowel x, y als z // met x en z teken je de plane als een lijn op je scherm //debug.Plane(plane.position,plane.width,plane.height, color); teller++; } else if (primitieve.GetType().Equals(typeof(sphere))) { sphere bol = (sphere)primitieve; debug.Circle(bol.position[0], bol.position[2], bol.radius, color); teller++; } } render.CopyTo(screen, 0, 0); debug.CopyTo(screen, 512, 0); // TODO teken hier de spheres: links in 3d en rechts in 2d bovenaanzicht }