概要
cscの作法、調べてみた。
wpf3d、やってみた。
写真
サンプルコード
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
class Main3d: Window {
public Main3d() {
var pos = new Point3DCollection();
pos.Add(new Point3D(1, 0, 0));
pos.Add(new Point3D(0, 1, 0));
pos.Add(new Point3D(0, 0, 0));
var model = new GeometryModel3D();
model.Geometry = new MeshGeometry3D() {
Positions = pos
};
model.Material = new DiffuseMaterial(Brushes.LightGreen);
var light = new DirectionalLight();
var cam = new PerspectiveCamera();
cam.Position = new Point3D(0, 0, 5);
var vp3d = new Viewport3D();
vp3d.Camera = cam;
vp3d.Children.Add(new ModelVisual3D() {
Content = model
});
vp3d.Children.Add(new ModelVisual3D() {
Content = light
});
Width = 400;
Height = 400;
Content = vp3d;
}
[STAThread]
static void Main() {
var wnd = new Main3d();
wnd.ShowDialog();
}
}
以上。