SceneKit re-visited: Part 1
I am doing some work on an experimental project using SceneKit & Swift with iOS and WatchKit as application targets ; potentially this is part of a bigger project; I have worked with SceneKit on & off over the past few years. I have also worked with Unity3D and the Unreal engines.
SceneKit combines a high-performance rendering engine with a descriptive API for import, manipulation, and rendering of…developer.apple.com
I am working with SceneKit as I want to have an app that is mixture of UIKit and SceneKit & secondly, I wanted to see what I could do with displaying 3D models on an Apple Watch using SceneKit (Note: at this time, the project does not work with the Watch OS 4 beta).
I am not that fast with 3D modelling; so for the purposes of experiment, I sourced a few hamburger models that have creative commons licensing for this project.
This is a cheeseburger on a sesame seed bun with a side of onion rings and a medium softdrink. Everything uses textures…www.blendswap.com
Many thanks to people who share their work this. I have open sourced the work on this experiment on GitHub as well.
To get the models into Xcode, I needed to convert the blender projects to collada files (DAE). And blender does allow you to export projects to collada files. But the objects were not designed to end up in an app like this; the materials did not look right. I spent a bit of time editing the materials in the Xcode Scene Kit editor. And I found myself thinking, I would use an hamburger photograph image for reference to get RGB values for parts like the bun, tomatoes. etc & this was being done before having lunch — what a challenge I have set up for myself.
Xcode has a materials editor built in. I selected the 3D mesh & then selected the materials tab in the inspector. At this time, I am just changing the diffuse settings values. Dealing with lighting & materials introduces another set of terminology to gain famaliarity with. I remember being puzzled by term albedo when editing colours in Unity — why not just say colour ? I know there is reason for this now 😀.
I used the colour picker tool to hover over the burger photo to select colours. When choosing a colour, I would select a well lit part of the image.
I have a basic iOS app that displays the scene kit file (SCN). In the Xcode interface builder, you reference the SCN file in the properties for the scene view. Note: you need to include the assets folder name in the entry “art.scnassets” giving “art.scnassets/burger.scn”. This is one of those details that is worth putting on a sticky note for furture reference.
Ok, I have a 3d burger being displayed on my iphone but there is no lighting. Now since iOS 10, SceneKit supports physically based rendering (PBR). I need to establish what do I want to do for the purposes of this experiment. I am an amateur film maker thus I do know a bit about lighting scenes.
SceneKit is a fully featured high-level graphics framework enabling your apps and games to create 3D animated scenes…developer.apple.com
I shall think more about lighting over lunch 🍔.