I used Blender for create 3D modal. I created .obj file and converted to .h file but .h file having only glVertexPointer, glDrawArrays. I used .png image file. But when image is tracking the 3D modal doesn't displays proper. It's some what black color. I replaced code in EAGLView.mm is:
- (void) setup3dObjects
{
for (int i=0; i < [textures count]; i++)
{
Object3D *obj3D = [[Object3D alloc] init];
obj3D.numVertices = STRAPPNumVerts;
obj3D.vertices = STRAPPVerts;
obj3D.normals = nil;
obj3D.texCoords = nil;
obj3D.numIndices = 0;
obj3D.indices = nil;
obj3D.texture = [textures objectAtIndex:i];
[objects3D addObject:obj3D];
[obj3D release];
}
}
In renderFrame:
glVertexPointer(3, GL_FLOAT, 0, STRAPPVerts);
glDrawArrays(GL_TRIANGLES, 0, STRAPPNumVerts);
and
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) STRAPPVerts);
glDrawArrays(GL_TRIANGLES, 0, STRAPPNumVerts);
where i did mistake?
Attachment | Size |
---|---|
![]() | 173.41 KB |
Since you only have vertices, but no texture coordinates, your mesh will be rendered black, unless you change the code in the fragment Shader.
Perhaps you may want to consider using Unity rather than programming natively ? as this would make your life much easier when it comes to rendering 3D models...