I'm loading a 3D Skeleton model (exported from Blender) using Cocos3D but got the following assertion:
*** Assertion failure in -[CC3OpenGLES2IOS drawIndicies:ofLength:andType:as:], /Users/phamdacloc/Downloads/xxx/cocos3d201/Projects/CC3HelloWorld/cocos3d/cocos3d/OpenGL/CC3OpenGL.m:282
Here's where the assert came from:
-(void) drawIndicies: (GLvoid*) indicies ofLength: (GLuint) len andType: (GLenum) type as: (GLenum) drawMode {
#if CC3_OGLES
CC3Assert((type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_BYTE),
@"OpenGL ES permits drawing a maximum of 65536 indexed vertices, and supports only"
@" GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE types for vertex indices");
#endif
glDrawElements(drawMode, len, type, indicies);
LogGLErrorTrace(@"glDrawElements(%@, %u, %@, %p)", NSStringFromGLEnum(drawMode), len, NSStringFromGLEnum(type), indicies);
CC_INCREMENT_GL_DRAWS(1);
}
From the message above, my understanding is that the model is too detailed and contains more vertices than allowed (65536). I then removed all the spinal cords, head, legs and this time Cocos3D loads successfully. Is there a way to keep all these vertices or should I split the models into several .pod files?
On a side note, when I open the skeleton.blend file in "Object Mode", I see 205,407 vertices at the top right of Blender. However, when I changed from "Object Mode" to "Edit Mode" and select all the vertices, only 33,574 + 4,773 = 38,347 vertices were present. Why does "Object Mode" shows more vertices than "Edit Mode"?
If you're ok with a certain amount of device/platform dependence, most reasonably recent devices support the OES_element_index_uint extension. This adds support for indices of type GL_UNSIGNED_INT
, on top of the types GL_UNSIGNED_SHORT
and GL_UNSIGNED_BYTE
types supported by base ES 2.0.
On iOS, which you seem to be using, this extension is supported by all SGX Series 5, A7, and A8 GPUs (source: https://developer.apple.com/library/ios/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/OpenGLESPlatforms/OpenGLESPlatforms.html). I would expect support for this extension to also be present on Android devices of a similar age.
With 32-bit indices, your memory will run out long before you exhausted the index range.
If you want to get this working with pure ES 2.0 functionality, you pretty much have to split up your model into smaller parts. At least I can't think of a reasonable alternative.