Exemplo n.º 1
0
        private void UpdateDetailVisual()
        {
            const double IDEALRATIO = .4d;

            if (_detailVisual == null)
            {
                return;
            }

            if (pnlDetail.Item != null && pnlDetail.Model != null)
            {
                _detailVisual.Content             = UtilityCore.Clone(pnlDetail.Model);
                _detailRotationInitial.Quaternion = pnlDetail.ModelRotate;

                Rect3D bounds = _detailVisual.Content.Bounds;

                // Center it so that it's at 0,0,0 in model coords
                _detailTranslate.OffsetX = -(bounds.X + (bounds.SizeX / 2d));
                _detailTranslate.OffsetY = -(bounds.Y + (bounds.SizeY / 2d));
                _detailTranslate.OffsetZ = -(bounds.Z + (bounds.SizeZ / 2d));

                // Scale it to the ideal size on screen
                double size = bounds.DiagonalLength();

                double scale = IDEALRATIO / (size / _cameraLength);

                _detailScale.ScaleX = scale;
                _detailScale.ScaleY = scale;
                _detailScale.ScaleZ = scale;
            }
            else
            {
                _detailVisual.Content = GetBlankModel();
            }
        }