VR+全景播放器+头控讲解-01-知识储备
VR+全景播放器+头控讲解-02-创建球体
VR+全景播放器+头控讲解-03-渲染视频
VR+全景播放器+头控讲解-04-滑动手势
VR+全景播放器+头控讲解-05-伸缩画面
VR+全景播放器+头控讲解-06-头控实现
VR+全景播放器+头控讲解-07-分屏技术
本节学习目标
如何实现通过手势移动来调节呈现出来的画面位置
实现步骤
-
1.单独创建一个视图放在最外层,放手势对象
[view addGestureRecognizer:self.panGesture];
-
2.创建一个滑动手势
self.pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGesture:)];
-
3.转换为旋转角度
if (panGesture.state == UIGestureRecognizerStateBegan){ CGPoint currentPoint = [panGesture locationInView:panGesture.view]; self.lastPoint_x = currentPoint.x; self.lastPoint_y = currentPoint.y; [self.delegate gestureManager:self panGesture:panGesture matrix4:SCNMatrix4Identity]; }else{ CGPoint currentPoint = [panGesture locationInView:panGesture.view]; float distX = currentPoint.x - self.lastPoint_x; float distY = currentPoint.y - self.lastPoint_y; self.lastPoint_x = currentPoint.x; self.lastPoint_y = currentPoint.y; // 这里进行手势滑动视角的微调,根据需求设置 distX *= -0.005; distY *= -0.005; self.fingerRotationY += distX * OSVIEW_CORNER / 100.0; self.fingerRotationX += distY * OSVIEW_CORNER / 100.0; SCNMatrix4 modelMatrix = SCNMatrix4Identity; modelMatrix = SCNMatrix4Rotate(modelMatrix, self.fingerRotationX,1, 0, 0); modelMatrix = SCNMatrix4Rotate(modelMatrix, self.fingerRotationY, 0, 1, 0);
-
4.改变照相机的旋转角度
self.eyeNode.pivot = modelMatrix;
本节讲解完毕
SceneKit 中文教程