Ejemplo n.º 1
0
        public override void doPress(MEvent eventArg)
        {
            base.doPress(eventArg);

            // If we are not in selecting mode (i.e. an object has been selected)
            // then set up for the translation.
            if (!_isSelecting())
            {
                eventArg.getPosition(ref startPos_x, ref startPos_y);

                view = M3dView.active3dView;

                MDagPath  camera   = view.Camera;
                MFnCamera fnCamera = new MFnCamera(camera);
                MVector   upDir    = fnCamera.upDirection(MSpace.Space.kWorld);
                MVector   rightDir = fnCamera.rightDirection(MSpace.Space.kWorld);

                // Determine the camera used in the current view
                if (fnCamera.isOrtho)
                {
                    if (upDir.isEquivalent(MVector.zNegAxis, 1e-3))
                    {
                        currWin = 0;                         // TOP
                    }
                    else if (rightDir.isEquivalent(MVector.xAxis, 1e-3))
                    {
                        currWin = 1;                         // FRONT
                    }
                    else
                    {
                        currWin = 2;                         // SIDE
                    }
                }
                else
                {
                    currWin = 3;                     // PERSP
                    MGlobal.displayWarning("moveTool only works in top, front and side views");
                }

                // Create an instance of the move tool command.
                cmd = _newToolCommand() as moveCmd;
                cmd.setVector(0.0, 0.0, 0.0);
            }
        }
Ejemplo n.º 2
0
 public override void doRelease(MEvent eventArg)
 {
     base.doRelease(eventArg);
     if (!_isSelecting())
     {
         eventArg.getPosition(ref endPos_x, ref endPos_y);
         // Delete the move command if we have moved less then 2 pixels
         // otherwise call finalize to set up the journal and add the command to the undo queue.
         if (Math.Abs(startPos_x - endPos_x) < 2 && Math.Abs(startPos_y - endPos_y) < 2)
         {
             cmd = null;
             view.refresh(true, false);
         }
         else
         {
             cmd.finalize();
             view.refresh(true, false);
         }
     }
 }
Ejemplo n.º 3
0
		public override void doRelease(MEvent eventArg)
		{
			base.doRelease (eventArg) ;
			if ( !_isSelecting () ) {
				eventArg.getPosition (ref endPos_x, ref endPos_y) ;
				// Delete the move command if we have moved less then 2 pixels
				// otherwise call finalize to set up the journal and add the command to the undo queue.
				if ( Math.Abs (startPos_x - endPos_x) < 2 && Math.Abs (startPos_y - endPos_y) < 2 ) {
					cmd =null ;
					view.refresh (true,false) ;
				} else {
					cmd.finalize () ;
					view.refresh (true,false) ;
				}
			}
		}
Ejemplo n.º 4
0
		public override void doPress(MEvent eventArg)
		{
			base.doPress (eventArg) ;
			
			// If we are not in selecting mode (i.e. an object has been selected)
			// then set up for the translation.
			if ( !_isSelecting () ) {
				eventArg.getPosition (ref startPos_x, ref startPos_y) ;

				view = M3dView.active3dView;

				MDagPath camera = view.Camera ;
				MFnCamera fnCamera =new MFnCamera (camera) ;
				MVector upDir =fnCamera.upDirection (MSpace.Space.kWorld) ;
				MVector rightDir =fnCamera.rightDirection (MSpace.Space.kWorld) ;

				// Determine the camera used in the current view
				if ( fnCamera.isOrtho ) {
					if ( upDir.isEquivalent (MVector.zNegAxis, 1e-3) )
						currWin =0 ; // TOP
					else if ( rightDir.isEquivalent (MVector.xAxis, 1e-3) )
						currWin =1 ; // FRONT
					else
						currWin =2 ; // SIDE
				} else {
					currWin =3 ; // PERSP
					MGlobal.displayWarning ("moveTool only works in top, front and side views") ;
				}

				// Create an instance of the move tool command.
				cmd = _newToolCommand () as moveCmd;
				cmd.setVector (0.0, 0.0, 0.0) ;
			}
		}