Exemple #1
0
        public override int Proc(IntPtr hwnd, int msg, int point, int flags, IIPoint2 m)
        {
            Debug.Print("viewport point: " + m.X + ", " + m.Y);
            switch (msg)
            {
            case 0:     // MOUSE_ABORT see .\maxsdk\include\mouseman.h for all possible values
            {
                IGlobal      global = Autodesk.Max.GlobalInterface.Instance;
                IInterface14 ip     = global.COREInterface14;
                ip.PopCommandMode();
                Debug.Print("mouse callback aborted");
            }
            break;

            case 1:     // MOUSE_POINT see .\maxsdk\include\mouseman.h for all possible values
            {
                if (point == 0)
                {
                    IGlobal      global = Autodesk.Max.GlobalInterface.Instance;
                    IInterface14 ip     = global.COREInterface14;
                    IViewExp     vp     = ip.ActiveViewExp;
                    IPoint3      pt     = vp.SnapPoint(m, m, null, SnapFlags.InPlane);
                    ip.PopCommandMode();
                    Debug.Print("3d point (in plane): " + pt.X + ", " + pt.Y + ", " + pt.Z);
                }
                // else if ... other points if you have more than one...
            }
            break;

            default:
                break;
            }
            return(1);
        }
      /// <summary>
      /// Initializes a new instance of the SetViewCameraCommand class.
      /// </summary>
      /// <param name="cameraNode">The Camera node to use.</param>
      /// <param name="viewport">The viewport to set the camera for.</param>
      public SetViewCameraCommand(IMaxNode cameraNode, IViewExp viewport)
      {
         Throw.IfNull(cameraNode, "cameraNode");
         Throw.IfNull(viewport, "viewport");

         this.cameraNode = cameraNode;
         this.viewport = viewport;
      }