将struct Array复制到另一个struct数组(GLKVector)

时间:2013-04-16 14:14:18

标签: objective-c arrays struct opengl-es-2.0 glkit

我尝试将vertexDataTextured ArmandDeBrignac []数组的内容复制到vertexDataTextured MeshVertexData []数组中。但它不起作用....我认为问题出在struct方法中,有GLKvector元素.....?

这是我的标题 - 文件:

struct vertexDataTextured
{
    GLKVector3      vertex;
    GLKVector3      normal;
    GLKVector2      texCoord;
};
typedef struct vertexDataTextured vertexDataTextured;
typedef vertexDataTextured* vertexDataTexturedPtr;


vertexDataTextured MeshVertexData[] = {}; 

vertexDataTextured ArmandDeBrignac[] = {
    {/*v:*/{-0.979979, -2.383373, -1.142941}, /*n:*/{0.000000, -0.725242, -0.688467}, /*t:*/{0.794971, 0.247112}},
    {/*v:*/{-0.859054, -2.367034, -0.829303}, /*n:*/{0.023591, -0.999512, 0.019593}, /*t:*/{0.786435, 0.224949}},
    {/*v:*/{-1.056731, -2.383373, -1.142941}, /*n:*/{-0.337657, -0.631642, -0.697836}, /*t:*/{0.800393, 0.247114}},
    {/*v:*/{-0.979979, -2.117816, -1.142941}, /*n:*/{0.000000, 0.500198, -0.865902}, /*t:*/{0.645127, 0.391262}},
    {/*v:*/{-0.979979, -2.383373, -1.142941}, /*n:*/{0.000000, -0.725242, -0.688467}, /*t:*/{0.663889, 0.391205}},
    {/*v:*/{-1.056731, -2.383373, -1.142941}, /*n:*/{-0.337657, -0.631642, -0.697836}, /*t:*/{0.663906, 0.396627}},
    {/*v:*/{-0.993670, -2.036772, 0.915066}, /*n:*/{-0.771722, 0.588244, 0.241585}, /*t:*/{0.293949, 0.430232}},
};


@interface FlaschenManager : NSObject

-(void) getFlaschenID: (NSString* ) Name andTexture: (NSString*) path;

@end

和我的.m文件

@implementation FlaschenManager

-(void) getFlaschenID: (NSString* ) Name andTexture: (NSString*) path
{

    if ([Name isEqualToString:@"ArmandDeBrignac"])
    {
        NSLog(@"%@",Name);

        MeshVertexData[0].vertex.v[0]=ArmandDeBrignac[0].vertex.v[0];
      //  MeshVertexData[] = ArmandDeBrignac[];

    } else if ([Name isEqualToString:@"Hennessy"])
    {
        NSLog(@"%@ ", Name);
        FlaschenName = Name;
    }
} 
@end

1 个答案:

答案 0 :(得分:0)

也许尝试这样的事情

vertexDataTextured ArmandDeBrignac[] = {
    {/*v:*/GLKVertex3Make(-0.979979, -2.383373, -1.142941), /*n:*/GLKVertex3Make(-0.979979, -2.383373, -1.142941), /*t:*/GLKVertex2Make(-0.979979, -2.383373)
}

你也可能想宁愿去

MeshVertexData[0].vertex = ArmandDeBrignac[0].vertex;

如果您尝试访问顶点的索引0,则使用其xyz组件

MeshVertexData[0].vertex.x = ArmandDeBrignac[0].vertex.x;

根本没有对此进行过测试,但这是一个建议