HelixToolkit使用总结:
问题点:
3d光源
相机
网格信息
1、配置HelixViewPort3d基本参数
2、配置相机参数和相机位置:HelixViewPort3D.DefaultCamera
设置相机的放置方向和观看位置
<hv:HelixViewport3D.DefaultCamera>
<PerspectiveCamera LookDirection="-587.475,-330.619,-229.365" Position="587.475,330.619,256.278" UpDirection="-0.248,-0.139,0.959" FieldOfView="45" NearPlaneDistance="0.1"/>
</hv:HelixViewport3D.DefaultCamera>
3、配置光线:hv:SunLight
4、配置坐标网格 hv:GridLinesVisual3D
<hv:GridLinesVisual3D Width="10000" Length="10000" MinorDistance="50" MajorDistance="50" Thickness="2" Fill="White"/>
5、配置模型的属性ModelVisual3D两个属性
1)、材质和外观
GeometryModel3D
1、Material
2、Geometry
GeometryModel3D model1 = d.Children[i] as GeometryModel3D;
var materialGroup = new MaterialGroup();
DiffuseMaterial diffMat = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));
materialGroup.Children.Add(diffMat);
model1.Material = materialGroup;
model1.BackMaterial = materialGroup;
对模型位置修改:
1)模型内位置的修改
对象的平移:
GeometryModel3D model1 = d.Children[0] as GeometryModel3D;
MeshGeometry3D mesh = model1.Geometry as MeshGeometry3D;
var res = mesh.Positions;
for (int i = 0; i < res.Count; i++)
{
var sp = mesh.Positions[i];
mesh.Positions[i] = new Point3D() { X = sp.X, Y =sp.Y, Z =sp.Z+ 10 };
}
model1.Geometry = mesh;
UI界面更新外观和位置:
<GeometryModel3D>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 2,0,0 2,2,0 0,2,0"
TriangleIndices="0,1,2 0,2,3">
</MeshGeometry3D>
</GeometryModel3D.Geometry>
</GeometryModel3D>
2)整体模型位置的修改
通过对前台代码的修改即可。或者是使用mvvm进行绑定修改
效果图如下:
实现对模型的运动控制 文章来源:https://www.toymoban.com/news/detail-497421.html
源代码如下:文章来源地址https://www.toymoban.com/news/detail-497421.html
到了这里,关于HelixToolkit使用教程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!