我有一个包含16个浮点数的数组,我想用这个数组来初始化CATransform3D的值,即m11,m12,.....,有没有办法初始化它?
答案 0 :(得分:0)
CATransform3D
定义如下:
struct CATransform3D
{
CGFloat m11, m12, m13, m14;
CGFloat m21, m22, m23, m24;
CGFloat m31, m32, m33, m34;
CGFloat m41, m42, m43, m44;
};
下面的内容应该有效:
CATransform3D myTransform;
myTransform.m11 = array[0];
myTransform.m12 = array[1];
myTransform.m13 = array[2];
myTransform.m14 = array[3];
myTransform.m21 = array[4];
myTransform.m22 = array[5];
myTransform.m23 = array[6];
myTransform.m24 = array[7];
...
myTransform.m44 = array[15];
答案 1 :(得分:0)
有点脏,但你可以这样做:
CGFloat array[16];
...
CATransform3D myTransform;
memcpy(&myTransform, &array, sizeof(CATransform3D));