GLKMatrix4Multiply is broken



我有以下方法:

func printMatrix(m: GLKMatrix4) {
    var s = ""
    for i in 0...15 {
        s += "(m[i]), "
        if (i + 1) % 4 == 0 {
            print(s)
            s = ""
        }
    }
    print("")
}

以及下面的一些代码:

let a = GLKMatrix4Identity
self.printMatrix(a)
let b = GLKMatrix4MakeTranslation(3.0, 0.0, 0.0)
self.printMatrix(b)
let m = GLKMatrix4Multiply(a, b)
self.printMatrix(m)

最后我看到了结果:

1.0, 0.0, 0.0, 0.0, 
0.0, 1.0, 0.0, 0.0, 
0.0, 0.0, 1.0, 0.0, 
0.0, 0.0, 0.0, 1.0, 
1.0, 0.0, 0.0, 0.0, 
0.0, 1.0, 0.0, 0.0, 
0.0, 0.0, 1.0, 0.0, 
3.0, 0.0, 0.0, 1.0, 
1.0, 1.0, 0.0, 0.0, 
0.0, 0.0, 0.0, 0.0, 
0.0, 0.0, 0.0, 1.0, 
0.0, 3.0, 0.0, 0.0, 

似乎乘法无法正常工作。有没有人可以解释它或为矩阵推荐任何类似的库?

仅在使用 iOS 模拟器进行测试时出现问题(我正在使用模拟器测试上面的代码)。在真实设备上,GLKMatrix4Multiply工作正常。

最新更新