The Log.i call just outputs to the debug log for android, so I can see what my code's doing

this part:

if (this.texture.equals("none")) {

works perfectly! I can tell by viewing the output log, and all the AcObjects that don't have textures report "NO TEXTURE TO LOAD"

However...

When I attempt to Draw, I use the following code:

public void draw(GL10 gl, int filter) {
// Bind the texture according to the set texture filter
if(!this.texture.equals("none"))
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[filter]);

The condition:

if(!this.texture.equals("none"))

Always evaluates false and the ! flips it to true. Note that, from the time the texture is attempted to load, the model is already done loading, and nothing would / should modify the this.texture at all.

Further, if I print the this.texture to the log, it prints "none"

so I KNOW that this.texture DOES equal "none" because I print it to the log... yet this always evaluates as !(false)

Re: .equals is broken ... not working as expected

Posted 29 November 2010 - 11:10 AM

What does this show you:

...
public void draw(GL10 gl, int filter) {
// NOTE ALL NORMALS CODE COMMENTED OUT, UNTIL I PROGRAM NORMAL
// CALCULATOR
/*
* THIS LINE DOESN'T WORK, this.texture.equals("none") always is false,
* yet on line 428 it works perfectly... P.S: this area is kind of messy
* with the multiple if conditions, but this is a work in progress and I
* can fix that later
*/
Log.i("AcLoader", ">>>> In Draw(): this.texture = "
+ this.texture
+ ", Length = "
+ this.texture.length());
// Bind the texture according to the set texture filter
if (!this.texture.trim().equals("none")) { // added .trim()
...

Re: .equals is broken ... not working as expected

Posted 29 November 2010 - 06:06 PM

n8wxs, on 29 November 2010 - 10:10 AM, said:

What does this show you:

...
public void draw(GL10 gl, int filter) {
// NOTE ALL NORMALS CODE COMMENTED OUT, UNTIL I PROGRAM NORMAL
// CALCULATOR
/*
* THIS LINE DOESN'T WORK, this.texture.equals("none") always is false,
* yet on line 428 it works perfectly... P.S: this area is kind of messy
* with the multiple if conditions, but this is a work in progress and I
* can fix that later
*/
Log.i("AcLoader", ">>>> In Draw(): this.texture = "
+ this.texture
+ ", Length = "
+ this.texture.length());
// Bind the texture according to the set texture filter
if (!this.texture.trim().equals("none")) { // added .trim()
...

Re: .equals is broken ... not working as expected

Posted 29 November 2010 - 06:48 PM

Okay so it works now (thanks to n8wxs!) BUT the original condition still exists for different reasons.
Allow me to explain...

If you look at the code for the draw method, it should only use textures, if there is a texture available. Otherwise, it should just display polygons with no texture (I was planning on implementing colors / materials later)

I rewrote the Draw method to be a little clearer.
As it turns out, the .equals IS working now, but the OpenGL ES still displays the textures. Because these triangles are are untextured surfaces, all their UV coordinates are 0, 0. This means OpenGL tries to sample from one 0-width, 0-height pixel from the corner of the texture image, and stretch it over the entire polygon (triangle). OpenGL doesn't expect all corners to overlap on 0,0 so it goes haywire and textures start flickering everywhere, even though textures should only be displayed if they are available.

It should display solid white if there is no texture, as I never actually set the GL color. For whatever reason, its still drawing the only-loaded texture over all polygons that have no texture, causing a really weird tweak-out / flickery distortion on all those polygons.

It was this behavior that let me to originally think the .equals was broken, even after n8wxs's help... it's still drawing textures when I DON'T call