예제 #1
0
    def draw_board(self):
        LW, LH = config.LW, config.LH
        glPolygonOffset(1.0, 0.2)
        glEnable(GL_POLYGON_OFFSET_FILL)

        # Draw the gray table
        if 'bg' in config.__dict__:
            glBegin(GL_QUADS)
            glColor(0.2, 0.2, 0.2, 1)
            for x, y, z in config.bg['boundptsM']:
                glVertex(x, y, z)
            glEnd()

        glPushMatrix()
        glMultMatrixf(np.linalg.inv(self.modelmat).transpose())
        glScale(LW, LH, LW)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glPushMatrix()
        glTranslate(*config.bounds[0])
        blockdraw.draw()
        glPopMatrix()

        # Draw the shadow blocks (occlusions)
        glDisable(GL_POLYGON_OFFSET_FILL)

        # Draw the axes for the model coordinate space
        glLineWidth(3)
        glBegin(GL_LINES)
        glColor3f(1, 0, 0)
        glVertex3f(0, 0, 0)
        glVertex3f(1, 0, 0)
        glColor3f(0, 1, 0)
        glVertex3f(0, 0, 0)
        glVertex3f(0, 1, 0)
        glColor3f(0, 0, 1)
        glVertex3f(0, 0, 0)
        glVertex3f(0, 0, 1)
        glEnd()

        # Draw a grid for the model coordinate space
        if self.flag_drawgrid:
            glLineWidth(1)
            glBegin(GL_LINES)
            GR = config.GRIDRAD / 2
            glColor3f(1.0, 1.0, 1.0)
            for j in range(0, 1):
                for i in range(-GR, GR + 1):
                    glVertex(i, j, -GR)
                    glVertex(i, j, GR)
                    glVertex(-GR, j, i)
                    glVertex(GR, j, i)
            glEnd()
            glPopMatrix()
            pass
        glLineWidth(1)
예제 #2
0
    def draw_board(self):
        LW,LH = config.LW, config.LH
        glPolygonOffset(1.0,0.2)
        glEnable(GL_POLYGON_OFFSET_FILL)

        # Draw the gray table
        if 'bg' in config.__dict__:
            glBegin(GL_QUADS)
            glColor(0.2,0.2,0.2,1)
            for x,y,z in config.bg['boundptsM']:
                glVertex(x,y,z)
            glEnd()

        glPushMatrix()
        glMultMatrixf(np.linalg.inv(self.modelmat).transpose())
        glScale(LW,LH,LW)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
        glPushMatrix()
        glTranslate(*config.bounds[0])
        blockdraw.draw()
        glPopMatrix()

        # Draw the shadow blocks (occlusions)
        glDisable(GL_POLYGON_OFFSET_FILL)

        # Draw the axes for the model coordinate space
        glLineWidth(3)
        glBegin(GL_LINES)
        glColor3f(1,0,0); glVertex3f(0,0,0); glVertex3f(1,0,0)
        glColor3f(0,1,0); glVertex3f(0,0,0); glVertex3f(0,1,0)
        glColor3f(0,0,1); glVertex3f(0,0,0); glVertex3f(0,0,1)
        glEnd()

        # Draw a grid for the model coordinate space
        if self.flag_drawgrid:
            glLineWidth(1)
            glBegin(GL_LINES)
            GR = config.GRIDRAD/2
            glColor3f(1.0,1.0,1.0)
            for j in range(0,1):
                for i in range(-GR,GR+1):
                    glVertex(i,j,-GR); glVertex(i,j,GR)
                    glVertex(-GR,j,i); glVertex(GR,j,i)
            glEnd()
            glPopMatrix()
            pass
        glLineWidth(1)
def draw_blocks():
    with opengl_state():
        glMultMatrixf(np.linalg.inv(preview.modelmat).transpose())
        LH,LW = config.LH, config.LW
        glScale(LW,LH,LW)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
        glPushMatrix()
        glTranslate(*config.bounds[0])
        blockdraw.draw()
        glPopMatrix()

        # Draw the axes for the model coordinate space
        glLineWidth(3)
        glBegin(GL_LINES)
        glColor3f(1,0,0); glVertex3f(0,0,0); glVertex3f(1,0,0)
        glColor3f(0,0,1); glVertex3f(0,0,0); glVertex3f(0,0,1)
        glEnd()