Esempio n. 1
0
        public static void _drawImage(int x0, int y0, int z0, int Xsize, int Xfi, int Xteta, int Ysize, int Yfi, int Yteta, Bitmap image, Bitmap dest)
        {
            double x1p0, x2p0, yp0, x1p1, x2p1, yp1;
            double XTeta = -Xteta * Math.PI / 180;
            double YTeta = -Yteta * Math.PI / 180;
            double XFi   = Xfi * Math.PI / 180;
            double YFi   = Yfi * Math.PI / 180;

            AX = Math.Sin(XFi) * Math.Cos(XTeta) * Xsize;
            BX = Math.Sin(XFi) * Math.Sin(XTeta) * Xsize;
            CX = Math.Cos(XFi) * Xsize;
            AY = Math.Sin(YFi) * Math.Cos(YTeta) * Ysize;
            BY = Math.Sin(YFi) * Math.Sin(YTeta) * Ysize;
            CY = Math.Cos(YFi) * Ysize;

            if (Xfi <= 90)
            {
                Graph3dDraw._to2Da((double)x0, (double)y0, (double)z0, out x1p0, out x2p0, out yp0);
                Graph3dDraw._to2Da((double)x0 + AY, (double)y0 + BY, (double)z0 + CY, out x1p1, out x2p1, out yp1);
            }
            else
            {
                Graph3dDraw._to2Da(x0 + AX, y0 + BX, z0 + CX, out x1p0, out x2p0, out yp0);
                Graph3dDraw._to2Da(x0 + (AX + AY), y0 + (BX + BY), z0 + (CX + CY), out x1p1, out x2p1, out yp1);
            }
            double dy  = Math.Pow(yp1 - yp0, 2);
            double dx1 = Math.Sqrt(Math.Pow(x1p1 - x1p0, 2) + dy);
            double dx2 = Math.Sqrt(Math.Pow(x2p1 - x2p0, 2) + dy);

            _fill_lines  = (dx1 > dx2) ? dx1 : dx2;
            _fill_lines *= 1.2;

            Graph3dStereoImage.src  = image;
            Graph3dStereoImage.dest = dest;
            Graph3dStereoImage.x0   = x0;
            Graph3dStereoImage.y0   = y0;
            Graph3dStereoImage.z0   = z0;
            int    threadCount = Environment.ProcessorCount;
            double delta       = _fill_lines / threadCount;

            Thread[] thread = new Thread[threadCount];
            int      i      = 0;

            for (; i < threadCount - 1; i++)
            {
                thread[i] = new Thread(testThread);
                thread[i].Start(new object[] { i *delta, (i + 1) * delta });
            }
            testThread(new object[] { i *delta, (i + 1) * delta });

            for (i = 0; i < threadCount - 1; i++)
            {
                while (thread[i].ThreadState == ThreadState.Running)
                {
                    ;
                }
            }
        }
Esempio n. 2
0
        public static void putpixel(int x, int y, int z, Color c, Bitmap pixels)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.putpixel(x, y, z, c, pixels);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 3
0
        public static void line(int x1m, int y1m, int z1m, int x2m, int y2m, int z2m)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.line(x1m, y1m, z1m, x2m, y2m, z2m, Graph.bitmap);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 4
0
        public static void outtextxy(int x, int y, int z, string s)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.outtextxy(x, y, z, s);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 5
0
        public static void circle(int x, int y, int z, int r)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.circle(x, y, z, r);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 6
0
        public static void fillellipse(int x0, int y0, int z0, int startangle, int endangle, int r1, int f1, int t1, int r2, int f2, int t2)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.fillellipse(x0, y0, z0, startangle, endangle, r1, f1, t1, r2, f2, t2);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 7
0
        public static void rectangle(int x0, int y0, int z0, int r1, int f1, int t1, int r2, int f2, int t2)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            Graph3dDraw.rectangle(x0, y0, z0, r1, f1, t1, r2, f2, t2);
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 8
0
        private static void lineImage(double x1m, double y1m, double z1m, double x2m, double y2m, double z2m, double time)
        {
            double x1p1, x2p1, yp1, x1p2, x2p2, yp2;

            if (Graph3d.glass == Glass.None)
            {
                Graph3dDraw._to2D(x1m, y1m, z1m, out x1p1, out yp1);
                Graph3dDraw._to2D(x2m, y2m, z2m, out x1p2, out yp2);
                lineImageDraw(x1p1, yp1, x1p2, yp2, false, time);
            }
            else
            {
                Graph3dDraw._to2Da(x1m, y1m, z1m, out x1p1, out x2p1, out yp1);
                Graph3dDraw._to2Da(x2m, y2m, z2m, out x1p2, out x2p2, out yp2);
                lineImageDraw(x2p1, yp1, x2p2, yp2, false, time);
                lineImageDraw(x1p1, yp1, x1p2, yp2, true, time);
            }
        }
