我想点击一个实体的脸,并产生它的法线向量。它将帮助我设置一个旋转轴。
我按照示例中的model1_SelectionChanged:EyeshotDemo,我可以知道我点击了哪张脸。但我不知道下一步我能做什么。
我想点击一个实体的脸,并产生它的法线向量。它将帮助我设置一个旋转轴。
我按照示例中的model1_SelectionChanged:EyeshotDemo,我可以知道我点击了哪张脸。但我不知道下一步我能做什么。
您应该出于面部定位目的使用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
}