如何检索 ARMeshGeometry 给定面的法线?

发布于 2025-01-11 02:38:34 字数 575 浏览 0 评论 0原文

给定一个 ARMeshAnchor 'meshAnchor',我可以检索它的几何形状和面:

let geometry = meshAnchor.geometry
let faces = geometry.faces
var i = Int(0)
while i < faces.count
{
   //??? get the normal of faces[i]
   i = i+1
}

如何检索 faces[i] 的世界坐标中的法线?

每张脸有 1 个正常吗?每个三角形的每个顶点?或每个网格的顶点?

根据苹果公司的说法: https://developer.apple.com/documentation/arkit/ armeshgeometry/3516923-法线

var 法线: ARGeometrySource { get }
= 定义每个面的外侧方向的射线

given a ARMeshAnchor 'meshAnchor', i can retrieve its geometry and faces :

let geometry = meshAnchor.geometry
let faces = geometry.faces
var i = Int(0)
while i < faces.count
{
   //??? get the normal of faces[i]
   i = i+1
}

how can I retrieve the normal in world coordinates of faces[i] ?

Is there 1 normal per face ? per vertex of each triangle ? or per each vertex of the mesh ?

According to Apple : https://developer.apple.com/documentation/arkit/armeshgeometry/3516923-normals

var normals: ARGeometrySource { get }
= Rays that define which direction is outside for each face

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过潦 2025-01-18 02:38:34

这是我的解决方案。我使用了面几何体的网格锚点中的 int32。该解决方案运行时应该不会出现错误。我能够得到正确的解决方案。就像我通过使用场景理解创建的网格表面进行测试一样,然后获取地板上的网格表面,它返回 0,1,0(y 是向上方向),这是正确的!顺便说一句,我使用 .first 是因为由于三角形的 3 个顶点,数组中存储了 3 个面。而且它们的法线都是相同的,因为它是一个平面。

   for index in 0..<anchor.geometry.faces.count {         
       let x = anchor.geometry.normals[anchor.geometry.faces[index].first!].0
       let y = anchor.geometry.normals[anchor.geometry.faces[index].first!].1
       let z = anchor.geometry.normals[anchor.geometry.faces[index].first!].2
       let normal = SIMD3(x, y, z) 
    }   

This was my solution. I used the int32 from the mesh anchor of the face geometry. This solution should run without an error. I was able to get a correct solution. Like I tested it by using the mesh surface created with scene understanding then getting a mesh face that was on the floor and it returned 0,1,0 (y is up direction) which is right! btw I used .first because there are 3 faces stored in the array due to the 3 verticies of a triangle. and their normals are all the same since its a plane.

   for index in 0..<anchor.geometry.faces.count {         
       let x = anchor.geometry.normals[anchor.geometry.faces[index].first!].0
       let y = anchor.geometry.normals[anchor.geometry.faces[index].first!].1
       let z = anchor.geometry.normals[anchor.geometry.faces[index].first!].2
       let normal = SIMD3(x, y, z) 
    }   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文