Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 985
yaali Avatar asked Aug 08 '17 11:08

yaali


2 Answers

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)
like image 124
OOPer Avatar answered Nov 19 '22 13:11

OOPer


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
like image 23
Vasilii Muravev Avatar answered Nov 19 '22 12:11

Vasilii Muravev