我想要点击一个实体的面,并出现其正常的vector.It将帮助我设置一个旋转轴。
我遵循示例中的model1_SelectionChanged :EyeshotDemo,我可以知道我click.But哪个face,我不知道下一步我能做什么。
发布于 2019-05-14 20:25:08
您应该使用viewportLayout.FindClosestTriangle进行面部定位。
这将为您提供一个构成面的三角形(通常是最接近鼠标的三角形)。
然后从那里创建一个平面,指定该三角形的3个顶点,该顶点的法线方向将与三角形法线相匹配。
下面是一个完整的工作代码:
// create a basic cube solid
var cube = Solid.CreateBox(10, 10, 10);
// add to the viewport (vp is the ViewportLayout control)
vp.Entities.Add(cube);
// in the vp (ViewportLayout control) mouse click
private void vp_MouseClick(object sender, MouseEventArgs e)
{
// get the index of the entity under the cursor
var index = vp.GetEntityUnderMouseCursor(e.Location);
// get that item from the entity list as a IFace (since it's a solid)
var item = vp.Entities[index] as IFace;
// find the closest triangles
var triangles = vp.FindClosestTriangle(item, e.Location);
// get the meshes of that IFace
var meshes = item.GetPolygonMeshes();
// in meshes you have all vertex and triangles you need to create a plane
}https://stackoverflow.com/questions/56124408
复制相似问题