【问题标题】:How to get CMutablePointer<SCNVector3> from SCNVector3[]?如何从 SCNVector3[] 获取 CMutablePointer<SCNVector3>?
【发布时间】:2014-07-29 07:10:29
【问题描述】:

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

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

【问题讨论】:

  • 试试:init(&amp;vertices, yourCount).
  • "'SCNVector3[]' 不是 '@lvalue $T1' 的子类型"
  • 你的顶点是如何声明的?
  • let vertices: SCNVector3[] = [ ... ]
  • 知道了,我需要var!谢谢!

标签: swift scenekit


【解决方案1】:

您可以从SCNVector3[]&amp; 获得CMutablePointer&lt;SCNVector3&gt;

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

顶点是可变的很重要(用'var'而不是'let'声明)。

(感谢亚当在上面的 cmets 中轻推......如果他写一个我会接受他的回答:)

【讨论】:

    猜你喜欢
    • 2015-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 2018-03-02
    • 2018-02-01
    • 1970-01-01
    • 2021-07-21
    相关资源
    最近更新 更多