如何为SCNPhysicsShape声明多个选项

时间:2015-01-01 15:22:47

标签: ios objective-c scenekit

我需要在[SCNPhysicsShape shapeWithGeometry:options:]中声明ShapeTypeKey和ShapeScaleKey所有想到的选项。例如,我当前的代码类似于;

NSValue *nodeScale = [NSValue valueWithSCNVector3:SCNVector3Make(200, 400, 150)];
SCNScene *stackScene = [SCNScene sceneNamed:@"stackoverflow.dae"];
SCNNode *stackNode = [stackScene.rootNode childNodeWithName:@"Grid" recursively:NO];
SCNGeometry *nodeGeometry = stackNode.geometry;

stackNode.physicsBody.physicsShape = [SCNPhysicsShape shapeWithGeometry:nodeGeometry options:@{SCNPhysicsShapeTypeKey:SCNPhysicsShapeTypeConcavePolyhedron}];
stackNode.physicsBody.physicsShape = [SCNPhysicsShape shapeWithGeometry:nodeGeometry options:@{SCNPhysicsShapeScaleKey:nodeScale}];

这显然会用后者覆盖前者。

1 个答案:

答案 0 :(得分:1)

作为一本字典,你可以这样做:

stackNode.physicsBody.physicsShape = [SCNPhysicsShape shapeWithGeometry:nodeGeometry options:@{SCNPhysicsShapeTypeKey:SCNPhysicsShapeTypeConcavePolyhedron, SCNPhysicsShapeScaleKey:nodeScale}];

字典中的每个元素都可以用逗号分隔