C#で地球を表示する(VTKのEarthSourceによる方法)
C#でVTKのvtkEarthSourceクラスによって地球を表示させる.
ActiViz
ActiVizは,3Dコンピュータグラフィックスの可視化ライブラリVTK(The Visualization ToolKit)のC#ラッパである.NuGetからインストールできる.簡単な解説は以下のページを参照.
C#で3Dモデル表示(VTKのC#ラッパActiVizによる方法) - whoopsidaisies's diary
RenderWindowControl
NuGetからActiVizをインストールし,RenderWindowControlをフォームに追加する.
vtkEarthSource
VTKにはvtkEarthSourceという,地球が表示されるオブジェクトがあるので使う.ソースコードは以下のようになる.
using (var earth = new Kitware.VTK.vtkEarthSource()) using (var mapper = new Kitware.VTK.vtkCompositePolyDataMapper()) using (var actor = new Kitware.VTK.vtkActor()) { mapper.SetInputConnection(earth.GetOutputPort()); actor.SetMapper(mapper); renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer().AddActor(actor); }
実行すると以下のように地球が表示される.ドラッグで視点変更が出来る.