10

What is the correct way to export meshes including textures etc for use in SceneKit of iOS 8 or even OS X? By the default options I can only export meshes - somehow I don't get textures to work. Also Preview in OS X has trouble opening anything output from Blender/COLLADA so far. Running OS X Mavericks.

For instance, the ship.dae that is included in a template SceneKit project in Xcode 6 has Y for up, whereas stuff exported from Blender has Z up. Maybe this causes errors in the Apple world? Also importing ship.dae then exporting it with default options gives likewise "bad" COLLADA output. I was doing a diff in the input ship.dae and the output one and the differences were rather many so I don't know where to start.

Jonny
  • 503
  • 2
  • 6
  • 15
  • Have you tried to pass user data to SceneKit through the .dae file? I don't know whether it's possible, though, I'm just curious. – rraallvv Feb 24 '15 at 02:24
  • I haven't been doing any SceneKit or even Blender for a long time, but it seems like the USD format (Universal Scene Description) is the way forward - already supported in iOS 10. Unfortunately it seems like Blender does not support it, yet. – Jonny Jan 11 '17 at 08:31
  • press the export button and then done and it will work – mr.Bob Aug 14 '17 at 19:42

1 Answers1

12

Until I can get a tutorial made I will give a couple pointers.

Solve Blender "z" up axis

  1. Create a folder on your desktop and give it an extension of ".scnassets"

  2. Put your collada(.dae) file along with any textures you will be using

  3. Drag the folder into your project and save as copy like usual.

  4. Click on your scnassets folder and you will see a checked box (if not check it) for converting to a "y" up axis.

Using textures with Blender collada

  1. Click on your collada(.dae) file inside your project in xcode.

  2. You should see your scene and on its left side a list of cameras, lights, materials, and such.

  3. Open the materials tab and click on one of your materials.

  4. On the right hand side in the inspection window click on the ball shaped icon to view the diffuse, specularity, and such of that one material.

  5. Click on the diffuse tab and when it opens you should have an option of colors and your textures within your project. Select the texture you used on your model within Blender. As long as you UV unwrapped them properly in blender they should apply instantly within your scene view.

NOTE
Blender will not export the texture for you. No need to check on that tab inside of the collada exporter window.

ANOTHER NOTE If you want to add to or delete something from your scnassets folder, navigate to your project folder to do so and not xcode. This took me a while to figure out so thought I would save everyone the trouble.

FlippinFun
  • 236
  • 2
  • 3
  • Thanks - the axis thing seems to have been set up already. Actually, the meshes' "up" were never incorrect. However when I set "diffuse" to the texture (I am using a texture for a floor), the floor appears to change to use the texture but it's very blurred so it basically just displays an extremely blurred out brown color - the original texture is a fine tatami mat. – Jonny Aug 01 '14 at 05:05
  • Another note: the template ship.dae has a meter specified as "0.01", whereas anything exported from Blender has "1". Maybe the scale is incorrect. – Jonny Aug 01 '14 at 05:21
  • Did you uv unwrap your floor in blender. Sounds like all of your vertices are stacked on top of each other and basically displaying the color of one spot of your texture. I haven't had any issues with scale. – FlippinFun Aug 01 '14 at 06:18
  • Ok you are probably right - I just started with Blender a few days ago and even though the preview within Blender displays the textures, I guess I will have to find out how to exactly do that part. Btw I followed this short tutorial on texturing in Blender: https://www.youtube.com/watch?v=Ix6_j-PMtSE Maybe you could include a short texturing part in your tutorial ;-)) I'll set your answer as right. – Jonny Aug 01 '14 at 07:08
  • Thanks and I will check that out. There are plenty of good tutorials on uv unwrapping on youtube also. – FlippinFun Aug 01 '14 at 07:40
  • Jonny that was a good video using Blender render but a few years old. He projected but never unwrapped his uv's. When you unwrap them they are stored as 2D coordinate values in your collada file which helps match them back up to your texture in xcode(scenekit) or any other program. Search youtube for uv unwrapping and I believe your problem will be solved. If I find a good one I will post it here. – FlippinFun Aug 01 '14 at 07:58
  • I did it by following this tutorial to make a wooden cup: https://www.youtube.com/watch?v=9PJL0eAuZ_E For anyone watching this, the texturing part begins at about 6:30. The only problem when looking at the .dae in Preview and on an iOS device is that there was no texture inside the cup, but I could set "Double sided" in Xcode and it fixed that. Now the cup still looks a bit different, it has not the same "thickness" on top. Anyway this is getting lengthy, so a complete tutorial writeup on a lot of these things would be very useful. – Jonny Aug 01 '14 at 08:38
  • Great tutorial indeed Jonny. Your SCNMaterial class has a property called "doublesided" which should be applied in your case. The cup is modified to show thickness but actually is only a single layer all the way around it. You will have to use SCNSceneSource to get a reference to your material as answered in the question you asked about untitled animations and set that property to yes. It is default no because most cases the back side of a polygon is not visible. Such as a cube. Glad to see you are finding your way! – FlippinFun Aug 01 '14 at 09:28
  • A heads-up. The option to fix up axis to Y seems to be gone from Xcode 8. I just cannot find the feature in Xcode 8.2.1. – Jonny Jan 12 '17 at 02:16
  • I found out (thanks to http://stackoverflow.com/a/41606318/129202) that you need to ctrl-click the .scnassets folder in Xcode and "Open as Scene Kit Asset catalog". This opens the options we are looking for. – Jonny Jan 13 '17 at 03:12