Thread: Culling polys by texture name.

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

    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.
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  2. #2
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    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.
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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,071
    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*
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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, 01:08 PM
  2. D3d Texture Wrapper == ARRRGGGGHHH
    By yaya in forum Game Programming
    Replies: 1
    Last Post: 03-25-2009, 06: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-24-2006, 11:06 PM
  5. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM