Beispiel #1
0
        public static Bitmap drawObjectXZ(Object3D obj, Bitmap b)
        {
            int        x1, x2, y1, y2;
            BitmapData bdma = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
                                         ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            foreach (Face f in obj.getFaces())
            {
                for (int i = 0; i < f.getVertexs().Count - 1; i++)
                {
                    x1 = (int)(330 + obj.getActuals()[f.getVertexs()[i]].getX());
                    y1 = (int)(250 + obj.getActuals()[f.getVertexs()[i]].getZ());
                    x2 = (int)(330 + obj.getActuals()[f.getVertexs()[i + 1]].getX());
                    y2 = (int)(250 + obj.getActuals()[f.getVertexs()[i + 1]].getZ());
                    GraphicPrimitives.bresenham(bdma, x1, y1, x2, y2);
                }
                x1 = (int)(330 + obj.getActuals()[f.getVertexs()[f.getVertexs().Count - 1]].getX());
                y1 = (int)(250 + obj.getActuals()[f.getVertexs()[f.getVertexs().Count - 1]].getZ());
                x2 = (int)(330 + obj.getActuals()[f.getVertexs()[0]].getX());
                y2 = (int)(250 + obj.getActuals()[f.getVertexs()[0]].getZ());
                GraphicPrimitives.bresenham(bdma, x1, y1, x2, y2);
            }

            b.UnlockBits(bdma);

            return(b);
        }
Beispiel #2
0
        private static void flat(Object3D obj, Vertex l, double[] argb, double[] drgb, double[] ergb, Vertex h, BitmapData bdma)
        {
            double        ln, hn;
            int           r, g, bc;
            List <Vertex> lv;

            foreach (Face f in obj.getFaces())
            {
                ln = l.getX() * f.getNormal().getX() + l.getY() * f.getNormal().getY() + l.getZ() * f.getNormal().getZ();
                hn = Math.Pow((h.getX() * f.getNormal().getX() + h.getY() * f.getNormal().getY() + h.getZ() * f.getNormal().getZ()), 10);

                r  = (int)(255 * (0.1 * argb[0] + 0.4 * drgb[0] * ln + 0.3 * ergb[0] * hn));
                g  = (int)(255 * (0.1 * argb[1] + 0.4 * drgb[1] * ln + 0.3 * ergb[1] * hn));
                bc = (int)(255 * (0.1 * argb[2] + 0.4 * drgb[2] * ln + 0.3 * ergb[2] * hn));

                if (f.getNormal().getZ() > 0)
                {
                    lv = new List <Vertex>();
                    for (int i = 0; i < f.getVertexs().Count; i++)
                    {
                        lv.Add(new Vertex(330 + obj.getActuals()[f.getVertexs()[i]].getX(), 250 + obj.getActuals()[f.getVertexs()[i]].getY(), obj.getActuals()[f.getVertexs()[i]].getZ()));
                    }
                    Fill.flat(lv, Color.FromArgb(limiter(0, 255, r), limiter(0, 255, g), limiter(0, 255, bc)), bdma);
                }
            }
        }
Beispiel #3
0
        private static void desenha(Object3D obj, Face f, BitmapData bdma)
        {
            int x1, x2, y1, y2;

            for (int i = 0; i < f.getVertexs().Count - 1; i++)
            {
                x1 = (int)(330 + obj.getActuals()[f.getVertexs()[i]].getX());
                y1 = (int)(250 + obj.getActuals()[f.getVertexs()[i]].getY());
                x2 = (int)(330 + obj.getActuals()[f.getVertexs()[i + 1]].getX());
                y2 = (int)(250 + obj.getActuals()[f.getVertexs()[i + 1]].getY());
                GraphicPrimitives.bresenham(bdma, x1, y1, x2, y2);
            }
            x1 = (int)(330 + obj.getActuals()[f.getVertexs()[f.getVertexs().Count - 1]].getX());
            y1 = (int)(250 + obj.getActuals()[f.getVertexs()[f.getVertexs().Count - 1]].getY());
            x2 = (int)(330 + obj.getActuals()[f.getVertexs()[0]].getX());
            y2 = (int)(250 + obj.getActuals()[f.getVertexs()[0]].getY());
            GraphicPrimitives.bresenham(bdma, x1, y1, x2, y2);
        }