3d SceneKit用于复杂形状的自定义形状;。DAE“;物体
问题1: 与基本对象发生碰撞的代码-管状体工作不正常:3d SceneKit用于复杂形状的自定义形状;。DAE“;物体,3d,swift3,collision-detection,game-physics,scenekit,3d,Swift3,Collision Detection,Game Physics,Scenekit,问题1: 与基本对象发生碰撞的代码-管状体工作不正常: let tubeGeometry = SCNTube(innerRadius: 2, outerRadius: 2.5, height: 2) let tubeMaterial = SCNMaterial() tubeMaterial.diffuse.contents = UIColor.green tubeGeometry.materials = [tubeMaterial] let tubeNo
let tubeGeometry = SCNTube(innerRadius: 2, outerRadius: 2.5, height: 2)
let tubeMaterial = SCNMaterial()
tubeMaterial.diffuse.contents = UIColor.green
tubeGeometry.materials = [tubeMaterial]
let tubeNode = SCNNode(geometry: tubeGeometry)
tubeNode.position = SCNVector3(0, 0, 0)
let tubeShape = SCNPhysicsShape(geometry: tubeGeometry, options: nil)
let tubeBody = SCNPhysicsBody(type: .dynamic, shape: tubeShape)
tubeNode.physicsBody?.categoryBitMask = collisionTube
tubeNode.physicsBody?.collisionBitMask = collsionTarget
tubeNode.physicsBody?.mass = 1
tubeNode.physicsBody = tubeBody
scene.rootNode.addChildNode(tubeNode)
截图:
为什么球在物体的顶部
问题2:
我仔细阅读了手册,使用了SCNPhysicsShape和SCNPhysicsBody
研究了对DAE对象施加约束的所有可能方法。
并得出结论,所有的限制都必须在对象的单个物理模型中编程为复杂的SCNNodes束
发现了非常有趣的答案:
我真的希望有一种方法来制作类似于让DAEShape=scnpphysisshape(geometry:*.DAE”)的东西,否则设置复杂对象的碰撞可能需要一个月或更长的时间
例如,如何设计复杂管状“DAE”对象的碰撞,如屏幕截图中所示,有何建议?
问题不在于性能,而在于能否以最直接的方式实现复杂3D对象的复杂约束,避免编程的繁琐
如何使用“DAE”对象的顶点、边和面设置物理约束
我真的希望答案是。。。
提前谢谢
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)
tubeNode.physicsBody = SCNPhysicsBody(type: .static, shape: SCNPhysicsShape(geometry: tubeGeometry, options: [SCNPhysicsShape.Option.type: SCNPhysicsShape.ShapeType.concavePolyhedron]))
scene.rootNode.addChildNode(tubeNode)