예제 #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)
                {
                    ;
                }
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
        }