我想单击一个实体的脸并出现其法线向量,这将帮助我设置旋转轴。
我在sample:EyeshotDemo中遵循model1_SelectionChanged,我可以知道我点击了哪张脸。但是我不知道下一步该怎么做。
答案 0 :(得分:0)
出于面向面部的目的,应使用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
}