简体   繁体   中英

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.

I dragged and dropped the .dae file to my project. 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.

在此处输入图片说明

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 ?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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