コード例 #1
0
 //============================================================
 // <T>处理鼠标落下。</T>
 //============================================================
 public void ProcessMouseDown(int mouseButton, int x, int y)
 {
     RMouse.ProcessDown(mouseButton);
     RMouse.LocationDown.Set(x, y);
     // 左键按下
     if (mouseButton == EMouseButton.Left)
     {
         // 存储相机
         _region.Camera.Store();
         // 点击测试
         if (RKeybord.IsPressedKey(EKeyCode.D1) || RKeybord.IsPressedKey(EKeyCode.D2) || RKeybord.IsPressedKey(EKeyCode.D3) ||
             RKeybord.IsPressedKey(EKeyCode.D4) || RKeybord.IsPressedKey(EKeyCode.D5) || RKeybord.IsPressedKey(EKeyCode.D6) ||
             RKeybord.IsPressedKey(EKeyCode.D7) || RKeybord.IsPressedKey(EKeyCode.D8) || RKeybord.IsPressedKey(EKeyCode.D9))
         {
         }
         else
         {
             int renderableId           = _techniqueDesign.HitTest(_region, x, y);
             FDxDesignGeometry geometry = null;
             if (renderableId > 0)
             {
                 geometry = _region.Renderables.FindById(renderableId) as FDxDesignGeometry;
             }
             DoGeometryFocus(geometry);
         }
         // 过滤所有选择对象
         _region.Renderables.FilterSelected(_renderablesSelected, false);
         _renderablesSelected.Store();
     }
 }
コード例 #2
0
 //============================================================
 public void ProcessMouseUp(int mouseButton, int x, int y)
 {
     RMouse.ProcessUp(mouseButton);
     _region.Renderables.SetSelected(true, false);
 }
コード例 #3
0
 //============================================================
 public void ProcessMouseMove(int mouseButton, int x, int y)
 {
     if (RMouse.IsPressed())
     {
         int cx = x - RMouse.LocationDown.X;
         int cy = y - RMouse.LocationDown.Y;
         // 鼠标左键点击
         if (RMouse.IsPressedKey(EMouseButton.Left))
         {
             // 相机旋转
             if (_commandCd == EDxDesignCommand.CameraRotation)
             {
                 _region.Camera.Restore();
                 _region.Camera.DoYaw(-cx * 0.005f);
                 _region.Camera.DoPitch(-cy * 0.005f);
                 _region.Camera.Update();
             }
             // 检查对象有选中的时候,进行操作
             if (!_renderablesSelected.IsEmpty())
             {
                 float delta = cx + cy;
                 // 移动
                 if (_commandCd == EDxDesignCommand.MatrixTranslationX)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendTranslation(delta, 0, 0);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixTranslationY)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendTranslation(0, -delta, 0);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixTranslationZ)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendTranslation(0, 0, delta);
                 }
                 // 旋转
                 if (_commandCd == EDxDesignCommand.MatrixRotationX)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendRotation(delta * 0.05f, 0, 0);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixRotationY)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendRotation(0, -delta * 0.05f, 0);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixRotationZ)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendRotation(0, 0, delta * 0.05f);
                 }
                 // 缩放
                 float scaleRate = 1.0f + delta * 0.001f;
                 if (_commandCd == EDxDesignCommand.MatrixScaleAll)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendScale(scaleRate, scaleRate, scaleRate);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixScaleX)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendScale(scaleRate, 1, 1);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixScaleY)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendScale(1, scaleRate, 1);
                 }
                 else if (_commandCd == EDxDesignCommand.MatrixScaleZ)
                 {
                     _renderablesSelected.Restore();
                     _renderablesSelected.AppendScale(1, 1, scaleRate);
                 }
                 // 更新
                 _renderablesSelected.Update();
                 _spatialTranslate.Matrix.Assign(_focusGeometry.Matrix);
                 _spatialTranslate.Update();
                 _spatialRotation.Matrix.Assign(_focusGeometry.Matrix);
                 _spatialRotation.Update();
                 _spatialScale.Matrix.Assign(_focusGeometry.Matrix);
                 _spatialScale.Update();
             }
         }
     }
 }