public void DrawTriangle(Triangle3D t, Light light)
        {
            Triangle3DRasterizer r = new Triangle3DRasterizer(t, light);

            Triangle3DLine[] lines = r.Execute();

            for (int i = 0; i < lines.Length; i++)
            {
                for (int j = 0; j < lines[i].Count; j++)
                {
                    DrawVertex(lines[i][j]);
                }
            }
        }
        public Model GetModel()
        {
            XmlElement xModel = _XMLModel.DocumentElement;

            Model model = new Model();

            foreach (XmlNode xTriangle in xModel)
            {
                Vector3D           n  = GetNormal(xTriangle);
                Vertex             v1 = GetVertex(xTriangle, "vertex1");
                Vertex             v2 = GetVertex(xTriangle, "vertex2");
                Vertex             v3 = GetVertex(xTriangle, "vertex3");
                MaterialProperties mp = GetMaterial(xTriangle);
                Triangle3D         t  = new Triangle3D(v1, v2, v3, n, mp);
                model.AddTriangle(t);
            }

            return(model);
        }
        public Triangle3DRasterizer(Triangle3D triangle, Light light)
        {
            _Triangle = triangle;
            _Light    = light;

            _X1 = Maths.Round(triangle.V1.Position.X);
            _Y1 = Maths.Round(triangle.V1.Position.Y);

            _X2 = Maths.Round(triangle.V2.Position.X);
            _Y2 = Maths.Round(triangle.V2.Position.Y);

            _X3 = Maths.Round(triangle.V3.Position.X);
            _Y3 = Maths.Round(triangle.V3.Position.Y);

            yMin = Maths.Min(_Y1, _Y2, _Y3);
            yMax = Maths.Max(_Y1, _Y2, _Y3);

            _Lines = new Triangle3DLine[yMax - yMin + 1];
        }