QUESTION 1:
Code to make collision with elementary object - tube works not correctly:
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)
Screenshot:

Why balls is on the top of object ?
QUESTION 2:
I'm carefully read the manual to use the classes SCNPhysicsShape and SCNPhysicsBody
Researched all possible ways of imposing constraints to the DAE objects. And came to the conclusion that all restrictions must be programmed complex bundles of SCNNodes in a single physical model of the object.
Found very interesting answer:
LINK
I really hope there is a way to made something like let DAEShape = SCNPhysicsShape(geometry: "*.DAE")..., otherwise the setting collisions to complex objects can take a month or more development.
For example, how to design collisions of the complex tube "DAE" object, as in the screenshot, any advices?

The question is not about performance rather the ability to implement complex constraints to complex 3D objects the most straightforward way, avoiding the chore of programming...
How to set physic constraints using the vertexes, edges and faces of the "DAE" object?
I really hope that the answer will be... Thanks in advance!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With