Exemplo n.º 1
0
    def initialize(self):
        glutPositionWindow(0, 600)
        GLRealtimeProgram.initialize(self)

        colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (0, 1, 1), (1, 0, 1)]

        for (i, cloud) in enumerate(self.clouds):
            point_list = glGenLists(i + 1)
            self.point_lists.append(point_list)

            # compile the point cloud
            glNewList(point_list, GL_COMPILE)
            glDisable(GL_LIGHTING)
            glBegin(GL_POINTS)
            for point in cloud:
                if len(point) == 2:
                    xyz = point[0]
                    rgb = point[1]
                else:
                    xyz = point[:3]
                    if len(point) == 4:
                        rgb = point[3]
                    elif len(point) > 4:
                        rgb = point[3:6]
                    else:
                        rgb = None

                if rgb is not None:
                    glColor3f(*map(lambda x: x / 255.0, rgb))
                else:
                    glColor3f(*colors[i % len(colors)])
                glVertex3f(*xyz[:3])
            glEnd()
            glEndList()
            logging.debug("compiled {} points for cloud {}".format(len(cloud), i))
Exemplo n.º 2
0
 def initialize(self):
     glutPositionWindow(0, 600)
     GLRealtimeProgram.initialize(self)