示例#1
0
    def render(self):
        s = self.scale
        l = self.length

        startL = -(l / s) / 2
        endL = (l / s) / 2
        startW = -(self.width / s) / 2
        endW = (self.width / s) / 2
        if (self.outLined):
            glBegin(GL_LINES)
            for j in range(startW, endW + 1):
                glVertex3f(startL * s, j * s, 0)
                glVertex3f(endL * s, j * s, 0)
            for i in range(startL, endL + 1):
                glVertex3f(i * s, startW * s, 0)
                glVertex3f(i * s, endW * s, 0)
        else:
            glBegin(GL_QUADS)
            for i in range(startW, endW):
                for j in range(startL, endL):
                    if ((i + j) % 2 == 0):
                        if config.enable_lighting:
                            material.grey()
                        else:
                            glColor3f(0.3, 0.3, 0.3)
                    else:
                        if config.enable_lighting:
                            material.darkgrey()
                        else:
                            glColor3f(0.6, 0.6, 0.6)
                    x0 = i * s
                    y0 = j * s
                    x1 = (i + 1) * s
                    y1 = (j + 1) * s

                    glVertex3f(x0, y0, 0)
                    glVertex3f(x1, y0, 0)
                    glVertex3f(x1, y1, 0)
                    glVertex3f(x0, y1, 0)

                    # todo: draw other walls to make a room
        glEnd()
示例#2
0
 def render(self):
     s = self.scale
     l = self.length
     
     startL =- (l/s)/2
     endL = (l/s)/2
     startW =- (self.width/s)/2
     endW = (self.width/s)/2
     if (self.outLined):
         glBegin(GL_LINES)
         for j in range(startW, endW + 1):
             glVertex3f(startL*s, j*s, 0)
             glVertex3f(endL*s, j*s, 0)
         for i in range (startL, endL + 1):
             glVertex3f(i*s, startW*s, 0)
             glVertex3f(i*s, endW*s, 0)
     else:
         glBegin(GL_QUADS)
         for i in range(startW, endW):
             for j in range(startL, endL):
                 if ((i + j) % 2 == 0):
                     if config.enable_lighting:
                         material.grey()
                     else:
                         glColor3f(0.3, 0.3, 0.3)
                 else:
                     if config.enable_lighting:
                         material.darkgrey()
                     else:
                         glColor3f(0.6, 0.6, 0.6)
                 x0 = i*s
                 y0 = j*s
                 x1 = (i + 1)*s
                 y1 = (j + 1)*s
                 
                 glVertex3f(x0, y0, 0)
                 glVertex3f(x1, y0, 0)
                 glVertex3f(x1, y1, 0)
                 glVertex3f(x0, y1, 0)
                 
                 # todo: draw other walls to make a room
     glEnd()
示例#3
0
    def render(self):
        for link in self.links:
            R = link.R
            P = link.P
            h = link.h

            if config.enable_lighting:
                material.black()
            else:
                glColor3f(0, 0, 0)

            glPushMatrix()
            glLineWidth(15)
            glBegin(GL_LINES)
            if not link.is_prismatic():
                glVertex3f(0, 0, 0)
                glVertex3f(P[0], P[1], P[2])
            else:
                glVertex3f(0, 0, 0)
                glVertex3f(P[0] - link.q * link.h[0],
                           P[1] - link.q * link.h[1],
                           P[2] - link.q * link.h[2])
            glEnd()

            glTranslate(P[0], P[1], P[2])

            if config.enable_axis:
                if link.index != self.N:
                    display.draw_axes(20, str(link.index))
                else:
                    display.draw_axes(20, 'T')

            # draw joint
            if link.is_prismatic():  # prismatic joint
                display.draw_prismatic_joint([[0], [0], [0]], link.q * link.h,
                                             10)
            elif link.is_rotational():
                if config.enable_lighting:
                    material.green()
                else:
                    glColor3f(0, 0.6, 0)
                display.draw_rotational_joint(h * 10, h * -10, 8,
                                              link.q * 180 / PI)
                if config.enable_lighting:
                    material.grey()
                else:
                    glColor3f(0.3, 0.3, 0.3)

                glRotate(link.q * 180 / PI, link.h[0], link.h[1], link.h[2])
            elif (R == eye(3)).all():  # link - no joint
                pass

        # pop all joints off
        for matPop in self.links:
            glPopMatrix()

        glLineWidth(5)
        glPointSize(10)

        # only save the last whatever points
        self.trace = self.trace[-config.max_trace:]

        if config.enable_ghost:
            if config.enable_lighting:
                material.grey()
            else:
                glColor3f(0.4, 0.4, 0.4)

            glPointSize(8)
            for verts, i in zip(self.trace, range(len(self.trace))):
                if i % config.ghost_interval == 1:
                    glBegin(GL_POINTS)
                    for vert in verts:
                        glVertex3f(vert[0], vert[1], vert[2])
                    glEnd()

            if config.enable_lighting:
                material.grey()
            else:
                glColor3f(0.7, 0.7, 0.7)

            for verts, i in zip(self.trace, range(len(self.trace))):
                if i % config.ghost_interval == 1:
                    glBegin(GL_LINE_STRIP)
                    for vert in verts:
                        glVertex3f(vert[0], vert[1], vert[2])
                    glEnd()

        if config.enable_trace:
            # saved tool positions

            if config.enable_lighting:
                material.red()
            else:
                glColor3f(1.0, 0.0, 0)
            glBegin(GL_LINE_STRIP)
            for verts in self.trace:
                vert = verts[-1]
                glVertex3f(vert[0], vert[1], vert[2])
            glEnd()
