错误"OBJ文件没有面孔". [英] Error "OBJ file has no faces"

查看:109
本文介绍了错误"OBJ文件没有面孔".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用ARKit和SceneKit放置obj-3D模型.

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

这就是我正在使用的模型: https://free3d.com/3d -model/chest-50529.html

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

我正在使用以下代码:

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
}

但是,出现以下错误:OBJ file has no faces.

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

为什么? -谢谢.

推荐答案

问题出在obj文件的编码中.特别是问题在于回车差.

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

在终端会话中,运行以下命令: 文件testcube.obj(其中测试立方体是您的模型名称)

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

将导致您提到的错误的文件的结果是: testcube.obj:带有CR行终止符的ASCII文本

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

在删除CR行终止符之后,file命令的结果为: testcube.obj: ASCII文本

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

后者在XCode,Scenekit和Model IO中正确打开.

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

我只是复制了一个空的新行,然后手动将CR换成了新行,但是请参阅以下有关如何使用mac2unix命令的答案: https://stackoverflow.com/a/14080318/7426374

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

这篇关于错误"OBJ文件没有面孔".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