Beispiel #1
0
        protected virtual unsafe Vector2Int[][][] Rasterize(Vector2[][] screenCoords, TV2F[][] modelV2Fs, IPrimitive[][] primitives)
        {
            Rasterizer.StartRasterize(_bufferSizeF);
            Vector2Int[][][] rasterization = new Vector2Int[modelV2Fs.Length][][];

            Vector2 *primitiveCoords = stackalloc Vector2[3];

            for (int modelIndex = 0; modelIndex < modelV2Fs.Length; modelIndex++)
            {
                rasterization[modelIndex] = new Vector2Int[primitives[modelIndex].Length][];
                for (int primitiveIndex = 0; primitiveIndex < primitives[modelIndex].Length; primitiveIndex++)
                {
                    IPrimitive primitive = primitives[modelIndex][primitiveIndex];

                    for (int j = 0; j < primitive.Count; j++)
                    {
                        primitiveCoords[j] = screenCoords[modelIndex][primitive.Indices[j]];
                    }
                    Rasterizer.SetPoints(primitiveCoords);

                    switch (primitive.Count)
                    {
                    case 2:
                        Rasterizer.Line();
                        break;

                    default:
                        throw new NotImplementedException("Rasterization for this kind of primitive is not supported");
                        break;
                    }
                    rasterization[modelIndex][primitiveIndex] = Rasterizer.ContriveResult();
                }
            }

            Rasterizer.EndRasterize();
            return(rasterization);
        }
Beispiel #2
0
 private void BeginRasterize()
 {
     Rasterizer.StartRasterize(_bufferSizeF);
 }