Log in or register to post comments

can' replace teapot with banana

October 11, 2013 - 12:15am #1

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

May 11, 2014 - 4:41am #4

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);

So, Now i can see my model 3D correctly in my frame marker.

 

can' replace teapot with banana

May 9, 2014 - 12:54pm #3

Hi!

i have a problem when i try to change the 3D letter model (Frame marker sample) in my own simply 3D model to prove. I have created my model with Blender, exported to .obj with some options active like Triangulate, Normals, ... . Then, i used the script perl obj2opengl.pl to change mymodel3d.obj to mymodel3d.h. 

Show the .h file i know that don't appear the array of index so i have to pay attention in glDrawArrays call.

i created mymodel3d.java ,because i am using Java Native, configuring this file with the arrays in .h file. I try to follow the file QObject.java.

But i have a problem with call glDrawArrays. My code is:

GLES20.glDrawElements(GLES20.GL_TRIANGLES, 0, numVertices);

when "numVertices"  is declared several instructions up like:

numVertices = mymodel3d.getNumObjectVertex();

The error that eclipse show me is: 

The method glDrawElements(int, int, int, int) in the type GLES20 is not applicable for the arguments (int, int, int)

i need help with this!!

 

Thanks so much!

can' replace teapot with banana

October 11, 2013 - 1:47am #2

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, 

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.vertices);

glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.normals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.texCoords);
 
with:
 
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) bananaVerts);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) bananaNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) bananaTexCoords);

 

Log in or register to post comments