via CoreMotion Controlled 3D Sketching on an iPhone with Swift.
I was really impressed by a demo of InkScape that I read about in Creative Applications recently. InkScape is an Android app which allows users to sketch in a 3D space that’s controlled by the device’s accelerometer. It’s inspired byRhonda which pre-dates accelerometers and uses a trackball instead.
Of course, my first thought was, “how can I do this in Swift?“. I’ve never done any work with CoreMotion before, so this was a good opportunity to learn some new stuff. My first port of call was this excellent article on iOS motion at NSHipster.
My plan for the application was to have a SceneKit scene with a motion controlled camera rotating around an offset pivot point at the centre of the SceneKit world. With each touchesBegan(), I’d create a new flat box in the centre of the screen that aligned with the camera and on touchesMoved(), I’d use the touch location to append to a path that I’d draw onto a CAShapeLayer that I’d use as the diffuse material for the newly created geometry.
Easy! Let’s break it down:
via An Introduction to SceneKit: User Interaction, Animations & Physics – Tuts+ Code Tutorial.
This is the second part of our introductory series on SceneKit. In this tutorial, I assume you are familiar with the concepts explained in the first part, including setting up a scene with lights, shadows, cameras, nodes, and materials.
In this tutorial, I am going to teach you about some of the more complicated—but also more useful—features of SceneKit, such as animation, user interaction, particle systems, and physics. By implementing these features, you can create interactive and dynamic 3D content rather than static objects like you did in the previous tutorial.
We’ll look at the primitives available in SceneKit and some basic animations.
Here’s a SceneKit starter project with an empty scene to help you follow along with this tutorial.
Geometries in SceneKit are instances of the SCNGeometry class. Geometries provide the data necessary to draw the 3D objects they represent. Among other things this data is made up of vertices, normals, texture coordinates and indices. We also plan on releasing a series of tutorials on custom geometries which will explain all these concepts in detail.
If you want more information on geometry data in SceneKit have a look at this great tutorial this great tutorial which explains how to create custom geometries. Read More>>
SceneKit is a powerfull high level framework for adding 3D graphics to your apps. You can use it to build games, interactive visualizations, 3D user interfaces or any kind of gaming or non-gaming appliclications. SceneKit has been around since 2012 but was previously only available on OSX. Before SceneKit iOS Developers had to learn OpenGL or use 3rd party Frameworks which often did not interact well with the rest of iOS or had significant limitations. Read More>>