WPF如何通过按键事件构造三维图形?还有关于3Dtools~~ 我希望能在程序运行过程中通过输入三维坐标添加个球~~不知道该如何实现我几乎所有的图形构造都是在XAML里完成的~~不知道应该怎么关联输入的坐标以及按钮的触发还有就是关于3DTOOLS里的screenspaceline功能~~我看例子程序里通过选一个选项就能显示实体或者框架但是不知道该怎么做还是代码部分求助啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问错地方了,这里人都不研究WPF 你可以上msdn中文论坛上问问:http://social.microsoft.com/Forums/zh-CN/wpfzhchs/threads另外在silverlight版也可以问问看。 后台写3D和摁下button时旋转,比较粗糙,如果是球需要循环用三角拼起来。 public partial class MainWindow : Window { Viewport3D viewport = new Viewport3D(); Model3DGroup modelgroup = new Model3DGroup(); GeometryModel3D geomodel = new GeometryModel3D(); ModelVisual3D modelvisual = new ModelVisual3D(); MeshGeometry3D mgeo = new MeshGeometry3D(); MatrixTransform3D mt3d = new MatrixTransform3D(); public MainWindow() { InitializeComponent(); viewport.Camera = new PerspectiveCamera(new Point3D(0, 0, 3), new Vector3D(0, 0, -1), new Vector3D(1, 1, -1), 45); modelgroup.Children.Add(new DirectionalLight(Colors.White, new Vector3D(-1, -1, -1))); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Normals.Add(new Vector3D(0, 0, 1)); mgeo.Positions.Add(new Point3D(-0.5, -0.5, 0.5)); mgeo.Positions.Add(new Point3D(0.5, -0.5, 0.5)); mgeo.Positions.Add(new Point3D(0.5, 0.5, 0.5)); mgeo.Positions.Add(new Point3D(0.5, 0.5, 0.5)); mgeo.Positions.Add(new Point3D(-0.5, 0.5, 0.5)); mgeo.Positions.Add(new Point3D(-0.5, -0.5, 0.5)); mgeo.TextureCoordinates.Add(new Point(0, 0)); mgeo.TextureCoordinates.Add(new Point(1, 0)); mgeo.TextureCoordinates.Add(new Point(1, 1)); mgeo.TextureCoordinates.Add(new Point(1, 1)); mgeo.TextureCoordinates.Add(new Point(0, 1)); mgeo.TextureCoordinates.Add(new Point(0, 0)); mgeo.TriangleIndices.Add(0); mgeo.TriangleIndices.Add(1); mgeo.TriangleIndices.Add(2); mgeo.TriangleIndices.Add(3); mgeo.TriangleIndices.Add(4); mgeo.TriangleIndices.Add(5); geomodel.Geometry = mgeo; geomodel.Material = new DiffuseMaterial(Brushes.Blue); geomodel.Transform = mt3d; modelgroup.Children.Add(geomodel); modelvisual.Content = modelgroup; viewport.Children.Add(modelvisual); grid1.Children.Add(viewport); } double i; private void button1_Click(object sender, RoutedEventArgs e) { i+=0.01; Matrix3D matrix = new Matrix3D(); matrix.M11 = Math.Sin(i); matrix.M12 = Math.Cos(i); matrix.M13 = -Math.Sin(i); matrix.M21 = -Math.Cos(i); matrix.M22 = Math.Sin(i); matrix.M23 = Math.Cos(i); matrix.M31 = Math.Sin(i); matrix.M32 = -Math.Cos(i); matrix.M33 = Math.Cos(i); mt3d.Matrix = matrix; } } Report中表达式字段类型转换 怎么制作类似vs.net的工具箱界面 求递归算法 我想问一下在C#上如何像VB.NET一样用chr(10)来获取字码 关于vb应用程序与C#的性能差别的问题. CSDN高校俱乐部线上编程挑战赛,奖品多多~ 我想在web form中的datagrid中删除一条记录,如何在删除前进行确认? 哪位大侠有c#.net的入门电子书?小弟我给50分! 再线,当时给分,一个简单的问题 一个关于datagrid的问题! "dataGridView与textbox同时绑定一张table相同字段"有关问题 反射问题
{
Viewport3D viewport = new Viewport3D();
Model3DGroup modelgroup = new Model3DGroup();
GeometryModel3D geomodel = new GeometryModel3D();
ModelVisual3D modelvisual = new ModelVisual3D();
MeshGeometry3D mgeo = new MeshGeometry3D();
MatrixTransform3D mt3d = new MatrixTransform3D();
public MainWindow()
{
InitializeComponent();
viewport.Camera = new PerspectiveCamera(new Point3D(0, 0, 3), new Vector3D(0, 0, -1), new Vector3D(1, 1, -1), 45);
modelgroup.Children.Add(new DirectionalLight(Colors.White, new Vector3D(-1, -1, -1)));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Normals.Add(new Vector3D(0, 0, 1));
mgeo.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
mgeo.Positions.Add(new Point3D(0.5, -0.5, 0.5));
mgeo.Positions.Add(new Point3D(0.5, 0.5, 0.5));
mgeo.Positions.Add(new Point3D(0.5, 0.5, 0.5));
mgeo.Positions.Add(new Point3D(-0.5, 0.5, 0.5));
mgeo.Positions.Add(new Point3D(-0.5, -0.5, 0.5));
mgeo.TextureCoordinates.Add(new Point(0, 0));
mgeo.TextureCoordinates.Add(new Point(1, 0));
mgeo.TextureCoordinates.Add(new Point(1, 1));
mgeo.TextureCoordinates.Add(new Point(1, 1));
mgeo.TextureCoordinates.Add(new Point(0, 1));
mgeo.TextureCoordinates.Add(new Point(0, 0));
mgeo.TriangleIndices.Add(0);
mgeo.TriangleIndices.Add(1);
mgeo.TriangleIndices.Add(2);
mgeo.TriangleIndices.Add(3);
mgeo.TriangleIndices.Add(4);
mgeo.TriangleIndices.Add(5);
geomodel.Geometry = mgeo;
geomodel.Material = new DiffuseMaterial(Brushes.Blue);
geomodel.Transform = mt3d;
modelgroup.Children.Add(geomodel);
modelvisual.Content = modelgroup;
viewport.Children.Add(modelvisual);
grid1.Children.Add(viewport);
}
double i;
private void button1_Click(object sender, RoutedEventArgs e)
{
i+=0.01;
Matrix3D matrix = new Matrix3D();
matrix.M11 = Math.Sin(i);
matrix.M12 = Math.Cos(i);
matrix.M13 = -Math.Sin(i);
matrix.M21 = -Math.Cos(i);
matrix.M22 = Math.Sin(i);
matrix.M23 = Math.Cos(i);
matrix.M31 = Math.Sin(i);
matrix.M32 = -Math.Cos(i);
matrix.M33 = Math.Cos(i);
mt3d.Matrix = matrix;
}
}