Ejemplo n.º 1
0
        void fillTriangle(Triangle T, int ApexIndex, Color C)
        {
            LineEquation L1, L2;

            Dimension.data.Point Apex = T.wireframeSegment[ApexIndex];

            L1 = new LineEquation(Apex, T.wireframeSegment[(ApexIndex + 1) % 3]);
            L2 = new LineEquation(Apex, T.wireframeSegment[(ApexIndex + 2) % 3]);

            Dimension.data.Point raster1, raster2, rasterPoint;

            raster1 = L1.calculateNextPoint(Apex);
            raster2 = L2.calculateNextPoint(Apex);

            for (int i = 0; i < L2.length; i++)
            {
                LineEquation RasterLine = new LineEquation(raster1, raster2);
                rasterPoint = RasterLine.calculateNextPoint(raster1);
                for (int j = 0; j < RasterLine.length; j++)
                {
                    if (rasterPoint.x >= stageWpx || rasterPoint.y >= stageHpx || rasterPoint.x < 0 || rasterPoint.y < 0)
                    {
                        rasterPoint = RasterLine.calculateNextPoint(rasterPoint);
                        continue;
                    }
                    Outbound.SetPixel((int)rasterPoint.x, (int)rasterPoint.y, C);
                    rasterPoint = RasterLine.calculateNextPoint(rasterPoint);
                }
                raster1 = L1.calculateNextPoint(raster1);
                raster2 = L2.calculateNextPoint(raster2);
            }
        }
Ejemplo n.º 2
0
 void renderTriangleOutline(Triangle T, Color C)
 {
     //Will fill in the lines between 2 points using
     //Equation y=mx+C;
     for (int i = 0; i < T.wireframeSegment.Count(); i++)
     {
         //Outbound.SetPixel((int)T.wireframeSegment[i].x, (int)T.wireframeSegment[i].y, Color.Aqua);
         int                  f        = (i + 1) % T.wireframeSegment.Count();
         LineEquation         curLine  = new LineEquation(T.wireframeSegment[i], T.wireframeSegment[f]);
         Dimension.data.Point curPoint = T.wireframeSegment[i];
         for (int j = 0; j < curLine.length; j++)
         {
             if (curPoint.x >= stageWpx || curPoint.y >= stageHpx || curPoint.x < 0 || curPoint.y < 0)
             {
                 curPoint = curLine.calculateNextPoint(curPoint);
                 continue;
             }
             Outbound.SetPixel((int)curPoint.x, (int)curPoint.y, C);
             curPoint = curLine.calculateNextPoint(curPoint);
         }
     }
 }