1
votes

I know how to export a single model (like a car) from Blender as a .dae file, and then import it and show it using SceneKit. And also with an animation for that model.

But I'm wondering what the best way to import more complex model's. Like a small part of a city. Like a scene with multiple cars and, buildings and people, with different animations.

Is there a way to do this without exporting everything as one model with one animation, and then through code in SceneKit comebine and place everything? So that as much as possible is defined in Blender/other 3D tool.

2

2 Answers

1
votes

It's obvious that you must export complex models from 3D packages divided into smaller parts. And, of course, you do not necessarily need to export all your 3D models separately (per one model basis). In any case, a preparation of all your 3D models for using in Game Engine is extremely time consuming process. There's no one button solution.

Complex scenes like city could be logically divided to groups of static objects: skyscrapers, posts, asphalt, houses, benches, etc. But animated objects, like people, trees or cars, must be exported from Blender and imported into SceneKit separately.

Remember, all corresponding textures for these 3D objects (whether it's a single object or a group of objects) must be saved as UV-mapped square jpeg or png files (like 512x512 or 1024x1024 pix). And do not forget about low-poly collision meshes for dynamics.

Look at WWDC 2015 SceneKit session. You'll see how to build 3D scene in Xcode's Scene Editor.

enter image description here

To accomplish your goal you need to export smaller parts (logically divided, as I mentioned earlier) of your 3D scene from Blender, import all the parts into SceneKit's (ARKit) project and then combine them all through Swift code. Also, many 3D packages can export multiple animations as a single animation with, so called, sub-animations. In this SO post you can find how to handle it.

0
votes

Actually, there is a way to do this.

If you watch the WWDC video about Model I/O, the guy demonstrates how to iterate through a .USD file to easily capture the nodes, geometries, associated hierarchies, materials, animations, etc.

Unfortunately, he didn’t do this for a .dae file.

The process goes like this:

  1. Create an array of the nodes in the scene file.

  2. Create an array that describes the parent nodes of each node.

  3. Create an array that describes the instances of those nodes.

  4. Create an array that describes the materials for the nodes...

  5. Create an array that describes the animations... do this by creating an array of the bones, their attached vertices, transforms, etc.

After all that, you have to code a function that reassembles the scene that has been described as an array of arrays.

I’m not skilled enough to do this... and I hope somebody creates an example so I can study it.

But that’s the logic.