【发布时间】:2018-01-28 10:49:18
【问题描述】:
我有一个混合器文件,我已将其导出为 DAE/collada,然后使用 Xcode 转换为 Scenekit 的场景文件。我在使用场景文件中的几何图形时遇到问题。
场景文件(“model.scn”)非常基本:
- 组(无几何元素)
- Shape1(几何元素)
- Shape2(几何元素)
- Shape3(几何元素)
当我尝试使用该模型时,我无法将 3 个形状的组合几何体用于与 SCNPhysicsBody 一起使用的 SCNGeometry。
我尝试了各种方法,但都不起作用:
方法 1
let scene = SCNScene(named: "art.scnassets/model.scn")!
let node = scene.rootNode.childNode(withName: "Group", recursively: true)!
guard let geo = node.geometry else { return }
// node.geometry is nil so returns here
let physicsBody = SCNPhysicsBody(type: .kinematic, shape: SCNPhysicsShape(geometry: geo))
// this is what I need the custom/aggregate geometry for
方法2
let scene = SCNScene(named: "art.scnassets/model.scn")!
let geoNode = SCNNode()
let node1 = scene.rootNode.childNode(withName: "Shape1", recursively: true)!
let node2 = scene.rootNode.childNode(withName: "Shape2", recursively: true)!
let node3 = scene.rootNode.childNode(withName: "Shape3", recursively: true)!
geoNode.addChildNode(node1)
geoNode.addChildNode(node2)
geoNode.addChildNode(node3)
// expected geoNode.geometry is not nil, but it is
一个节点只能附加一个几何图形。要组合几何图形以便一起控制或制作动画,请创建一个没有几何图形的节点并向其添加其他节点。
但它似乎没有工作,因为父节点的几何可选仍然为零。
我想做的事情应该很简单,但我做错了。我想使用我的 dae/collada/scene 文件中的几何图形。我不想使用默认值(立方体、圆柱体、金字塔、球体、圆环等)。
我做错了什么?谢谢!
【问题讨论】:
标签: ios swift 3d scenekit arkit