0

我正在尝试使用 SCNGeometrySource 的init(vertices: CMutablePointer<SCNVector3>, count: Int)初始化程序,但我不知道如何制作CMutablePointer<SCNVector3>.

在 Objective-C 中,我会使用 C 数组,但我不认为SCNVector3[]Swift 中的 a 是这样布局的。

4

1 回答 1

1

You can get a CMutablePointer<SCNVector3> from SCNVector3[] with &:

var vertices: SCNVector3[] = [ ... ]
let geometrySource = SCNGeometrySource(vertices: &vertices, count: vertices.count)

It's important that vertices is mutable (declared with 'var' instead of 'let').

(found thanks to Adam's nudging in the comments above... whose answer I'll accept if he writes one :)

于 2014-06-08T17:19:59.747 回答