Log in or register to post comments

The Banana... that sodding banana!

November 14, 2011 - 4:37am #1

Hi guys,

I am trying to display the banana model. I have imported the model and changed the code relevant code to:


glVertexPointer(3, GL_FLOAT, 0, bananaVerts);
glNormalPointer(GL_FLOAT, 0, bananaNormals);
glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords);

glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);

I have change the texture so banana.jpg. When I do my image recognition I see just crazy flashes of yellow, it's displaying something but it's sure as hell not a banana. Any ideas?

Re: The Banana... that sodding banana!

January 10, 2012 - 4:42am #13

Thanks so much :)

It works fine!!!!

Re: The Banana... that sodding banana!

January 10, 2012 - 2:06am #12

I got the castle from here http://www.turbosquid.com/FullPreview/Index.cfm/ID/552087

It's a good resource. I had to flip the texture to get it to work properly.

Re: The Banana... that sodding banana!

January 9, 2012 - 3:32pm #11

HI,

Please, can you send me the castle .obj and its flat texture .jpg to test my app. My email is

. Thanks in advance. :)

Re: The Banana... that sodding banana!

January 9, 2012 - 5:52am #10

That is also correct although it doesn't fix the issues described above for me.

Re: The Banana... that sodding banana!

December 9, 2011 - 2:04pm #9

I don't know if this will help you guys, but I resized my texture to 256x256 and it worked perfectly, the dimensions probably need to be multiple of 2, like: 32x32, 64x64, 128x128... I'm just guessing, can anyone confirm it?

Re: The Banana... that sodding banana!

November 24, 2011 - 4:58am #8

As I said. Once I had the banana showing I tried to load my castle model. The texture was incorrect but was fixed by flipping the texture vertically.

Re: The Banana... that sodding banana!

November 24, 2011 - 4:29am #7

Hi, garyriches:)
I have a same problem with you like a banana.
So I just use one colored texture.
How to do the mapping of the castle, it's awesome for me.
Can you give me a hint, plz~

Re: The Banana... that sodding banana!

November 24, 2011 - 2:30am #6

Thanks MoSR, having broken down the texture in to coloured quads everything seems to be ok. I had already flipped the banana skin and it didn't look perfect. I then tried loading my castle model and flipped that texture and low and behold... it worked!

I have since come to the conclusion that maybe the banana isn't textured 100% correctly, can anyone confirm this?

Here are the results

Re: The Banana... that sodding banana!

November 23, 2011 - 8:55am #5

Try using a texture with 4 different coloured quadrants - it may help you understand where the texture coordinate mapping is wrong.

Re: The Banana... that sodding banana!

November 23, 2011 - 5:38am #4

Thanks I tried that and whilst the opposite half looked better the other half (that used to look ok-ish) looked worse.

I have also loaded a 3d castle model and the texture doesn't seem to it correctly on that either. It's a flat texture, 1024 x 1024.

I resized the texture down to that from 4000 x 4000. I checked if I needed to regenerate the texture coords but it seemed I didn't.

Is there some way of specifying different types of mapping?

Re: The Banana... that sodding banana!

November 23, 2011 - 5:34am #3

Try flipping the texture image vertically.

- Kim

Re: The Banana... that sodding banana!

November 22, 2011 - 8:01am #2

Ok, so I managed to display the banana using:

[PHP" /> glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaVerts[0" />);

glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &bananaNormals[0" />);

glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &bananaTexCoords[0" />);

glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, [thisTexture textureID" />);

glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0" /> );

glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);[/PHP" />

The key was setting kObjectScale to 150 as the banana was showing, but too small to actually see.

The issue I have now is the texture mapping is wrong, it doesn't fit to the banana.

A screen shot is here

My EAGLView.mm is here

Any ideas why?

Log in or register to post comments