Culling polys by texture name.

This is a discussion on Culling polys by texture name. within the Game Programming forums, part of the General Programming Boards category; Ok, this one has me completely stumped. I'm trying to cull polys based on their texture name. More specifically, I'm ...

  1. #1
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070

    Culling polys by texture name.

    Ok, this one has me completely stumped. I'm trying to cull polys based on their texture name. More specifically, I'm loading a Quake 3 BSP, and I want keep the renderer from drawing any faces that use the texture "null.jpg". Seems simple enough. I have something like this:

    Code:
    for(int i=0; i<numQ3bspFaces; i++){
     Q3BSPFace *pTri = &q3bspFace[i];
     int materialIndex = pTri->texID;
    
     string::size_type loc = texMgr->textures[q3bspMaterial[materialIndex][0]]->name.find("null");
     if(loc == string::npos){
      //"null" not found, so draw normally
     }
    }
    (not actual code, but the nearly the same thing.

    However, it still draws everything anyway. I have no idea why. I had it working once, but then I tried to change the texture that prevents rendering, and it stopped working again. I've also tried having the if statement use a goto statement, but to no avail.

    Please help. Please tell me i'm just doing something stupid. Because it really doesn't make much sense to me.

    Thanks.

    EDIT: I should also mention that I know that there are faces in the mesh using the texture. In fact, a test mesh I have all use that texture, but it's still rendered.
    Last edited by psychopath; 11-29-2006 at 01:43 PM.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  2. #2
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    Nevermind, I've got it working.

    Rather than checking the texture name at run-time, I check it when the mesh is loaded. If the texture contains "null", it skips loading any textures, and sets the current texture index in a bool array to true. This array is then checked at run-time.

    Not 100% sure why this works, but it's also faster than string checking, so i'm sticking with it anyway.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    It works b/c you set the texture member to NULL in the constructor of the mesh class don't you?

    As long as that is NULL then you know you don't have a texture.

  4. #4
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    It works b/c you set the texture member to NULL in the constructor of the mesh class don't you?
    Well, actually i'm not doing that for some reason. But now I set it to NULL if the texture contains "null". Why the hell did I set a value in a different array for this?

    *sighs*
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Dunno. Maybe too much late night coding? Usually is the case for me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. d3d9 c++ texture wrapper... again...
    By yaya in forum Game Programming
    Replies: 0
    Last Post: 04-01-2009, 02:08 PM
  2. D3d Texture Wrapper == ARRRGGGGHHH
    By yaya in forum Game Programming
    Replies: 1
    Last Post: 03-25-2009, 07:41 PM
  3. Replies: 4
    Last Post: 02-27-2008, 03:10 PM
  4. OpenGL - look trough surface -nehe lesson
    By GanglyLamb in forum Game Programming
    Replies: 8
    Last Post: 08-25-2006, 12:06 AM
  5. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 11:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21