Added drawing to QuadTree
return o
else:
return None
+
+
+ def draw(self, rect = None):
+ glColor3f(1.0, 1.0, 1.0)
+ glBegin(GL_LINE_LOOP)
+ glVertex3f(self.bbox.left, self.bbox.top, 0)
+ glVertex3f(self.bbox.right, self.bbox.top, 0)
+ glVertex3f(self.bbox.right, self.bbox.bottom, 0)
+ glVertex3f(self.bbox.left, self.bbox.bottom, 0)
+ glEnd()
+
+ for (r, o) in self.rects:
+ if rect and r.colliderect(rect):
+ glColor3f(1.0, 1.0, 0.0)
+ else:
+ glColor3f(0.0, 0.0, 1.0)
+ glBegin(GL_LINE_LOOP)
+ glVertex3f(r.left, r.top, 0)
+ glVertex3f(r.right, r.top, 0)
+ glVertex3f(r.right, r.bottom, 0)
+ glVertex3f(r.left, r.bottom, 0)
+ glEnd()
+
+ if self.subregions:
+ for s in self.subregions:
+ s.draw(rect)
+
+ if rect:
+ glColor3f(1.0, 0.0, 0.0)
+ glBegin(GL_LINE_LOOP)
+ glVertex3f(rect.left, rect.top, 0)
+ glVertex3f(rect.right, rect.top, 0)
+ glVertex3f(rect.right, rect.bottom, 0)
+ glVertex3f(rect.left, rect.bottom, 0)
+ glEnd()