コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics3DForm graphics       = new Graphics3DForm(this, e.Graphics);
            double         angleHorizRad  = _angleHoriz * Math.PI / 180.0;
            double         angleVertRad   = _angleVert * Math.PI / 180.0;
            double         cameraDistance = 10000.0;

            graphics.CameraPosition = new Vector3D(
                cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad)
                , cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad)
                , cameraDistance * Math.Sin(angleVertRad));
            // set camera target
            graphics.Target = Vector3D.Zero;
            // set viewport (not actually needed)
            graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
            // show images
            graphics.ShowTextures = true;
            if (null != _drawingContainer)
            {
                try
                {
                    _drawingContainer.Draw(this, graphics);
                }
                catch (Exception ex)
                {
                    e.Graphics.DrawString(ex.Message
                                          , new Font("Arial", 12)
                                          , new SolidBrush(Color.Red)
                                          , new Point(0, 0)
                                          , StringFormat.GenericDefault);
                    _log.Error(ex.Message);
                }
            }
            graphics.Flush();

            // draw toolbar
            if (ShowToolBar)
            {
                DrawToolBar(e.Graphics);
            }
        }
コード例 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics3DForm graphics = new Graphics3DForm(this, e.Graphics);
            double angleHorizRad = _angleHoriz * Math.PI / 180.0;
            double angleVertRad = _angleVert * Math.PI / 180.0;
            double cameraDistance = 10000.0;
            graphics.CameraPosition = new Vector3D(
                cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad)
                , cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad)
                , cameraDistance * Math.Sin(angleVertRad));
            // set camera target
            graphics.Target = Vector3D.Zero;
            // set viewport (not actually needed)
            graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
            // show images
            graphics.ShowTextures = true;
            if (null != _drawingContainer)
            {
                try
                {
                    _drawingContainer.Draw(this, graphics);
                }
                catch (Exception ex)
                {
                    e.Graphics.DrawString(ex.Message
                        , new Font("Arial", 12)
                        , new SolidBrush(Color.Red)
                        , new Point(0, 0)
                        , StringFormat.GenericDefault);
                    _log.Error(ex.Message);
                }
            }
            graphics.Flush();

            // draw toolbar
            if (ShowToolBar)
                DrawToolBar(e.Graphics);
        }