VR+全景播放器+頭控講解-04

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容