Ejemplo n.º 1
0
        // Render the scene
        public void Render(bool debugging)
        {
            Ray ray;

            for (int y = 0; y < Screen.height; y++)
            {
                for (int x = 0; x < Screen.width / 2; x++)
                {
                    ray = Camera.getRay(x, y);
                    Intersection intersection = Scene.intersect(ray);

                    Screen.pixels[x + Screen.width / 2 + y * Screen.width] = intersection.color(Scene).getColor();
                    if (debugging && y == 256 && x % 50 == 0)
                    {
                        if (intersection.ThingWeIntersectedWith != Scene.Primitives[4])
                        {
                            intersection.debug(Screen);
                        }
                        else
                        {
                            ray.debug(Screen, 7, 3);
                        }
                    }
                }
                if (debugging)
                {
                    foreach (Primitive p in Scene.Primitives)
                    {
                        p.debug(Screen);
                    }
                    Camera.debug(Screen);
                }
            }
        }
Ejemplo n.º 2
0
        public Vector3 Render(float u, float v)
        {
            Ray ray = camera.getRay(u, v);

            if (u % (40f / 512f) == 0 && ray.Direction.Y == 0)
            {
                raylist.Add(ray);
            }
            int cap = 0;

            return(Trace(ray, cap));
        }