public static void DrawCircle(Surface s, float xin, float yin, float rin, Vector3 c) { int x0 = TX(xin, s); int y0 = TY(yin, s); int radius = (int)(rin * (s.width / Game.SCENE_WIDTH)); int x = radius; int y = 0; int err = 0; int col = ConstructColor(c.X, c.Y, c.Z); while (x >= y) { s.Plot(x0 + x, y0 + y, col); s.Plot(x0 + y, y0 + x, col); s.Plot(x0 - y, y0 + x, col); s.Plot(x0 - x, y0 + y, col); s.Plot(x0 - x, y0 - y, col); s.Plot(x0 - y, y0 - x, col); s.Plot(x0 + y, y0 - x, col); s.Plot(x0 + x, y0 - y, col); y += 1; if (err <= 0) { err += 2 * y + 1; } if (err > 0) { x -= 1; err -= 2 * x + 1; } } }
public void Render() { //for (every pixel in the camera plane), find the color //reuse the same ray Ray ray; for (int x = 0; x < 512; x++) //screen width = 512, maar client width = 1024 (want debug scherm rechts) { for (int y = 0; y < 512; y++) { //add the z calculations here once we have a working rotating camera Vector3 screenpoint = new Vector3(xlength * ((float)x / (screen.width / 2)) - (xlength / 2), ylength * ((float)y / screen.height) - (ylength / 2), 0); //z heeft met cam te maken ray = new Ray(); ray.Origin = camera.pos; ray.Dir = (screenpoint - ray.Origin).Normalized(); //normaliseer ray so length is 1 Vector3 color; if (y == 256 && (x % 31) == 0) { color = trace(ray, 6, true); } else { color = trace(ray, 6, false); } screen.Plot(x, 512 - y, debug.createColor(color)); //512 - y because to invert the y axis (so positive is up and negative is down) } } debug.Render(); }
public void RenderCamera() { surface.Plot(TX(camera.pos.X), TY(camera.pos.Z), 0xFFFFFF); }