2014/12/19

How to use 3D data by Blender for Metal in Swift 3

Continuation of : How to use 3D data by Blender for Metal in Swift 2 / iPhone App Development Memo

3 Make Swift data file directly

Finally I tried to make a Swift file which has 3D data.
I usually use one program which is introduced this page :
How To Export Blender Models to OpenGL ES: Part 1/3 - Ray Wenderlich

I changed the code to output a Swift file, and the result code is like this :
import Foundation
class Robot3 { 

    let vertices: Int = 660
    let positions: [Float] = [
        -0.437199, 0.539412, -0.437199, 
        -0.437199, -0.539412, -0.437199, 
        -0.437199, 0.494338, -0.139248, 
        ...
    ]

    init () {
    }
}
At first I just declared variables and set values in initializer, but sometimes this code terminated abruptly, so I changed code like above and there is nothing to do in init()

Then I can easily access data of vertices etc.

I’m not sure which is the most proper way, so I will do like this.
Develop | Comments(0) | Trackback(0)
Comment

管理者のみに表示