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

问题描述 投票:4回答:1

我正在使用“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

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

提前致谢!

ios 3d swift3 physics scenekit
1个回答
3
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.