Beispiel #1
0
        void RayTraccing()
        {
            var width  = pictureBox1.Width;
            var height = pictureBox1.Height;

            Scene.camera = new Camera(new Vec3(0, 5, 15), new Vec3(0, 0, -1), new Vec3(0, 1, 0), 90);
            Lighting lights = new Lighting();

            lights.Add(new LightClass(new MyColor(1, 1, 1), new Vec3(0.5, -1, -1)));
            Scene.lights  = lights;
            Scene.figures = FigureList();
            Scene.Initialize();
            TraccedImage image = new TraccedImage(height, width);

            pictureBox1.Image = image.GetImage();
        }
Beispiel #2
0
        private void initCells(Size cellSize, MapHeights heights, MapNormals normals, Lighting light, int[,] distribution)
        {
            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    if (Map[i, j] == null)
                    {
                        Map[i, j] = new Cell(i, j, cellSize);
                    }
                    for (int k = 0; k < cellSize.Width; k++)
                    {
                        for (int s = 0; s < cellSize.Height; s++)
                        {
                            int x  = Map[i, j].Location.X + k;
                            int y  = Map[i, j].Location.Y + s;
                            int cx = i * cellSize.Width + k;
                            int cy = j * cellSize.Height + s;
                            switch (distribution[cx, cy] == 0 ? Cell.Element.GROUND : Cell.Element.WATER)
                            {
                            case Cell.Element.WATER:
                                Map[i, j][k, s] =
                                    new Cell.Property(
                                        new Water(x, y, heights[cx, cy]),
                                        new Normal(x, y, normals[cx, cy]));
                                break;

                            case Cell.Element.GROUND:
                                Map[i, j][k, s] =
                                    new Cell.Property(
                                        new Ground(x, y, heights[cx, cy], normals[cx, cy]),
                                        new Normal(x, y, normals[cx, cy]));
                                break;
                            }
                            if (Map[i, j][k, s].Height is IBrightness)
                            {
                                light.Add((IBrightness)Map[i, j][k, s].Height);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 void AddLightingPair(Vector2 lightingPair)
 {
     Lighting.Add(lightingPair);
 }