首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

VR+全景播放器+头控讲解-04

本节学习目标

如何实现通过手势移动来调节呈现出来的画面位置

实现步骤

  • 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 中文教程

下一篇
举报
领券