2014/10/23

Convert GLKMatrix4 to simd::float4x4

I suppose few people need this. But I needed this to use GLKit methods in Objective-C++ for Metal. I had to use GLKit methods because there is few methods to handle quaternion in SceneKit or simd library.
-(simd::float4x4)convertToFloat4x4FromGLKMatrix:(GLKMatrix4)matrix
{
    return float4x4(
                    simd::float4 {matrix.m00,matrix.m01,matrix.m02,matrix.m03 },
                    simd::float4{ matrix.m10,matrix.m11,matrix.m12,matrix.m13 },
                    simd::float4{ matrix.m20,matrix.m21,matrix.m22,matrix.m23 },
                    simd::float4{ matrix.m30,matrix.m31,matrix.m32,matrix.m33 }
                    );
}

Develop | Comments(2) | Trackback(0)
Comment
No title
note that if you are using SceneKit you can convert SCNMatrix4 from/to simd:

SCNMatrix4ToMat4
SCNMatrix4FromMat4
Re: No title
> note that if you are using SceneKit you can convert SCNMatrix4 from/to simd:
>
> SCNMatrix4ToMat4
> SCNMatrix4FromMat4

Thank you for your information!
Though I gave up to use SceneKit for Metal, because SceneKit does not have enough methods for quaternion, for example, a method to convert quaternion to matrix.

管理者のみに表示