SceneKit对象在其边界框处而不是沿着网格

时间:2017-04-01 21:46:04

标签: ios 3d swift3 physics scenekit

我正在使用" DAE"作为SCNGeometry的模型。

Half of TUBE

尝试将其用作物理体形状:

    let url = Bundle.main.url(forResource: "art.scnassets/half", withExtension: "dae")
    let sceneSource = SCNSceneSource(url: url!, options: nil)
    let tubeGeometry = (sceneSource?.entryWithIdentifier("Cube-mesh", withClass: SCNGeometry.self ))! as SCNGeometry

    tubeNode = SCNNode(geometry: tubeGeometry)
    tubeNode.position = SCNVector3(0, 1, 0)
    tubeNode.eulerAngles = SCNVector3Make(1.5, 2, 0)

    let tubeShape = SCNPhysicsShape(geometry: tubeGeometry, options: nil)
    let tubeBody = SCNPhysicsBody(type: .static, shape: tubeShape)
    tubeNode.physicsBody = tubeBody
    scene.rootNode.addChildNode(tubeNode)

不要察觉几何对象属性(边,面等)。 看似立方体感知立方体。 因此,球与不是我的物体的不可见平面碰撞,但必须向内落,如下面的截图所示: scene

任何想法/建议为什么? 请帮我解决这个问题...

提前致谢!

1 个答案:

答案 0 :(得分:3)

您需要将物理体形状配置为“SCNPhysicsShapeTypeConcavePolyhedron”(默认为凸面)。您可以使用SCNView的debugOptions来可视化物理形状