【问题标题】:Scene Kit View with moving Object带有移动对象的场景套件视图
【发布时间】:2020-01-05 10:06:14
【问题描述】:

如何使用带有 swift 4 的场景套件视图在我的简单视图应用程序中显示移动的 3D 对象。

比如windows下的bee.glb文件,我用的是这四个文件:

  1. body.bmp
  2. 正文.jpg
  3. volkeswagon-vw-beetle.mtl
  4. 大众-大众-甲壳虫.obj

    import UIKit
    import SceneKit
    import ARKit
    
    class ViewController: UIViewController {
    
    @IBOutlet weak var sceneView: SCNView!
    
    override func viewDidLoad() {
    super.viewDidLoad()
    
    
    // 1: Load .obj file
    let scene = SCNScene(named: "volkeswagon-vw-beetle.obj")
    
    // 2: Add camera node
    let cameraNode = SCNNode()
    cameraNode.camera = SCNCamera()
    // 3: Place camera
    cameraNode.position = SCNVector3(x: 0, y: 10, z: 35)
    // 4: Set camera on scene
    scene!.rootNode.addChildNode(cameraNode)
    
    // 5: Adding light to scene
    let lightNode = SCNNode()
    lightNode.light = SCNLight()
    lightNode.light?.type = .omni
    lightNode.position = SCNVector3(x: 0, y: 10, z: 35)
    scene?.rootNode.addChildNode(lightNode)
    
    // 6: Creating and adding ambien light to scene
    let ambientLightNode = SCNNode()
    ambientLightNode.light = SCNLight()
    ambientLightNode.light?.type = .ambient
    ambientLightNode.light?.color = UIColor.darkGray
    scene?.rootNode.addChildNode(ambientLightNode)
    
    // Allow user to manipulate camera
    sceneView.allowsCameraControl = true
    
    // Show FPS logs and timming
     sceneView.showsStatistics = true
    
    // Set background color
    sceneView.backgroundColor = UIColor.white
    
    // Allow user translate image
    sceneView.cameraControlConfiguration.allowsTranslation = false
    
    // Set scene settings
    sceneView.scene = scene
    }
    
    }
    

输出是:

"3DVideo[6430:105708] [SceneKit] 错误:OpenGL 渲染器不支持基于物理的光照模型,而是使用 Phong (3) 2019-09-02 03:29:13.297536-0700 3DVideo[6430:105708] [SceneKit] 错误:OpenGL 渲染器不支持基于物理的光照模型,而是使用 Phong (2) 2019-09-02 03:29:13.308381-0700 3DVideo[6430:105708] [SceneKit] 错误:OpenGL 渲染器不支持基于物理的光照模型,而是使用 Phong”

【问题讨论】:

标签: swift scenekit .obj


【解决方案1】:

我通过将我的文件扩展名从 .obj 更改为 .dae 来解决此问题。因为 obj 文件没有任何动画

【讨论】:

    猜你喜欢
    • 2019-09-13
    • 2022-01-20
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多