2013-02-01 131 views
-2

您好朋友我想繪製2d圖像上的網格,如下圖所示,下面給出了代碼,但應用程序崩潰,沒有顯示錯誤消息...因此難以識別問題。在2D圖像上繪製網格cocos3d

float arr_location[] = {0.0,0.0,0.0, 0.0,1.0, 0.0, 1.0,1.0,0.0, 1.0,0.0,0.0}; 

CC3VertexLocations* Vlocation = 
    [[CC3VertexLocations vertexArrayWithName:@"demoLocation"] retain]; 
Vlocation.drawingMode = GL_TRIANGLES;// 
Vlocation.vertexCount = 3; 
Vlocation.vertices = arr_location; 

    float arr_normal[] = {0.0,0.0,-1.0}; 
CC3VertexNormals* normal = [[CC3VertexNormals vertexArrayWithName:@"demoNormal"] retain]; 
normal.vertexCount = 1; 
normal.vertices = arr_normal; 

    float arr_indice[] = {0,1,2}; 
CC3VertexIndices* demoIndices = [CC3VertexIndices vertexArrayWithName: @"demoIndicies"]; 
demoIndices.drawingMode = GL_TRIANGLES; 
demoIndices.vertexCount = 3; 
demoIndices.vertices = arr_indice; 

CC3VertexArrayMesh* demoMeshModel = 
    [[CC3VertexArrayMesh meshWithName:@"demoMeshModel"] retain]; 
demoMeshModel.vertexLocations = Vlocation; 
demoMeshModel.vertexNormals = normal; 
demoMeshModel.vertexIndices = demoIndices; 

CC3PlaneNode *meshNode = [[CC3PlaneNode alloc] init]; 
meshNode.mesh = demoMeshModel; 
meshNode.material = [CC3Material shiny]; 
meshNode.texture = [CC3Texture textureFromFile: @"2.jpg"]; 

[self addChild: meshNode]; 

Refrence image

Crash SnapShot

回答

0

我不認爲這是可能的cocos2d的,看起來像3D實際上,你可以用OpenGL ES的做到這一點是肯定的,雖然我不知道如何到目前爲止,還沒有在這麼低的水平上工作,但如果你可以使用cocos3d,那麼使用CC3PlaneNode並將圖片設置爲紋理非常簡單。我建議您閱讀the programming guide並再次詢問您是否還有其他問題。