简体   繁体   中英

Loading STL objects in Swift 2 (Metal)

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM