Exemple #1
0
        private void SetupDXEngine()
        {
            _dxViewportView = new DXViewportView();

            // To use render to bitmap on a server, it is possible to use software rendering with the following line:
            //_dxViewportView.GraphicsProfiles = new GraphicsProfile[] { GraphicsProfile.HighQualitySoftwareRendering };

            // Because the DXViewportView is not shown in the UI, we need to manually sets its size (without this the current version will not be initialized correctly - this will be improved in the future)
            _dxViewportView.Width  = 128;
            _dxViewportView.Height = 128;

            // By default the BackgroundColor is set to transparent.
            // We set that to white so that the saved bitmap has a white background.
            _dxViewportView.BackgroundColor = Colors.White;

            _viewport3D = new Viewport3D();

            _camera = new TargetPositionCamera()
            {
                //Heading = HeadingSlider.Value,
                Attitude         = -15,
                Distance         = 300,
                TargetPosition   = new Point3D(0, 10, 0),
                ShowCameraLight  = ShowCameraLightType.Always,
                TargetViewport3D = _viewport3D
            };

            UpdateCamera();

            _dxViewportView.Viewport3D = _viewport3D;


            // Initialize the scene with creating DirectX device and required resources
            try
            {
                _dxViewportView.InitializeScene();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error initializing DXEngine:\r\n" + ex.Message);

                RenderButton.IsEnabled = false;
            }

            _isFirstRender = true;
        }
Exemple #2
0
        private void SetupDXEngine()
        {
            _dxViewportView = new DXViewportView();

            // For this sample we force software rendering (for example to be used on server or other computer without graphics card)
            if (ForceSoftwareRendering)
            {
                _dxViewportView.GraphicsProfiles = new GraphicsProfile[] { GraphicsProfile.HighQualitySoftwareRendering }
            }
            ;

            // Because the DXViewportView is not shown in the UI, we need to manually sets its size (without this the current version will not be initialized correctly - this will be improved in the future)
            _dxViewportView.Width  = 128;
            _dxViewportView.Height = 128;

            _viewport3D = new Viewport3D();

            _camera = new TargetPositionCamera()
            {
                //Heading = HeadingSlider.Value,
                Attitude         = -20,
                Distance         = 200,
                ShowCameraLight  = ShowCameraLightType.Always,
                TargetViewport3D = _viewport3D
            };

            UpdateCamera();

            _dxViewportView.Viewport3D = _viewport3D;


            // Initialize the scene with creating DirectX device and required resources
            try
            {
                _dxViewportView.InitializeScene();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error initializing DXEngine:\r\n" + ex.Message);

                RenderButton.IsEnabled = false;
            }

            _isFirstRender = true;
        }