如何为 SCNPhysicsShape 声明多个选项
How to declare more than one option for SCNPhysicsShape
我需要在 [SCNPhysicsShape shapeWithGeometry: options:] 中声明 ShapeTypeKey 和 ShapeScaleKey,所有想到的选项都不多。例如,我当前的代码类似于;
NSValue *nodeScale = [NSValue valueWithSCNVector3:SCNVector3Make(200, 400, 150)];
SCNScene *stackScene = [SCNScene sceneNamed:@"Whosebug.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}];
字典中的每个元素可以用逗号分隔
我需要在 [SCNPhysicsShape shapeWithGeometry: options:] 中声明 ShapeTypeKey 和 ShapeScaleKey,所有想到的选项都不多。例如,我当前的代码类似于;
NSValue *nodeScale = [NSValue valueWithSCNVector3:SCNVector3Make(200, 400, 150)];
SCNScene *stackScene = [SCNScene sceneNamed:@"Whosebug.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}];
字典中的每个元素可以用逗号分隔