I downloaded banana.h file from http://heikobehrens.net/2009/08/27/obj2opengl/. I included .h file. I replaced like this in EAGLView.mm file:
namespace {
// Teapot texture filenames
const char* textureFilenames[] = {
"banana.jpg",
/*
"TextureTeapotBrass.png",
"TextureTeapotBlue.png",
"TextureTeapotRed.png"
*/
}/
/ Model scale factor
const float kObjectScale = 3.0f;
}
- (void) setup3dObjects
{
// build the array of objects we want drawn and their texture
// in this example we have 3 targets and require 3 models
// but using the same underlying 3D model of a teapot, differentiated
// by using a different texture for each
for (int i=0; i < [textures count]; i++)
{
Object3D *obj3D = [[Object3D alloc] init];
// obj3D.numVertices = NUM_TEAPOT_OBJECT_VERTEX;
obj3D.numVertices =bananaNumVerts;
obj3D.vertices = bananaVerts;
obj3D.normals = bananaNormals;
obj3D.texCoords = bananaTexCoords;
obj3D.numIndices = 0;
obj3D.indices = nil;
obj3D.texture = [textures objectAtIndex:i];
[objects3D addObject:obj3D];
[obj3D release];
}
}
In renderFrame replaced:
glVertexPointer(3, GL_FLOAT, 0, bananaVerts);
glNormalPointer(GL_FLOAT, 0, bananaNormals);
glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords);
glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);
Where i did mistake.
can' replace teapot with banana
Two issues:
first, you need to increase the kObjectScale for the banana mesh, try using 100.0f instead of 3.0f, otherwise it will be too small to be visible.
second, you need to replace the OpenGL ES 2.0 code,
can' replace teapot with banana
Hi!
can' replace teapot with banana
Hi!!
i have found the solution about my error. Sorry, because i don't pay attention that when there isn't an array of index the method that i have to use is glDrawArrays instead of glDrawElements. The new line is:
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, numVertices);