我需要在[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}];
这显然用后者覆盖了前者。
最佳答案
由于它是一本字典,因此您可以执行以下操作:
stackNode.physicsBody.physicsShape = [SCNPhysicsShape shapeWithGeometry:nodeGeometry options:@{SCNPhysicsShapeTypeKey:SCNPhysicsShapeTypeConcavePolyhedron, SCNPhysicsShapeScaleKey:nodeScale}];
字典中的每个元素都可以用逗号分隔
关于ios - 如何为SCNPhysicsShape声明多个选项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27732009/