####physics body物理形体
####physics shapes物理形状
###获取相机中心
代码语言:txt复制ARFrame * frame = self.jpARSCNView.session.currentFrame;
SCNMatrix4 mat = SCNMatrix4FromMat4(frame.camera.transform);
SCNVector3 dir = SCNVector3Make(-1* mat.m31, -1* mat.m32 , -1* mat.m33);
SCNVector3 pos = SCNVector3Make(mat.m41,mat.m42 ,mat.m43);
bulletsNode.position = pos;
SCNVector3 bulletDirection = dir;
[bulletsNode.physicsBody applyForce:bulletDirection impulse:YES];
[self.jpARSCNView.scene.rootNode addChildNode:bulletsNode];
###检测碰撞事件
######和以往iOS的代理事件不同 它还要多设置categoryBitMask、contactTestBitMask属性的id 用于标志2个物体是否会发生碰撞
#####代理设置
<SCNPhysicsContactDelegate>
_jpARSCNView.scene.physicsWorld.contactDelegate = self;
self.physicsBody.categoryBitMask = 2;
self.physicsBody.contactTestBitMask = 1;
// 这里是自己独立开一条线程出来
— (void)physicsWorld:(SCNPhysicsWorld )world didBeginContact:(SCNPhysicsContact )contact ;
代码