【问题标题】:How to display / determine the index of a vertex in ARSCNFaceGeometry?如何在 ARSCNFaceGeometry 中显示/确定顶点的索引?
【发布时间】:2019-04-28 07:32:56
【问题描述】:

我想获取ARSCNFaceGeometry的网格中特定顶点的索引。

我尝试在显示顶点索引的顶点上添加SCNText

// Create face node
let faceNode = SCNNode(geometry: geometry) // geometry is the ARSCNFaceGeometry

// Get vertices of face node
let vertices = ...

// For each vertex
vertices.enumerated().forEach({ (index, vertex) in
    
    // Create text geometry
    let textGeometry = SCNText(string: text, extrusionDepth: 1)
    textGeometry.firstMaterial?.diffuse.contents = UIColor.black
    
    // Create text node
    let textNode = SCNNode(geometry: textGeometry)
    textNode.scale = SCNVector3(0.0002, 0.0002, 0.0002)
    textNode.position = SCNVector3(vertex.x, vertex.y, vertex.z)
    
    // Add text node to face mask node
    faceNode.addChildNode(textNode)
})

但是在 Xcode Scene Editor 中的结果是一些文本节点定位正确,而另一些则分散在各处:

为什么文本节点是这样定位的?

还有其他获取顶点索引的方法吗?

更新:

我尝试将SCNBox 添加到每个顶点:

let box = SCNBox(width: 0.005, height: 0.005, length: 0.005, chamferRadius: 0)
box.firstMaterial?.multiply.contents = UIColor.blue
let boxNode = SCNNode(geometry: box)
boxNode = vertex
faceNode.addChildNode(boxNode)

结果显示,连盒子的位置都错了。那么如何使用顶点将每个框定位在网格点的中心呢?

【问题讨论】:

    标签: xcode scenekit arkit scnnode arfacegeometry


    【解决方案1】:

    我从面网格中检索顶点的方式是错误的。我现在使用this 回答来提取顶点并且它可以工作。

    【讨论】:

      猜你喜欢
      • 2011-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 2016-11-05
      • 1970-01-01
      相关资源
      最近更新 更多