Cannot convert value of type "SCNMatrix4" to the expected argument type "matrix_float4x4" (aka 'simd_float4x4')

I got this error when using iOS 11 ARKit (Scenekit - Xcode 9 beta) when I try to set the simdPosition of a virtual object. I need to know if it is possible to convert SCNMatrix4 to matrix_float4x4 in swift. If so, how to convert it.

+4
source share
2 answers

With the iOS SDK 11, you can use initializers to convert between SCNMatrix4and simd_float4x4.

import SceneKit

var mat4 = SCNMatrix4()

let f4x4 = simd_float4x4(mat4)

mat4 = SCNMatrix4(f4x4)
+8
source

SCNMatrix4ToMat4:

let matrix = SCNMatrix4()               // matrix is SCNMatrix4
let float4x4 = SCNMatrix4ToMat4(matrix) // float4x4 is matrix_float4x4

SCNMatrix4 matrix_float4x4, SCNMatrix4FromMat4:

let matrix1 = SCNMatrix4FromMat4(float4x4) // matrix1 is SCNMatrix4
+1

Source: https://habr.com/ru/post/1683243/


All Articles