2013-04-16 172 views
0

我嘗試將vertexDataTexture ArmandDeBrignac []數組的內容複製到vertexDataTextured MeshVertexData []數組中。但它不工作....我認爲問題是在結構方法中,有GLK向量元素.....?複製結構數組到另一個結構數組(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 

回答

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; 

沒有測試此可言,但它的一個建議

+0

謝謝您的回答! 現在它可以複製元素! 但有一個新的問題,如果我複製上述代碼在我的項目中,我得到一個ARC語義問題失敗....與另一個數組?... 因爲我不分配內存我的新結構數組? –

+0

您可能需要使用'sizeof()'然後malloc新數組來查找結構的大小,然後將值 – Fonix

相關問題