Exemplo n.º 1
0
        public static void SortTrianglePoints(VertexBuffer vbx, FrameBuffer frameBuffer, int triangleIndices, out PaintedVertex v0, out PaintedVertex v1, out PaintedVertex v2)
        {
            var t = vbx.Volume.Triangles[triangleIndices];

            var worldNormVertices  = vbx.WorldNormVertices;
            var projectionVertices = vbx.ProjectionVertices;
            var worldVertices      = vbx.WorldVertices;

            v0 = new PaintedVertex(worldNormVertices[t.I0], frameBuffer.ToScreen3(projectionVertices[t.I0]), worldVertices[t.I0]);
            v1 = new PaintedVertex(worldNormVertices[t.I1], frameBuffer.ToScreen3(projectionVertices[t.I1]), worldVertices[t.I1]);
            v2 = new PaintedVertex(worldNormVertices[t.I2], frameBuffer.ToScreen3(projectionVertices[t.I2]), worldVertices[t.I2]);

            if (v0.ScreenPoint.Y > v1.ScreenPoint.Y)
            {
                MiscUtils.Swap(ref v0, ref v1);
            }
            if (v1.ScreenPoint.Y > v2.ScreenPoint.Y)
            {
                MiscUtils.Swap(ref v1, ref v2);
            }
            if (v0.ScreenPoint.Y > v1.ScreenPoint.Y)
            {
                MiscUtils.Swap(ref v0, ref v1);
            }
        }
Exemplo n.º 2
0
        public void DrawLine(FrameBuffer surface, ColorRGB color, Vector4 projectionP0, Vector4 projectionP1)
        {
            if (!clipperH.Clip(ref projectionP0, ref projectionP1))
            {
                return;
            }

            var p0 = surface.ToScreen3(projectionP0);
            var p1 = surface.ToScreen3(projectionP1);

            surface.DrawLine(p0, p1, color);
        }