0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その596

Posted at

概要

cscの作法、調べてみた。
wpf3d、やってみた。
練習問題やってみた。

練習問題

「using System;」だけで、wpf3dを書け。

写真

image.png

サンプルコード

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();
	}
}



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?