c#如何获得ModelVisual3D中MeshGeometry3D对象

原文: c#如何获得ModelVisual3D中MeshGeometry3D对象

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37591671/article/details/70246442

目的是通过改变ModelVisual3D对象的顶点位置来实现WPF中3D对象的移动。

由于3D对象中包含许多的ModelVisual3D,所以不可能通过为每个ModelVisual3D中MeshGeometry3D命名来获得顶点(即Positions),想法是先获得包含所有ModelVisual3D对象的容器,然后通过循环得到所有ModelVisual3D对象,之后再获得MeshGeometry3D对象Positions点。


        ModelVisual3D model = (ModelVisual3D)RootGeometryContainer.Children[0];
      GeometryModel3D gm3D = model.Content as GeometryModel3D;
      MeshGeometry3D mesh = gm3D.Geometry as MeshGeometry3D;
      Point3DCollection point = new Point3DCollection();
      point = mesh.Positions;
      List<Point3D> list = new List<Point3D>();
      list.AddRange(point);

本例只获得的第一个对象,取得了第一个对象的Positions


猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/9704916.html