zoukankan      html  css  js  c++  java
  • iOS开发之SceneKit框架--SCNCamera.h

    1、SCNCamera简介

      被称为照相机或者摄像机,可以附加到节点以提供显示场景的角度。其实就是用户视角和人的眼睛一样。

    2、相关API简介

    • 初始化
    //懒加载
    + (instancetype)camera;
    • 管理相机属性
    //名字
    @property(nonatomic, copy, nullable) NSString *name;
    • 调整镜头角度
    //决定了相机和可见表面之间的最小距离。如果一个表面离摄像机的距离比这个最小距离更近,那么表面就会被剪掉。默认为1
    @property(nonatomic) double zNear;
    
    //决定了相机和可见表面之间的最大距离。如果一个表面离摄像机远超过这个最大距离,那么表面就被剪掉了。默认为100
    @property(nonatomic) double zFar;
    
    //是否自动调整zNear和zFar值,默认为NO
    //YES:近距离和远平面将自动设置为在渲染时匹配整个场景的边界框。
    @property(nonatomic) BOOL automaticallyAdjustsZRange API_AVAILABLE(macos(10.9));
    • 管理相机视野
    //相机的垂直或水平视角。默认60°
    @property(nonatomic) CGFloat fieldOfView API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //相机的焦距,默认50mm
    @property(nonatomic) CGFloat focalLength API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //相机成像平面的垂直尺寸,默认24mm
    @property(nonatomic) CGFloat sensorHeight API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //确定视场或正投影尺度的轴是垂直还是水平。默认垂直
    @property(nonatomic) SCNCameraProjectionDirection projectionDirection API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    typedef NS_ENUM(NSInteger, SCNCameraProjectionDirection) {
        SCNCameraProjectionDirectionVertical   = 0,//相机的视场或正投影尺度是垂直测量的。
        SCNCameraProjectionDirectionHorizontal = 1,//    相机的视场或正投影尺度是水平测量的。
    } API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    • 管理投影变换
    //确定接收器是否使用正投影,默认为NO
    @property(nonatomic) BOOL usesOrthographicProjection;
    
    //这个设置决定了相机可视区域的大小。只有当usesOrthographicProjection设置为YES时才启用。
    //当使用正投影时,指定相机的放大倍数。默认为1.
    @property(nonatomic) double orthographicScale API_AVAILABLE(macos(10.9));
    
    //确定摄像机用于投影世界的投影变换。
    @property(nonatomic) SCNMatrix4 projectionTransform;
    • 选择要对相机可见的节点
    //确定从接收者可见的节点类别。默认值是所有
    @property(nonatomic) NSUInteger categoryBitMask API_AVAILABLE(macos(10.10));
    • 增加景深效果的影响(景深效果是指当焦点对准某一点时,其前后都仍可清晰的范围。它能决定是把背景模糊化来突出拍摄对象,还是拍出清晰的背景。)、
    //是否为相机渲染了景深模糊效果。默认为NO
    @property(nonatomic) BOOL wantsDepthOfField API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //确定相机的焦点距离 默认为2.5
    @property(nonatomic) CGFloat focusDistance API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //模拟的物理相机孔径,用于景深效果 默认值5.6
    @property(nonatomic) CGFloat fStop API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //模拟的物理摄像机光圈的数量,以获得景深效果。默认值为6
    @property(nonatomic) NSInteger apertureBladeCount API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //像素样本的数量用于创建景深模糊效果。默认为25
    @property(nonatomic) NSInteger focalBlurSampleCount API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    • 添加动态模糊效果
    //确定运动模糊的强度。可以做成动画。默认值为0。
    //强度为零意味着没有运动模糊。强度不应超过1
    @property(nonatomic) CGFloat motionBlurIntensity API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    • 添加高动态范围效果。
    //是否将高动态范围(HDR)处理后效果应用到场景中。默认为NO
    @property(nonatomic) BOOL wantsHDR API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //对数偏差,调整SceneKit的色调映射操作的结果,场景可见亮或变暗。默认为0
    @property(nonatomic) CGFloat exposureOffset API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //确定最终图像中所需的平均灰度值。默认为0.18。
    @property(nonatomic) CGFloat averageGray API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //确定在最终图像中映射为白色的最小亮度级别。默认为1。
    @property(nonatomic) CGFloat whitePoint API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //在色调映射中使用的最小曝光值。默认为-15。
    @property(nonatomic) CGFloat minimumExposure API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //在色调映射中使用的最大曝光值。默认为-15。
    @property(nonatomic) CGFloat maximumExposure API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    • 添加自动HDR曝光适应
    //否自动调整暴露水平。默认值为YES。
    @property(nonatomic) BOOL wantsExposureAdaptation API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //从明亮到黑暗区域自动动画曝光的相对持续时间 默认0.4
    @property(nonatomic) CGFloat exposureAdaptationBrighteningSpeedFactor API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //从黑暗到明亮区域自动动画曝光的相对持续时间 默认0.6
    @property(nonatomic) CGFloat exposureAdaptationDarkeningSpeedFactor API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    • 调整呈现的颜色
    //控制整个场景的饱和度。默认为1(无效果)。
    @property(nonatomic) CGFloat saturation API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //控制整个场景的对比。默认为0(无效果)。
    @property(nonatomic) CGFloat contrast API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //一种将颜色分级效果应用到整个渲染场景的纹理。
    @property(nonatomic, readonly) SCNMaterialProperty *colorGrading API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    • 添加风格的视觉效果(Bloom、渐变、渐晕)
    //Bloom,又称“全屏泛光”,是游戏中常用的一种镜头效果,是一种比较廉价的“伪HDR”
    //在渲染的场景中应用于高光的亮度的大小。可以做成动画。默认为0(无效果)。
    @property(nonatomic) CGFloat bloomIntensity API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //设置Booom效果的亮度阈值 可以做成动画。默认为1
    @property(nonatomic) CGFloat bloomThreshold API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //以像素为单位的半径,确定Bloom效果的半径。可以做成动画。默认为4
    @property(nonatomic) CGFloat bloomBlurRadius API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //控制色彩渐变。默认为1。
    @property(nonatomic) CGFloat colorFringeIntensity API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //控制色彩渐变的强度。默认为0(无效果)。
    @property(nonatomic) CGFloat colorFringeStrength API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //控制渐晕效果的强度。默认为0(无效果)。
    @property(nonatomic) CGFloat vignettingIntensity API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    
    //控制渐晕效果的形状。默认为0(无效果)。
    @property(nonatomic) CGFloat vignettingPower API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0));
    • 添加屏幕空间环境遮挡。
    //施加在照相机渲染中的屏幕空间环境遮挡效应的强度。可动画、默认为0
    @property(nonatomic) CGFloat screenSpaceAmbientOcclusionIntensity API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //设置屏幕空间环境遮挡的作用半径。可动画 默认为5
    @property(nonatomic) CGFloat screenSpaceAmbientOcclusionRadius API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //设置遮挡偏差 ,默认0.03
    @property(nonatomic) CGFloat screenSpaceAmbientOcclusionBias API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //确定场景单元的深度模糊阈值。默认值0.2
    @property(nonatomic) CGFloat screenSpaceAmbientOcclusionDepthThreshold API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //确定正常模糊阈值。默认0.3
    @property(nonatomic) CGFloat screenSpaceAmbientOcclusionNormalThreshold API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    • 被废弃方法
    //确定物理相机孔径。默认值为0。
    @property(nonatomic) CGFloat focalBlurRadius API_DEPRECATED("Use fStop instead", macos(10.8, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
    
    //确定接收器在X轴上的视场。可以做成动画。
    @property(nonatomic) double xFov API_DEPRECATED("Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead", macos(10.8, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
    
    //确定接收器在Y轴上的视场。可以做成动画。
    @property(nonatomic) double yFov API_DEPRECATED("Use -[SCNCamera fieldOfView] or -[SCNCamera focalLength] instead", macos(10.8, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
    
    //决定了接收机的光圈。可以做成动画。默认值1/8.0. 可动画
    @property(nonatomic) CGFloat aperture API_DEPRECATED("Use -[SCNCamera fStop] instead with fStop = sensorHeight / aperture.", macos(10.8, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
    
    //确定接收器的焦距。可以做成动画。默认0
    @property(nonatomic) CGFloat focalSize API_DEPRECATED_WITH_REPLACEMENT("-focusDistance", macos(10.9, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
    
    //确定接收器的焦距
    //当非零值时,焦距决定了相机在三维场景中如何聚焦对象。在macOS 10.13、ios11、tvos11和watchOS 4之前,默认值为10.0。否则默认为2.5。
    @property(nonatomic) CGFloat focalDistance API_DEPRECATED_WITH_REPLACEMENT("-focusDistance", macos(10.9, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0));
  • 相关阅读:
    在桌面上显示IE图标(非快捷键)
    在桌面上显示IE图标(非快捷键)
    Detours的使用准备
    Detours的使用准备
    腾讯机试题 AcWing 603 打怪兽
    牛客练习赛13D 幸运数字4
    牛客练习赛13B 幸运数字2
    牛客练习赛13E 乌龟跑步
    NOIP2016提高组复赛C 愤怒的小鸟
    Leetcode SingleNumber I & II & III 136/137/260
  • 原文地址:https://www.cnblogs.com/xianfeng-zhang/p/8990585.html
Copyright © 2011-2022 走看看