Domanda

i am new to the cocos2d/3d ,i want to draw cylinder but for understanding the functionality i am trying to Load a meshnode of a triangle in cocos3d with help of this link, but i am getting warning Incompatible pointer types sending 'CC3MeshNode *' to parameter of type 'CCNode *' and application crashing with below error.

please forgive for my english.

2013-03-19 12:43:49.195 LipAgumentation[982:d503] -[CC3MeshNode _setZOrder:]: unrecognized selector sent to instance 0xc44cce0

2013-03-19 12:43:49.203 LipAgumentation[982:d503] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CC3MeshNode _setZOrder:]: unrecognized selector sent to instance 0xc44cce0'

*** Call stack at first throw:
(
0   CoreFoundation                      0x019335a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x0161b313 objc_exception_throw + 44
2   CoreFoundation                      0x019350bb -[NSObject(NSObject)     
 doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x018a4966 ___forwarding___ + 966
4   CoreFoundation                      0x018a4522 _CF_forwarding_prep_0 + 50
5   LipAgumentation                     0x0003d574 -[CCNode insertChild:z:] + 532
6   LipAgumentation                     0x0003cb25 -[CCNode addChild:z:tag:] + 501
7   LipAgumentation                     0x0003ce39 -[CCNode addChild:] + 313
8   LipAgumentation                     0x0020754d -[LipAgumentationLayer  
LoadMeshOfATriangle] + 1405
9   LipAgumentation                     0x00206fbd -[LipAgumentationLayer LipsEffect] + 45
10  LipAgumentation                     0x00206d3f __42-[LipAgumentationLayer  
initializeControls]_block_invoke_0 + 47
11  LipAgumentation                     0x00023b70 -[NSObject(CCBlocksAdditions)  
ccCallbackBlockWithSender:] + 48
12  CoreFoundation                      0x018a3c7d __invoking___ + 29
13  CoreFoundation                      0x018a3b51 -[NSInvocation invoke] + 145
14  LipAgumentation                     0x0003678f -[CCMenuItem activate] + 79
15  LipAgumentation                     0x00036ff0 -[CCMenuItemLabel activate] + 160
16  LipAgumentation                     0x00033e94 -[CCMenu ccTouchEnded:withEvent:] + 292
17  LipAgumentation                     0x00089c3a -[CCTouchDispatcher  
touches:withEvent:withTouchType:] + 1482
18  LipAgumentation                     0x0008a783 -[CCTouchDispatcher  
touchesEnded:withEvent:] + 115
19  LipAgumentation                     0x0008c53e -[EAGLView touchesEnded:withEvent:] + 110
20  UIKit                               0x009a3ded -[UIWindow _sendTouchesForEvent:] + 567
21  UIKit                               0x00984c37 -[UIApplication sendEvent:] + 447
22  UIKit                               0x00989f2e _UIApplicationHandleEvent + 7576
23  GraphicsServices                    0x02248992 PurpleEventCallback + 1550
24  CoreFoundation                      0x01914944  
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
25  CoreFoundation                      0x01874cf7 __CFRunLoopDoSource1 + 215
26  CoreFoundation                      0x01871f83 __CFRunLoopRun + 979
27  CoreFoundation                      0x01871840 CFRunLoopRunSpecific + 208
28  CoreFoundation                      0x01871761 CFRunLoopRunInMode + 97
29  GraphicsServices                    0x022471c4 GSEventRunModal + 217
30  GraphicsServices                    0x02247289 GSEventRun + 115
31  UIKit                               0x0098dc93 UIApplicationMain + 1160
32  LipAgumentation                     0x00205ed6 main + 134
33  LipAgumentation                     0x00002bb5 start + 53
)

terminate called throwing an exception

here is my code to draw triangle

    static float arr_location[] = {-1.0,0.0,0.0,  1.0,0.0,0.0,  0.0,1.0,0.0};
static float arr_normal[] = {0.0,0.0,1.0, 0.0,0.0,1.0, 0.0,0.0,1.0};
static ushort arr_indice[] = {0,1,2};
static float arr_texture[] = {1.0,0.0, 0.0,0.0, 0.0,1.0};

CC3VertexLocations *locationDemo = 
           [[CC3VertexLocations vertexArrayWithName:@"demoLocation"] autorelease];
locationDemo.drawingMode = GL_TRIANGLES;
[locationDemo setVertexCount:3];
[locationDemo setVertices:arr_location];

CC3VertexNormals *demonormal = 
        [[CC3VertexNormals vertexArrayWithName:@"demoNormal"] autorelease];
[demonormal setVertexCount:3];
[demonormal setVertices:arr_normal];

CC3VertexIndices *demoIndices = [CC3VertexIndices vertexArrayWithName: @"demoIndicies"];
demoIndices.drawingMode = GL_TRIANGLES;
[demoIndices setVertexCount:3];
[demoIndices setVertices:arr_indice];

CC3Texture *demoTex;
demoTex = [[CC3Texture textureFromFile:@"2.jpg"] autorelease];

CC3VertexTextureCoordinates *demoTexture = 
       [CC3VertexTextureCoordinates vertexArrayWithName:@"demoTexture"];
[demoIndices setVertexCount:3];
[demoIndices setVertices:arr_texture];

[demoTexture alignWithTexture:demoTex];

CC3VertexArrayMesh *demoMeshModel = 
    [[CC3VertexArrayMesh meshWithName:@"demoMeshModel"] autorelease];
demoMeshModel.vertexLocations = locationDemo;
demoMeshModel.vertexNormals = normal;
demoMeshModel.vertexIndices = demoIndices;
demoMeshModel.vertexTextureCoordinates = demoTexture;

CC3MeshNode* demoMesh = [CC3MeshNode nodeWithName:@"demoMeshNode"];
demoMesh.mesh = demoMeshModel;
demoMesh.material = [CC3Material shiny];
demoMesh.material.name = [NSString stringWithFormat: @"demoMeshNode"];
demoMesh.material.diffuseColor = CCC4FMake(1.0, 1.0, 1.0, 1.0);
[demoMesh.material setTexture:demoTex];

[self addChild:demoMesh];
È stato utile?

Soluzione

I have read the http://brenwill.com/docs/cocos3d/0.6.2/api/interface_c_c3_node.html documentation, and you have to use a CC3Node base class in order to use CC3MeshNode.

I'm pretty sure "self" is a CCNode type and not a CC3Node base class as expected.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top