我有一个 typdef 结构,如下所示:
typedef struct {
float Position[3];
float Color[4];
float TexCoord[2];
} const Vertex;
我正在创建一个转换器,我将位置、颜色和 TexCoord 传递到单独的 NSArray 中:
+ (void)arrayConverter: (Vertex *) v
{
// Turn typeDef struct into seperate arrays
NSValue *positionData = [NSValue valueWithBytes:&v->Position objCType:@encode(Vertex)];
NSArray *positionArray = [NSArray arrayWithObjects:positionData, nil];
[positionData getValue:&v->Position]; // where I get error
NSMutableDictionary *vertexdata = [[NSMutableDictionary alloc] init];
[vertexdata setObject:positionArray forKey:@"Position"];
NSLog(@"\n Vertex data: %@\n",vertexdata);
}
我传入的顶点:
const Vertex Iso_Vertices[] = {
{{ -X, 0.0, Z }, {1, 0, 0, 1}, {1, 0}},
{{ X, 0.0, Z }, {0, 1, 0, 1}, {1, 1}},
{{ -X, 0.0, -Z }, {0, 0, 1, 1}, {0, 1}},
{{ X, 0.0, -Z }, {0, 0, 0, 1}, {0, 0}},
{{ 0.0, Z, X }, {1, 0, 0, 1}, {0, 1}},
{{ 0.0, Z, -X }, {0, 1, 0, 1}, {1, 0}},
{{ 0.0, -Z, X }, {0, 0, 1, 1}, {0, 0}},
{{ 0.0, -Z, -X }, {0, 0, 0, 1}, {1, 1}},
{{ Z, X, 0.0 }, {1, 0, 0, 1}, {1, 0}},
{{ -Z, X, 0.0 }, {0, 1, 0, 1}, {1, 1}},
{{ Z, -X, 0.0 }, {0, 0, 1, 1}, {0, 1}},
{{ -Z, -X, 0.0 }, {0, 0, 0, 1}, {0, 0}},
};
这个错误是什么意思?将 'float const(*)[3] 发送到 'void *' 类型的参数会丢弃限定符
似乎我不能让它按我的意愿工作。有什么建议么?