简体   繁体   English

3D模型无法在Scenekit中正确加载

[英]3D model not loading correctly in Scenekit

So I purchased a 3D model of a car to display in my ARKIT app.The folder consisted of different model formats and a single image. 因此我购买了汽车的3D模型以显示在我的ARKIT应用中。该文件夹包含不同的模型格式和单个图像。

I dragged and dropped the .dae file to my project. 我将.dae文件拖放到了我的项目中。 This is the file structure. 这是文件结构。

在此处输入图片说明

However when adding to the scene the axis would be completely off and not load correctly. 但是,当添加到场景中时,轴将完全关闭并且无法正确加载。 It did not load the complete model with textures, and would load above me. 它不会加载带有纹理的完整模型,并且会加载到我上方。

See example: 参见示例:

在此处输入图片说明

Then I decided to load the .Blender file in Blender and export again as a colada .dae file. 然后,我决定将.Blender文件加载到Blender中,然后再次导出为colada .dae文件。

在此处输入图片说明

This was the result when adding to my project. 这是添加到我的项目时的结果。

在此处输入图片说明

在此处输入图片说明

When loading it in the real world a half car would appear where I stood at a ridiculously large scale. 在现实世界中加载时,一辆半车会出现在我站着的一个荒谬的地方。

I have tried the project with a separate model and it worked fine. 我已经使用单独的模型尝试了该项目,并且效果很好。 Does anyone have any ideas how I can work with the 3D Model to load correctly in my app ? 有谁知道如何使用3D模型将其正确加载到我的应用程序中?

I had some problems scaling models I have purchased. 我在缩放购买的模型时遇到一些问题。 You aren't supposed to post links, but it's too big to paste in - I followed this guide to scale down the models and rotate them into the proper position in blender before exporting. 您不应该发布链接,但是太大了,无法粘贴-我按照本指南缩小了模型,并在导出之前将它们旋转到Blender中的适当位置。

https://jibransyed.wordpress.com/2014/06/05/how-to-correct-scale-and-rotation-of-static-blender-models-for-unity/ https://jibransyed.wordpress.com/2014/06/05/how-to-correct-scale-and-rotation-of-static-blender-models-for-unity/

On most models I use this to load: 在大多数模型上,我使用它来加载:

func loadCollada(sceneName: String, objName: String) -> SCNNode
    {
        let vScene = SCNScene(named: sceneName)!
        let gObject = vScene.rootNode.childNode(withName: objName, 
 recursively: true)!
        return gObject
      }

On some larger models, I had to do it this way: 在某些较大的模型上,我必须这样做:

func collada2SCNNode(filepath: String) -> SCNNode
{
    let returnNode = SCNNode()
    let scene = SCNScene(named: filepath)
    for vNode in (scene?.rootNode.childNodes)!
    {
        returnNode.addChildNode(vNode)
    }
    return returnNode
}

Then set Y UP: scntool --convert fighter0.dae --format c3d --output out.dae --force-y-up --force-interleaved --look-for-pvrtc-image 然后设置Y UP:scntool --convert fighter0.dae --format c3d --output out.dae --force-y-up --force-interleaved --look-for-pvrtc-image

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM