I got this error while using iOS 11 ARKit(Scenekit - Xcode 9 beta) when i try to set the simdPosition of virtual object. I need to know if it is possible to convert SCNMatrix4 to matrix_float4x4 in swift. If so how to convert it.
With iOS SDK 11, you can use initializers to convert between SCNMatrix4
and simd_float4x4
.
import SceneKit
var mat4 = SCNMatrix4()
let f4x4 = simd_float4x4(mat4)
mat4 = SCNMatrix4(f4x4)
You could use SCNMatrix4ToMat4
:
let matrix = SCNMatrix4() // matrix is SCNMatrix4
let float4x4 = SCNMatrix4ToMat4(matrix) // float4x4 is matrix_float4x4
And if you want to convert SCNMatrix4
to matrix_float4x4
, use SCNMatrix4FromMat4
:
let matrix1 = SCNMatrix4FromMat4(float4x4) // matrix1 is SCNMatrix4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With