我正在处理场景套件中的玉米洞游戏,并遇到了SCNPhysicsShape和SCNPhysicsBody摩擦的错误。游戏的棋盘是通过.dae文件加载的,并被设置为SCNPhysicsShapeTypeConcavePolyhedron。这允许豆袋从洞中落下,但是它似乎抵消了板上的摩擦力。当豆袋撞到板上时,它会立即滑下,尽管摩擦值为1.0 (豆袋的摩擦值也为1.0 )。如果我把板子改成SCNPhysicsShapeTypeConvexHull,那么摩擦力就会起作用,但是豆袋不会掉进洞里。
以下是我的自定义电路板初始化:
let geo = nodeWithFile("board.dae").geometry!
geo.materials = [SCNMaterial()]
geo.firstMaterial!.diffuse.contents = "wood_texture.png"
geo.firstMaterial!.diffuse.wrapS = SCNWrapMode.Repeat
geo.firstMaterial!.diffuse.wrapT = SCNWrapMode.Repeat
geo.firstMaterial!.diffuse.mipFilter = SCNFilterMode.Linear
self.geometry = geo
self.position = position
self.rotation = SCNVector4Make(1, 0, 0, -CFloat(degreesToRadians(65.0)))
let shape = SCNPhysicsShape(geometry: geo, options: [SCNPhysicsShapeTypeKey: SCNPhysicsShapeTypeConcavePolyhedron])
self.physicsBody = SCNPhysicsBody(type: .Static, shape: shape)
self.physicsBody!.restitution = 0.0
self.physicsBody!.rollingFriction = 1.0
self.physicsBody!.friction = 1.0下面是bean包的自定义初始化
let geo = SCNBox(width: 20.0, height: 4.0, length: 20.0, chamferRadius: 5.0)
self.geometry = geo
self.position = position
self.geometry!.firstMaterial!.diffuse.contents = UIColor.blueColor()
let shape = SCNPhysicsShape(geometry: geo, options: [SCNPhysicsShapeTypeKey: SCNPhysicsShapeTypeBoundingBox])
self.physicsBody = SCNPhysicsBody(type: .Dynamic, shape: shape)
self.physicsBody!.restitution = 0.0
self.physicsBody!.rollingFriction = 1.0
self.physicsBody!.friction = 1.0这两个都在SCNNode子类的类的初始化方法中
我的问题是:怎样才能使板保持ConcavePolyhedron的状态,同时摩擦也能正常工作?
发布于 2015-06-17 23:25:55
这可能不是最好的答案,但它会起作用。将您的电路板重新设计为多个部分,在中间留下一个不属于几何体的孔。
https://stackoverflow.com/questions/29521395
复制相似问题