【发布时间】:2014-12-29 22:49:34
【问题描述】:
我在 SceneKit 中发现 collada 对象的联合旋转有一个奇怪的行为。
想象一下,我用这段代码制作旋转桌(cheeta3d 制作的复杂表格桌):
SCNScene *heroScene = [SCNScene sceneNamed:@"scene.dae"];
b = [heroScene.rootNode childNodeWithName:@"desk" recursively:YES];
b.physicsBody = [SCNPhysicsBody dynamicBody];
b.physicsBody.physicsShape=[SCNPhysicsShape shapeWithNode:b options:@{SCNPhysicsShapeTypeKey:SCNPhysicsShapeTypeConcavePolyhedron,SCNPhysicsShapeKeepAsCompoundKey:@YES}]; //**HERE we need YES only, if NO it is not rotating**!
[scene.rootNode addChildNode:b];
SCNPhysicsHingeJoint *joint = [SCNPhysicsHingeJoint jointWithBody:b.physicsBody axis:SCNVector3Make(0,1,0) anchor:SCNVector3Make(0,5,0)];
[scene.physicsWorld addBehavior:joint];
看评论 //这里我们只需要 YES,如果 NO 它不旋转!
我测试了所有案例,所有关节。 SCNPhysicsShapeKeepAsCompoundKey 必须为 YES,尽管我认为这里并不那么重要。
为什么会这样?
【问题讨论】: