Help with chessboard sample

I’m making a dummy window gui, using the chessboard sample as a basis for the collision detection. I’ve hit a strange problem though.

This is the offending section of code:

    #Set the model itself to be collideable with the ray. If this model was
    #any more complex than a single polygon, you should set up a collision
    #sphere around it instead. But for single polygons this works fine.
    self.windowlist[self.windows].face.find("**/polygon").node().setIntoCollideMask(
      BitMask32.bit(1))
    #Set a tag on the square's node so we can look up what square this is
    #later during the collision pass
    self.windowlist[self.windows].face.find("**/polygon").node().setTag('square', str(self.windows))

It’s been slightly modified to look through the faces of each window in the list. It works fine as long as I use the original model of a square that came with the Chessboard demo. But if I use my own model (Which is also just a simple square I made in Blender) then the “find” function returns empty.

I can post all the code if necessary. I just need to know what is the difference between their square and the square I made, or if there’s a different way to do this that would get around this problem?

The find function returns a nodepath for a mesh with a specific name.
Give the plane the name “polygon” in blender and it will work.

Okay I tried this and the code is running now, however, when I use the traversal section, it’s always empty.

Here’s the new code for making a window

  def createWindow(self):
    self.window = Window()
    self.window.face.setX(1.0*self.windows/5)
    self.window.face.setY(1.0*self.windows/5)
    self.window.face.setZ(1.0*self.windows*.01)
    self.window.face.reparentTo(self.winRoot)
    self.windowlist.append(self.window)
      
    #Set the model itself to be collideable with the ray. If this model was
    #any more complex than a single polygon, you should set up a collision
    #sphere around it instead. But for single polygons this works fine.
    self.windowlist[self.windows].face.find("**/Plane").node().setIntoCollideMask(
      BitMask32.bit(1))
    #Set a tag on the square's node so we can look up what square this is
    #later during the collision pass
    self.windowlist[self.windows].face.find("**/Plane").node().setTag('square', str(self.windows)) 
    print "DONE"                                          
      
    self.windows = self.windows + 1    

“Plane” is the name of the polygon, and placing a print in front of those find statements verifies that it’s working. “Face” is the specific part of window object that is being used.

Here is the code used for traversal, taken almost verbatim from the chessboard sample:

      #Do the actual collision pass (Do it only on the squares for
      #efficiency purposes)
      self.picker.traverse(self.winRoot)

      if self.pq.getNumEntries() > 0:
        #if we have hit something, sort the hits so that the closest
        #is first, and highlight that node
        self.pq.sortEntries()
        i = int(self.pq.getEntry(0).getIntoNode().getTag('square'))
        #Set the highlight on the picked square
        self.windowlist[i].face.setColor(HIGHLIGHT)
        self.hiSq = i

I know that this if statement is being reached, but self.pq.getNumEntries() seems to be <= 0 because it never enters the if-statement.

This is driving me nuts. It was actually working fine, highlighting the windows and everything, then I made a few changes and it stopped working, and I can’t revert back, despite all the changes I thought I made being undone. I’m starting to suspect it’s one of those notorious typos (like a missing semi-colon) of an error. I’m feeling really stupid right now for not backing this up, so I apologize for this foolishness. Thanks in advance for any help :slight_smile:

Here’s the full code and models if anyone thinks they can help.
filefactory.com/file/33d805/