OSG(OpenSceneGraph)的.NET封装1-Winform和WPF中显示OSG

Winform中显示OSG

添加控件,并在窗体Load的时候添加坐标轴和背景,运行多线程渲染。

   public partial class ZfOsgViewForm : Form
    {
        private ZfOsgViewCtrl _zfOsgViewCtrl = null;
        public ZfOsgViewForm()
        {
            InitializeComponent();

            _zfOsgViewCtrl = new ZfOsgViewCtrl();
            _zfOsgViewCtrl.Dock = DockStyle.Fill;
            this.Controls.Add(_zfOsgViewCtrl);
        }

        private void ZfOsgViewForm_Load(object sender, EventArgs e)
        {
            _zfOsgViewCtrl.AddAxes();
            _zfOsgViewCtrl.AddBackground();
            _zfOsgViewCtrl.OsgObj.RunOSG();
        }
    }

ZfOsgEarthViewCtrl继承自ZfOsgViewCtrl,调用代码大致相同。

效果:

OSG(OpenSceneGraph)的.NET封装1-Winform和WPF中显示OSG_第1张图片

 

下面osgEarth的效果:

OSG(OpenSceneGraph)的.NET封装1-Winform和WPF中显示OSG_第2张图片

WPF中显示OSG

xaml中添加


    
        
    

cs中添加

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.ContentRendered += OnContentRendered;
        }

        private void OnContentRendered(object sender, EventArgs e)
        {
            OsgViewCtrl.AddBackground();
            OsgViewCtrl.AddAxes();
            OsgViewCtrl.OsgObj.RunOSG();
        }
    }

效果

OSG(OpenSceneGraph)的.NET封装1-Winform和WPF中显示OSG_第3张图片

你可能感兴趣的:(OSG)