Esempio n. 9
0
        static bool _getmouse(out int x, out int y, out int z)
        {
            if (!initCalled)
            {
                x = y = z = -1;
                return(false);
            }

            int tempX = MouseX, tempY = MouseY, tempZ = MouseZ;

            if (GForm2.RightClick)
            {
                tempZ -= Cursor.Position.Y - centerY;
            }
            else
            {
                tempY += Cursor.Position.Y - centerY;
            }
            tempX += Cursor.Position.X - centerX;

            double x1, x2, ym;

            Graph3dDraw._to2Da(tempX, tempY, tempZ, out x1, out x2, out ym);
            if (x1 >= 0 && x2 < Graph.width && ym >= 0 && ym < Graph.height)
            {
                MouseX = tempX;
                MouseY = tempY;
                MouseZ = tempZ;

                while (Cursor.Position.X != Graph.form.Left + Graph.form.Width / 2 || Cursor.Position.Y != Graph.form.Top + Graph.form.Height / 2)
                {
                    User32.SetCursorPos(Graph.form.Left + Graph.form.Width / 2, Graph.form.Top + Graph.form.Height / 2);
                }

                centerX = Cursor.Position.X;
                centerY = Cursor.Position.Y;
            }
            z = MouseZ;
            x = MouseX;
            y = MouseY;
            return(GForm2.LeftClick);
        }
Esempio n. 10
0
        private static void drawPixel(bool Left, double i, double j, Color c)
        {
            if (c.a > 0)
            {
                switch (Graph3d.glass)
                {
                case Glass.None:
                    Color back = Graph.getpixel((int)i, (int)j);
                    dest.SetPixel((int)i, (int)j, Color.PutAonB(c, back));
                    break;

                case Glass.Anaglyph:
                    Color anaglyph = Left ?
                                     Graph3dDraw.AnaglyphLeft(c, (int)j, Graph.bitmap, (int)i) :
                                     Graph3dDraw.AnaglyphRight(c, (int)j, Graph.bitmap, (int)i);
                    dest.SetPixel((int)i, (int)j, anaglyph);
                    break;

                case Glass.TV3D:
                    if (!Left)
                    {
                        if (i < Graph.width)
                        {
                            back = Graph.getpixel((int)(i / 2), (int)j);
                            dest.SetPixel((int)(i / 2), (int)j, Color.PutAonB(c, back));
                        }
                    }
                    else
                    {
                        if (i >= 0)
                        {
                            back = Graph.getpixel((int)((i + Graph.width) / 2), (int)j);
                            dest.SetPixel((int)((i + Graph.width) / 2), (int)j, Color.PutAonB(c, back));
                        }
                    }
                    break;
                }
            }
        }
Esempio n. 11
0
        public static void rectangle(int x0, int y0, int z0, int Xscale, int Yscale, Surface s)
        {
            bool temp = Graph.imediateDrawing;

            Graph.imediateDrawing = false;
            switch (s)
            {
            case Surface.XY:
                Graph3dDraw.rectangle(x0, y0, z0, Xscale, 90, 0, Yscale, 90, -90); break;

            case Surface.XZ:
                Graph3dDraw.rectangle(x0, y0, z0, Xscale, 90, 0, Yscale, 0, -90); break;

            case Surface.YZ:
                Graph3dDraw.rectangle(x0, y0, z0, Xscale, 0, -90, Yscale, 90, -90); break;
            }
            Graph.imediateDrawing = temp;
            if (Graph.imediateDrawing)
            {
                Graph.delay(0);
            }
        }
Esempio n. 12
0
        public Bitmap Convert3DToAnaglyph(bool LeftEyeIsLeft)
        {
            Bitmap result = new Bitmap(Width / 2, Height);

            if (LeftEyeIsLeft)
            {
                for (int i = 0; i < Width / 2; i++)
                {
                    for (int j = 0; j < Height; j++)
                    {
                        Color c = GetPixel(i, j);
                        c = Graph3dDraw.AnaglyphLeft(c, j, result, i);
                        result.SetPixel(i, j, c);

                        c = GetPixel(i + Width / 2, j);
                        c = Graph3dDraw.AnaglyphRight(c, j, result, i);
                        result.SetPixel(i, j, c);
                    }
                }
            }
            else
            {
                for (int i = 0; i < Width / 2; i++)
                {
                    for (int j = 0; j < Height; j++)
                    {
                        Color c = GetPixel(i, j);
                        c = Graph3dDraw.AnaglyphRight(c, j, result, i);
                        result.SetPixel(i, j, c);

                        c = GetPixel(i + Width / 2, j);
                        c = Graph3dDraw.AnaglyphLeft(c, j, result, i);
                        result.SetPixel(i, j, c);
                    }
                }
            }

            return(result);
        }