概要
cscの作法、調べてみた。
wpf3d、やってみた。
練習問題やってみた。
練習問題
「using System;」だけで、wpf3dを書け。
写真
サンプルコード
using System;
class Main3d: System.Windows.Window {
public Main3d() {
var v0 = new System.Windows.Media.Media3D.Point3D(1, 0, 0);
var v1 = new System.Windows.Media.Media3D.Point3D(0, 1, 0);
var v2 = new System.Windows.Media.Media3D.Point3D(0, 0, 0);
var pos = new System.Windows.Media.Media3D.Point3DCollection();
pos.Add(v0);
pos.Add(v1);
pos.Add(v2);
var mesh = new System.Windows.Media.Media3D.MeshGeometry3D();
mesh.Positions = pos;
var mat = new System.Windows.Media.Media3D.DiffuseMaterial(System.Windows.Media.Brushes.LightGreen);
var model = new System.Windows.Media.Media3D.GeometryModel3D();
model.Geometry = mesh;
model.Material = mat;
var light = new System.Windows.Media.Media3D.DirectionalLight();
var cam = new System.Windows.Media.Media3D.PerspectiveCamera();
cam.Position = new System.Windows.Media.Media3D.Point3D(0, 0, 5);
var cmodel = new System.Windows.Media.Media3D.ModelVisual3D();
cmodel.Content = model;
var clight = new System.Windows.Media.Media3D.ModelVisual3D();
clight.Content = light;
var vp3d = new System.Windows.Controls.Viewport3D();
vp3d.Camera = cam;
vp3d.Children.Add(cmodel);
vp3d.Children.Add(clight);
Title = "Hello 3D!";
Width = 400;
Height = 400;
Content = vp3d;
}
[STAThread]
static void Main() {
var wnd = new Main3d();
wnd.ShowDialog();
}
}
以上。