我正在使用“DAE”模型作为SCNGeometry。
试图将它用作物理体形状:
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)
不要察觉几何对象属性(边,面等)。看似立方体感知立方体。因此,球与一个不是我的物体的无形平面相撞,但必须向内倾斜,如下面的截图:
任何想法/建议为什么?请帮我解决这个问题......
提前致谢!
您需要将物理体形状配置为“SCNPhysicsShapeTypeConcavePolyhedron”(默认为凸面)。您可以使用SCNView的debugOptions来可视化物理形状