Exemple #1
0
        private void ShowModelScalar()
        {
            HideModelMover();
            HideModelRotator();

            if (_selectedVisual3D == null || _standardTransform3D == null)
            {
                return;
            }


            EnsureModelScalar();

            _modelScalar.Position = _standardTransform3D.GetTranslateVector3D().ToPoint3D();

            // If the 3D scene would not be shown yet, we would need to refresh the camera
            //Camera1.Refresh();

            // We need to set the size of the model mover's axes to an appropriate size so that it will look big enough
            // regardless of how far away the selected model is.
            // This can be done with calculating how big a 80 x 80 rectangle (in screen coordinates) would be in 3D space at the specified distance:
            double lookDirectionDistance = (_modelScalar.Position - Camera1.GetCameraPosition()).Length;
            var    worldSize             = Ab3d.Utilities.CameraUtils.GetPerspectiveWorldSize(new Size(80, 80), lookDirectionDistance, Camera1.FieldOfView, new Size(MainViewport.ActualWidth, MainViewport.ActualHeight));


            _modelScalar.AxisLength     = (worldSize.Width + worldSize.Height) / 2; // average the width and height
            _modelScalar.InnerBoxWidth  = _modelScalar.AxisLength * 0.06;
            _modelScalar.OuterBoxWidth  = _modelScalar.InnerBoxWidth * 3;
            _modelScalar.CenterBoxWidth = _modelScalar.InnerBoxWidth * 5;

            if (!OverlayViewport.Children.Contains(_modelScalar))
            {
                OverlayViewport.Children.Add(_modelScalar);
            }
        }