Add spheres at these points of the special SCNBox?

一世执手 提交于 2019-12-22 16:41:49

问题


Does someone can help me?

I saw that the WWDC 2013 slide has this esample and I try it, using SCNGeometrySource . this is my code below

var box = SCNBox(width: 10, height: 10, length: 10, chamferRadius: 0)
box.widthSegmentCount = 3
box.heightSegmentCount = 3
box.lengthSegmentCount = 3

let positionSource = box.getGeometrySources(for: .vertex)[0]
positionSource.vectorCount
positionSource.data.withUnsafeBytes{(vertexBuffer: UnsafePointer<Float>) in
    print("a")
    let a = positionSource.componentsPerVector
    for i in 0..<positionSource.vectorCount {
        print(SCNVector3(vertexBuffer[i * a], vertexBuffer[i * a + 1], vertexBuffer[i * a + 2]))
    }
}

What I want to do is add those spheres at these position and I can do hitTest with these spheres in my game. So I want to add spheres in any other Geometry like the image.

来源:https://stackoverflow.com/questions/41983862/add-spheres-at-these-points-of-the-special-scnbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!