示例#1
0
        public void updateDragInformation()
        {
            // Find the mouse point in local space
            MPoint  localMousePoint     = new MPoint();
            MVector localMouseDirection = new MVector();

            try
            {
                mouseRay(localMousePoint, localMouseDirection);
            }
            catch (System.Exception)
            {
                return;
            }

            // Find the intersection of the mouse point with the
            // manip plane
            MPoint mouseIntersectionWithManipPlane = new MPoint();

            if (!plane.intersect(localMousePoint, localMouseDirection, ref mouseIntersectionWithManipPlane))
            {
                return;
            }

            mousePointGlName.assign(mouseIntersectionWithManipPlane);

            uint active = 0;

            try
            {
                glActiveName(ref active);
            }
            catch (System.Exception)
            {
                return;
            }

            if (active == lineName && active != 0)
            {
                lineMath line = new lineMath();
                // Find a vector on the plane
                MPoint  a   = lineGeometry.topPoint();
                MPoint  b   = lineGeometry.bottomPoint();
                MVector vab = a.minus(b);
                // Define line with a point and a vector on the plane
                line.setLine(a, vab);
                MPoint cpt = new MPoint();
                // Find the closest point so that we can get the
                // delta change of the mouse in local space
                if (line.closestPoint(mousePointGlName, ref cpt))
                {
                    mousePointGlName.x -= cpt.x;
                    mousePointGlName.y -= cpt.y;
                    mousePointGlName.z -= cpt.z;
                }
            }
        }
示例#2
0
		public void updateDragInformation()
		{
			// Find the mouse point in local space
			MPoint localMousePoint = new MPoint();
			MVector localMouseDirection = new MVector();
			try
			{
				mouseRay(localMousePoint, localMouseDirection);
			}
			catch (System.Exception)
			{
				return;
			}

			// Find the intersection of the mouse point with the
			// manip plane
			MPoint mouseIntersectionWithManipPlane = new MPoint();
			if (!plane.intersect(localMousePoint, localMouseDirection, ref mouseIntersectionWithManipPlane))
				return;

			mousePointGlName.assign(mouseIntersectionWithManipPlane);

			uint active = 0;
			try
			{
				glActiveName(ref active);
			}
			catch (System.Exception)
			{
				return;
			}

			if (active == lineName && active != 0)
			{
				lineMath line = new lineMath();

				//
				bool rightLine = true;
				if (affectTranslate)
					rightLine = false;

				// Find a vector on the plane
				MPoint a = lineGeometry.topPoint(rightLine);
				MPoint b = lineGeometry.bottomPoint(rightLine);

				MVector vab = a.minus(b);
				// Define line with a point and a vector on the plane
				line.setLine(a, vab);
				MPoint cpt = new MPoint();
				// Find the closest point so that we can get the
				// delta change of the mouse in local space
				if (line.closestPoint(mousePointGlName, ref cpt))
				{
					mousePointGlName.x -= cpt.x;
					mousePointGlName.y -= cpt.y;
					mousePointGlName.z -= cpt.z;
				}
			}
		}