Error “OBJ file has no faces”

一曲冷凌霜 提交于 2020-01-15 09:57:26

问题


I want to place an obj-3D-Model with ARKit and SceneKit.

That's the model I'm using: https://free3d.com/3d-model/chest-50529.html

I'm using the following code:

private func createChestFromScene(_ position: SCNVector3) -> SCNNode? {
    guard let url = Bundle.main.url(forResource: "art.scnassets/Models/chest", withExtension: "obj") else {
        NSLog("Could not find door scene")
        return nil
    }
    guard let node = SCNReferenceNode(url: url) else { return nil }

    node.load()

    // Position scene
    node.position = position

    return node
}

However, I get the following error: OBJ file has no faces.

Why? - Thanks.


回答1:


The problem lies in the encoding of the obj file. In particular, the problem is the carriage return difference.

In a Terminal session, run the following command: file testcube.obj (where test cube is your model name)

The result for files that will cause the error you mentioned is: testcube.obj: ASCII text, with CR line terminators

After removing the CR line terminators the result of the file command is: testcube.obj: ASCII text

The latter opens correctly in XCode and Scenekit and Model IO.

I simply copied a empty new line and replaced the CR with a new line manually but see the following answer on how you can use mac2unix command instead: https://stackoverflow.com/a/14080318/7426374



来源:https://stackoverflow.com/questions/48154432/error-obj-file-has-no-faces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!