假设我有一个GLKVector3,并且只想读取x和y值作为CGPoints-我该怎么做?

最佳答案

GLKVector3 doc中,有类型定义:

union _GLKVector3
{
   struct { float x, y, z; };
   struct { float r, g, b; };
   struct { float s, t, p; };
      float v[3];
};
typedef union _GLKVector3 GLKVector3;


有3种选择:

GLKVector3v属性,它是float[3]{x,y,z}数组

即:

GLKVector3 vector;

...

float x = vector.v[0];
float y = vector.v[1];
float z = vector.v[2];

CGPoint p = CGPointMake(x,y);


然后,还有针对矢量类型的不同用途的浮点属性x,y,z或不太相关的r,g,bs,t,p

CGPoint p = CGPointMake(vector.x,vector.y);

关于ios - 从GLKVector3中提取X和Y?的iOS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19480982/

10-12 04:23