4

I'm trying to create a 3D model viewer, i've gone through a few tutorials for OpenGL and Metal to create 3D models and do some basic rotations with the pan gesture etc. This example from www.raywenderlich.com, a Sample Project Git(error free), the one on the web(original code) has some errors with Xcode 7.1.1. I want to load STL files to display on the device instead of the Cube. I've searched a lot, but can't find tutorials for loading STL files to project 3d object onto the view (Metal / Swift).

Any help would be great. I'm using swift 2 with xCode 7.1.1

273K
  • 29,503
  • 10
  • 41
  • 64
Amorn Narula
  • 323
  • 3
  • 13

1 Answers1

3

In iOS 9 (and OS X 10.11 and tvOS), the Model I/O framework provides help for loading 3D assets from file formats like (and including) STL. By using Model I/O together with GLKit or MetalKit, you can load those assets right into OpenGL or Metal buffers for rendering.

Apple has a sample code project called MetalKitEssentials that shows a bunch of this stuff in action — it's ObjC, but all the relevant API calls are the same in Swift so it's pretty easy to translate, especially if you already have some working Swift Metal code to reference.

rickster
  • 124,678
  • 26
  • 272
  • 326