示例#4
0
    def render(self):
        for link in self.links:
            R = link.R
            P = link.P
            h = link.h
            
            if config.enable_lighting:
                material.black()
            else:
                glColor3f(0, 0, 0)

            glPushMatrix()
            glLineWidth(15)
            glBegin(GL_LINES)
            if not link.is_prismatic():
                glVertex3f(0, 0, 0)
                glVertex3f(P[0], P[1], P[2])
            else:
                glVertex3f(0, 0, 0)
                glVertex3f(P[0]-link.q*link.h[0], P[1] - link.q*link.h[1], P[2] - link.q*link.h[2])
            glEnd()

            glTranslate(P[0], P[1], P[2])
            
            if config.enable_axis:
                if link.index != self.N:
                    display.draw_axes(20, str(link.index))
                else:
                    display.draw_axes(20, 'T')
            
            # draw joint
            if link.is_prismatic(): # prismatic joint
                display.draw_prismatic_joint([[0], [0], [0]], link.q*link.h, 10)
            elif link.is_rotational():
                if config.enable_lighting:
                    material.green()
                else:
                    glColor3f(0, 0.6, 0)
                display.draw_rotational_joint(h*10, h*-10, 8, link.q*180/PI)
                if config.enable_lighting:
                    material.grey()
                else:
                    glColor3f(0.3, 0.3, 0.3)
                
                glRotate(link.q * 180 / PI, link.h[0], link.h[1], link.h[2])
            elif (R == eye(3)).all(): # link - no joint
                pass

        # pop all joints off
        for matPop in self.links:
            glPopMatrix()

        glLineWidth(5)
        glPointSize(10)
        
        # only save the last whatever points
        self.trace = self.trace[-config.max_trace:]

        if config.enable_ghost:
            if config.enable_lighting:
                material.grey()
            else:
                glColor3f(0.4, 0.4, 0.4)
            
            glPointSize(8)
            for verts, i in zip(self.trace, range(len(self.trace))):
                if i % config.ghost_interval == 1:
                    glBegin(GL_POINTS)
                    for vert in verts:
                        glVertex3f(vert[0], vert[1], vert[2])
                    glEnd()

            if config.enable_lighting:
                material.grey()
            else:
                glColor3f(0.7, 0.7, 0.7)
            
            for verts, i in zip(self.trace, range(len(self.trace))):
                if i % config.ghost_interval == 1:
                    glBegin(GL_LINE_STRIP)
                    for vert in verts:
                        glVertex3f(vert[0], vert[1], vert[2])
                    glEnd()
        
        if config.enable_trace:
            # saved tool positions

            if config.enable_lighting:
                material.red()
            else:
                glColor3f(1.0, 0.0, 0)
            glBegin(GL_LINE_STRIP)
            for verts in self.trace:
                vert = verts[-1]
                glVertex3f(vert[0], vert[1], vert[2])
            glEnd()