Esempio n. 1
0
    def draw(self, x, y, z=0, angle=0, scale=1):
        """Draws the SVG to screen.

        :Parameters
            `x` : float
                The x-coordinate at which to draw.
            `y` : float
                The y-coordinate at which to draw.
            `z` : float
                The z-coordinate at which to draw. Defaults to 0. Note that z-ordering may not
                give expected results when transparency is used.
            `angle` : float
                The angle by which the image should be rotated (in degrees). Defaults to 0.
            `scale` : float
                The amount by which the image should be scaled, either as a float, or a tuple
                of two floats (xscale, yscale).

        """
        glPushMatrix()
        glTranslatef(x, y, z)
        if angle:
            glRotatef(angle, 0, 0, 1)
        if scale != 1:
            try:
                glScalef(scale[0], scale[1], 1)
            except TypeError:
                glScalef(scale, scale, 1)
        if self._a_x or self._a_y:
            glTranslatef(-self._a_x, -self._a_y, 0)
        glCallList(self.disp_list)
        glPopMatrix()
Esempio n. 2
0
    def render(self):
        """ renders the item to the screen """

        glPushMatrix()

        glMultMatrixf(numpy.transpose(self.translation_matrix))

        glMultMatrixf(self.scaling_matrix)

        glMultMatrixf(self.rotation_matrix)

        cur_color = color.COLORS[self.color_index]

        glColor3f(cur_color[0], cur_color[1], cur_color[2])

        if self.selected:  # emit light if the node is selected

            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])

        self.render_self()

        if self.selected:

            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
Esempio n. 3
0
def Draw_model(mode, glpane, superclass):  # called by testmode.Draw_model
    if env.prefs.get("A9 devel/testdraw/super.Draw first?", True):  #070404
        glPushMatrix()  #k needed??
        superclass.Draw_model(mode)
        glPopMatrix()
    # glpane.part.draw(glpane) # this doesn't draw the model in any different place as when done below... [061211]
    return
Esempio n. 4
0
    def drawGrid(self):

        grids_per_screen = 10
        eye_dist = self.camera_xyz[2]
        meters_per_grid = round_to_125(eye_dist / grids_per_screen)
        num_lines = 300

        glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_LINE_BIT)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glEnable(GL_DEPTH_TEST)

        glPushMatrix()
        glTranslatef(0, 0, 0)
        glColor3f(0.2, 0.2, 0.2)
        glBegin(GL_LINES)

        for i in range(num_lines):
            glVertex2f((-num_lines / 2 + i) * meters_per_grid,
                       -num_lines / 2 * meters_per_grid)
            glVertex2f((-num_lines / 2 + i) * meters_per_grid,
                       num_lines / 2 * meters_per_grid)

            glVertex2f(-num_lines / 2 * meters_per_grid,
                       (-num_lines / 2 + i) * meters_per_grid)
            glVertex2f(num_lines / 2 * meters_per_grid,
                       (-num_lines / 2 + i) * meters_per_grid)

        glEnd()
        glPopMatrix()
        glPopAttrib()
Esempio n. 5
0
    def paint(self):
        glPushMatrix()

        position = self.player.getPosition()
        glTranslate(position.x, position.y, position.z)
        glRotate(self.player.orientation.y, 0.0, 1.0, 0.0)
        # Slide back because the pyramid below is centered at 0.5, 0, 0.5
        # instead of at the origin.  Without this it rotates around its corner
        # instead of around its center.
        glTranslate(-0.5, 0, -0.5)

        glColor(1.0, 1.0, 1.0)

        glBegin(GL_TRIANGLES)
        glVertex3f(0.5, 0.0, 0.5)
        glVertex3f(0.0, 1.0, 0.0)
        glVertex3f(1.0, 1.0, 0.0)

        glVertex3f(0.5, 0.0, 0.5)
        glVertex3f(1.0, 1.0, 0.0)
        glVertex3f(1.0, 1.0, 1.0)

        glVertex3f(0.5, 0.0, 0.5)
        glVertex3f(1.0, 1.0, 1.0)
        glVertex3f(0.0, 1.0, 1.0)

        glVertex3f(0.5, 0.0, 0.5)
        glVertex3f(0.0, 1.0, 1.0)
        glVertex3f(0.0, 1.0, 0.0)
        glEnd()

        glPopMatrix()
Esempio n. 6
0
  def desenhar(self):

    glPushMatrix()
    glLoadIdentity()
    glTranslatef(*self.posicao)


    glColor3fv(self.cor)
    
    glBegin(GL_LINES)

    #desenha moldura

    glVertex3fv((0, 0, 0))
    glVertex3fv((self.largura, 0, 0))

    glVertex3fv((self.largura, 0, 0))
    glVertex3fv((self.largura, self.altura, 0))

    glVertex3fv((self.largura, self.altura, 0))
    glVertex3fv((0, self.altura, 0))

    glVertex3fv((0, self.altura, 0))
    glVertex3fv((0, 0, 0))

    i = 0
  

    while (i < len(self.pontos) - 1):
      glVertex3fv((self.pontos[i][0]*self.escala_x, self.pontos[i][1]*self.escala_y, 0))
      glVertex3fv((self.pontos[i + 1][0]*self.escala_x, self.pontos[i + 1][1]*self.escala_y, 0))
      i += 1
    glEnd()

    glPopMatrix()
Esempio n. 7
0
    def render(self):
        """ The render pass for the scene """
        self.init_view()

        # Enable lighting and color
        glEnable(GL_LIGHTING)

        glClearColor(0.4, 0.4, 0.4, 0.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Load the modelview matrix from the current state of the trackball
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        loc = self.interaction.translation
        glTranslated(-loc[0], -loc[1], -loc[2])
        glMultMatrixf(self.interaction.trackball.matrix)

        # store the inverse of the current modelview.
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        # render the scene. This will call the render function for each object in the scene
        self.scene.render()

        # draw the grid
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()

        # flush the buffers so that the scene can be drawn
        glFlush()
Esempio n. 8
0
    def draw_circle(
            self,
            circle_center,
            circle_normal,
            circle_radius,
            color=RGBA(1.1, 0.2, 0.8),
            num_segments=20,
    ):
        vertices = []
        vertices.append((0, 0, 0))  # circle center

        # create circle vertices in the xy plane
        for i in np.linspace(0.0, 2.0 * math.pi, num_segments):
            x = math.sin(i)
            y = math.cos(i)
            z = 0
            vertices.append((x, y, z))

        glPushMatrix()
        glMatrixMode(GL_MODELVIEW)
        glLoadMatrixf(
            self.get_pupil_transformation_matrix(circle_normal, circle_center,
                                                 circle_radius))
        glutils.draw_polyline((vertices),
                              color=color,
                              line_type=GL_TRIANGLE_FAN)  # circle
        glutils.draw_polyline([(0, 0, 0), (0, 0, 4)],
                              color=RGBA(0, 0, 0),
                              line_type=GL_LINES)  # normal
        glPopMatrix()
Esempio n. 9
0
def drawArrowHead(color, 
                  basePoint, 
                  drawingScale, 
                  unitBaseVector, 
                  unitHeightVector):



    arrowBase = drawingScale * 0.08
    arrowHeight = drawingScale * 0.12
    glDisable(GL_LIGHTING)
    glPushMatrix()
    glTranslatef(basePoint[0],basePoint[1],basePoint[2])
    point1 = V(0, 0, 0)
    point1 = point1 + unitHeightVector * arrowHeight    
    point2 = unitBaseVector * arrowBase    
    point3 = - unitBaseVector * arrowBase
    #Draw the arrowheads as filled triangles
    glColor3fv(color)
    glBegin(GL_POLYGON)
    glVertex3fv(point1)
    glVertex3fv(point2)
    glVertex3fv(point3)
    glEnd()    
    glPopMatrix()
    glEnable(GL_LIGHTING)
Esempio n. 10
0
 def for_each(self, points):
    for pos in points:
       glPushMatrix()
       translate(pos)
       self.func(*self.args, **self.kwargs)
       glPopMatrix()
    self._triggered = True
Esempio n. 11
0
def traverse(node):
    '''
    '''
    def rotate():
        if len(node.rotate) != 4:

            for r in node.rotate:
                glRotatef(*r)
        else:
            glRotatef(*node.rotate)

    glPushMatrix()
    if isinstance(node, Object3D):

        glTranslatef(*node.translate)
        if node.rotation_points is not None:

            glTranslatef(*node.rotation_points[0])
            rotate()
            glTranslatef(*node.rotation_points[1])

        else:
            rotate()

        glScalef(*node.scale)
        node.render()

    for b in node.branches:
        traverse(b)

    glPopMatrix()
Esempio n. 12
0
    def _draw_zero_plane_xy(self, color, texture_id=None, scale=1.0):
        glPushMatrix()
        # glColor3f(*rgb_to_f(*color))
        apply_texture = texture_id is not None
        if apply_texture:
            glColor3f(1, 1, 1)
            glBindTexture(GL_TEXTURE_2D, self._textures[texture_id])
            glTexCoord2f(1.0 * scale, 0.0 * scale)
        else:
            glColor3f(*rgb_to_f(*color))
        glBegin(GL_POLYGON)
        size = self._size / 2

        glVertex3f(size, size, 0)
        if apply_texture:
            glTexCoord2f(1.0 * scale, 1.0 * scale)
        glVertex3f(size, -size, 0)
        if apply_texture:
            glTexCoord2f(0.0 * scale, 1.0 * scale)
        glVertex3f(-size, -size, 0)
        if apply_texture:
            glTexCoord2f(0.0 * scale, 0.0 * scale)
        glVertex3f(-size, size, 0)
        # if texture is not None:
        #     glBindTexture(GL_TEXTURE_2D, )
        glEnd()
        glPopMatrix()
Esempio n. 13
0
def drawFilledCircle(color, center, radius, normal):
    """
    Scale, rotate/translate the unit circle properly.
    Added a filled circle variant, piotr 080405
    """
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix() 
    glColor3fv(color)
    glDisable(GL_LIGHTING)

    glTranslatef(center[0], center[1], center[2])
    rQ = Q(V(0, 0, 1), normal)
    rotAngle = rQ.angle*180.0/pi

    #This may cause problems as proved before in Linear motor display.
    #rotation around (0, 0, 0)
    #if vlen(V(rQ.x, rQ.y, rQ.z)) < 0.00005:
    #      rQ.x = 1.0

    glRotatef(rotAngle, rQ.x, rQ.y, rQ.z)
    glScalef(radius, radius, 1.0)
    glCallList(drawing_globals.filledCircleList)
    glEnable(GL_LIGHTING)
    glPopMatrix()
    return
Esempio n. 14
0
    def render(self):
        '''

        '''
        super(Shaft, self).render()

        glPushAttrib(GL_CURRENT_BIT)
        n = int(self.length)
        lim = n - 1
        if self.orientation in ['down', 'forward', 'backward']:
            lim = 0
        self._set_material()
#        print lim
        for i in range(n):
            glPushMatrix()

            glTranslatef(0, i / 2.0, 0)

            if i == lim:
                self._can_(0.66, 0.5)

            self._cylinder_(0.5, 0.5)

            glPopMatrix()
#        if self.state and animate:
#            if ac % 20 == 0 and self.prev_ac != ac:
#                if self.orientation == 'left' or self.orientation == 'up':
#                    self.colorlist = shift(self.colorlist)
#                else:
#                    self.colorlist = deshift(self.colorlist)
#            self.prev_ac = ac
        glPopAttrib()
Esempio n. 15
0
def drawbrick(color, center, axis, l, h, w, opacity=1.0):

    if len(color) == 3:
        color = (color[0], color[1], color[2], opacity)

    if opacity != 1.0:
        glDepthMask(GL_FALSE)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

    apply_material(color)
    glPushMatrix()
    glTranslatef(center[0], center[1], center[2])

    ##Huaicai 1/17/05: To avoid rotate around (0, 0, 0), which causes
    ## display problem on some platforms
    angle = -acos(axis[2]) * 180.0 / pi
    if (axis[2] * axis[2] >= 1.0):
        glRotate(angle, 0.0, 1.0, 0.0)
    else:
        glRotate(angle, axis[1], -axis[0], 0.0)

    glScale(h, w, l)
    #bruce 060302 revised the contents of solidCubeList while fixing bug 1595
    glCallList(drawing_globals.solidCubeList)

    if opacity != 1.0:
        glDisable(GL_BLEND)
        glDepthMask(GL_TRUE)

    glPopMatrix()
    return
Esempio n. 16
0
def main():
    moons = [Moon(pos) for pos in d12_input]
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
    glutInitWindowSize(800, 800)
    glutInitWindowPosition(350, 200)
    glutCreateWindow('name')
    glClearColor(0., 0., 0., 1.)
    glShadeModel(GL_SMOOTH)
    glEnable(GL_CULL_FACE)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_LIGHTING)
    lightZeroPosition = [10., 4., 10., 1.]
    lightZeroColor = [0.8, 1.0, 0.8, 1.0]
    glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition)
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor)
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1)
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05)
    glEnable(GL_LIGHT0)
    glutDisplayFunc(lambda: display_scene(moons))
    glutTimerFunc(0, timer, 0)
    glMatrixMode(GL_PROJECTION)
    gluPerspective(40., 1., 1., 40.)
    glMatrixMode(GL_MODELVIEW)
    gluLookAt(0, -10, 10, 0, 0, 0, 0, 1, 0)
    glPushMatrix()
    glutMainLoop()
Esempio n. 17
0
def drawRotateSign(color, pos1, pos2, radius, rotation=0.0):
    """Rotate sign on top of the caps of the cylinder """
    glPushMatrix()
    glColor3fv(color)
    vec = pos2 - pos1
    axis = norm(vec)
    glTranslatef(pos1[0], pos1[1], pos1[2])

    ##Huaicai 1/17/05: To avoid rotate around (0, 0, 0), which causes
    ## display problem on some platforms
    angle = -acos(axis[2]) * 180.0 / pi
    if (axis[2] * axis[2] >= 1.0):
        glRotate(angle, 0.0, 1.0, 0.0)
    else:
        glRotate(angle, axis[1], -axis[0], 0.0)
    glRotate(rotation, 0.0, 0.0, 1.0)  #bruce 050518
    glScale(radius, radius, Numeric.dot(vec, vec)**.5)

    glLineWidth(2.0)
    glDisable(GL_LIGHTING)
    glCallList(drawing_globals.rotSignList)
    glEnable(GL_LIGHTING)
    glLineWidth(1.0)

    glPopMatrix()
    return
Esempio n. 18
0
def drawFilledCircle(color, center, radius, normal):
    """
    Scale, rotate/translate the unit circle properly.
    Added a filled circle variant, piotr 080405
    """
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix()
    glColor3fv(color)
    glDisable(GL_LIGHTING)

    glTranslatef(center[0], center[1], center[2])
    rQ = Q(V(0, 0, 1), normal)
    rotAngle = rQ.angle * 180.0 / pi

    #This may cause problems as proved before in Linear motor display.
    #rotation around (0, 0, 0)
    #if vlen(V(rQ.x, rQ.y, rQ.z)) < 0.00005:
    #      rQ.x = 1.0

    glRotatef(rotAngle, rQ.x, rQ.y, rQ.z)
    glScalef(radius, radius, 1.0)
    glCallList(drawing_globals.filledCircleList)
    glEnable(GL_LIGHTING)
    glPopMatrix()
    return
Esempio n. 19
0
        def pickup(event, right):
            """
                Function to get the Name Stack
                right es si el boton pulsado es el derecho
                
                El viewport[3]-event.y() creo que es porque la medida de las Y está invertida
                Los problemas que tenía con windows de tener que hacer varios click se corrigieron sustituyendo la región de selección de 1,1 a 5,5

            """

            viewport = glGetIntegerv(GL_VIEWPORT)
            glMatrixMode(GL_PROJECTION)
            glPushMatrix()
            glSelectBuffer(512)
            glRenderMode(GL_SELECT)
            glLoadIdentity()
            gluPickMatrix(event.x(), viewport[3] - event.y(), 4, 4, viewport)
            aspect = viewport[2] / viewport[3]
            gluPerspective(60, aspect, 1.0, 400)
            glMatrixMode(GL_MODELVIEW)
            self.paintGL()
            glMatrixMode(GL_PROJECTION)
            if right == False:
                parseLeftButtonNameStack(glRenderMode(GL_RENDER))
            else:
                parseRightButtonNameStack(glRenderMode(GL_RENDER))
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)
Esempio n. 20
0
    def render(self):
        #init shadow matrix
        self.init_view()

        #open light
        glEnable(GL_LIGHTING)

        #clear color and depth caches
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        #set model view matrix(danwei matrix is ok)
        #set trackball's rotate matrix as Modelview
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()

        #replace now-matrix with hengdeng matrix
        glLoadIdentity()
        glMultMatrixf(self.interaction.trackball.matrix)

        #save Modelview matrix, later change system with anti-matrix
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        #rend the scene
        self.scene.render()

        #after each shadow , huifu light state
        glDisable(GL_LIGHTING)
        glPopMatrix()

        glFlush()
Esempio n. 21
0
    def draw(self, time, line_width=None):
        if self.hidden:
            return
        if time <= self.ts:
            return
        time = time * 1e-9

        pos_start = self.pos
        path = self.speed * (time - self.ts * 1e-9) * self.dir
        # max_end = self.pos + (self.speed * self.te * self.dir)
        # if not int(self.te) == 0 and time > self.te:
        #    pos_end = max_end
        # else:
        #    pos_end = self.pos + path
        pos_end = self.pos + path

        glPushMatrix()
        if line_width:
            glLineWidth(line_width)
        else:
            glLineWidth(self.line_width)
        glColor3f(*self.color)
        glBegin(GL_LINES)
        glVertex3f(*pos_start)
        glVertex3f(*pos_end)
        glEnd()
        glPopMatrix()
Esempio n. 22
0
 def draw_in_abs_coords(self, glpane, color):
     """
     Draw the handle as a highlighted object.
     
     @param glpane: The 3D Graphics area.
     @type  gplane: L{GLPane}
     
     @param color: Unused.
     @type  color:
     
     @attention: I{color} is not used.
     """          
     q = self.parent.quat  
     glPushMatrix()
     if self.parent.center:
         glTranslatef( self.parent.center[0],
                       self.parent.center[1], 
                       self.parent.center[2])
     if q:
         glRotatef( q.angle * ONE_RADIAN, 
                    q.x,
                    q.y,
                    q.z)            
     
     self._draw(highlighted = True)
     glPopMatrix()
Esempio n. 23
0
    def _display_vector_head(self, head_angle: float):
        """Displays the robot's head to the current OpenGL context

        :param head_angle: the angle of the lift in radians
        """

        glPushMatrix()
        # Rotate the head around the pivot
        glTranslatef(HEAD_PIVOT_X, 0.0, HEAD_PIVOT_Z)
        glRotatef(-head_angle, 0, 1, 0)
        glTranslatef(-HEAD_PIVOT_X, 0.0, -HEAD_PIVOT_Z)
        # Render all of the head meshes
        self.display_by_key("head_geo")
        # Screen
        self.display_by_key("backScreen_mat")
        self.display_by_key("screenEdge_geo")
        self.display_by_key("overscan_1_geo")
        # Eyes
        self.display_by_key("eye_L_geo")
        self.display_by_key("eye_R_geo")
        # Eyelids
        self.display_by_key("eyeLid_R_top_geo")
        self.display_by_key("eyeLid_L_top_geo")
        self.display_by_key("eyeLid_L_btm_geo")
        self.display_by_key("eyeLid_R_btm_geo")
        # Face cover (drawn last as it's translucent):
        self.display_by_key("front_Screen_geo")
        glPopMatrix()
Esempio n. 24
0
    def drawTexture(self, texture, dx, dy, dw, dh, x, y, w, h, r):
        '''
		texture is an int
		textureRect is a list of size 4, determines which square to take from the texture
		drawRect is a list of size 4, is used to determine the drawing size
		'''

        glBindTexture(self.texext, texture)

        glPushMatrix()
        glTranslatef(dx + dw / 2, dy + dh / 2, 0)
        glRotatef(r, 0, 0, 1.0)
        glTranslatef(-1 * (dx + dw / 2), -1 * (dy + dh / 2), 0)

        glBegin(GL_QUADS)
        #Top-left vertex (corner)
        glTexCoord2f(x, y + h)  #image/texture
        glVertex3f(dx, dy, 0)  #screen coordinates

        #Bottom-left vertex (corner)
        glTexCoord2f(x + w, y + h)
        glVertex3f((dx + dw), dy, 0)

        #Bottom-right vertex (corner)
        glTexCoord2f(x + w, y)
        glVertex3f((dx + dw), (dy + dh), 0)

        #Top-right vertex (corner)
        glTexCoord2f(x, y)
        glVertex3f(dx, (dy + dh), 0)
        glEnd()

        glPopMatrix()
Esempio n. 25
0
    def draw(self, x, y, z=0, angle=0, scale=1):
        """Draws the SVG to screen.

        :Parameters
            `x` : float
                The x-coordinate at which to draw.
            `y` : float
                The y-coordinate at which to draw.
            `z` : float
                The z-coordinate at which to draw. Defaults to 0. Note that z-ordering may not
                give expected results when transparency is used.
            `angle` : float
                The angle by which the image should be rotated (in degrees). Defaults to 0.
            `scale` : float
                The amount by which the image should be scaled, either as a float, or a tuple
                of two floats (xscale, yscale).

        """
        glPushMatrix()
        glTranslatef(x, y, z)
        if angle:
            glRotatef(angle, 0, 0, 1)
        if scale != 1:
            try:
                glScalef(scale[0], scale[1], 1)
            except TypeError:
                glScalef(scale, scale, 1)
        if self._a_x or self._a_y:
            glTranslatef(-self._a_x, -self._a_y, 0)
        glCallList(self.disp_list)
        glPopMatrix()
Esempio n. 26
0
def drawwiresphere_worker(params):
    """
    Draw a wireframe sphere.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    """

    (color, pos, radius, detailLevel) = params
    ## assert detailLevel == 1 # true, but leave out for speed
    from utilities.debug_prefs import debug_pref, Choice_boolean_True
    #bruce 060415 experiment, re iMac G4 wiresphere bug; fixes it!
    newway = debug_pref("new wirespheres?", Choice_boolean_True)
    oldway = not newway
    # These objects want a constant line color even if they are selected or
    # highlighted.
    glColor3fv(color)
    glDisable(GL_LIGHTING)
    if oldway:
        glPolygonMode(GL_FRONT, GL_LINE)
    glPushMatrix()
    glTranslatef(pos[0], pos[1], pos[2])
    glScale(radius,radius,radius)
    if oldway:
        glCallList(drawing_globals.sphereList[detailLevel])
    else:
        glCallList(drawing_globals.wiresphere1list)
    glEnable(GL_LIGHTING)
    glPopMatrix()
    if oldway:
        glPolygonMode(GL_FRONT, GL_FILL)
    return
Esempio n. 27
0
    def gl_display_cache_bars(self):
        """"""
        padding = 20.0
        frame_max = len(self.g_pool.timestamps
                        )  # last marker is garanteed to be frame max.

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        width, height = self.g_pool.camera_render_size
        h_pad = padding * (frame_max - 2) / float(width)
        v_pad = padding * 1.0 / (height - 2)
        gluOrtho(
            -h_pad, (frame_max - 1) + h_pad, -v_pad, 1 + v_pad, -1, 1
        )  # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        glTranslatef(0, -0.02, 0)
        color = (7.0, 0.1, 0.2, 8.0)
        draw_polyline(
            self.gl_display_ranges,
            color=RGBA(*color),
            line_type=GL_LINES,
            thickness=2.0,
        )

        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopMatrix()
Esempio n. 28
0
    def render(self):
        """ The render pass for the scene """
        self.init_view()

        # Enable lighting and color
        glEnable(GL_LIGHTING)

        glClearColor(0.4, 0.4, 0.4, 0.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Load the modelview matrix from the current state of the trackball
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        loc = self.interaction.translation
        glTranslated(-loc[0], -loc[1], -loc[2])
        glMultMatrixf(self.interaction.trackball.matrix)

        # store the inverse of the current modelview.
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        # render the scene. This will call the render function for each object in the scene
        self.scene.render()

        # draw the grid
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()

        # flush the buffers so that the scene can be drawn
        glFlush()
Esempio n. 29
0
    def draw(self):
        assert self._e_is_instance, "draw called on non-Instance of TextRect"  #061211
        glpane = self.env.glpane
        msg = str(
            self.msg
        )  #k str() won't always be needed, maybe isn't now ##e guess: need __mod__ in Expr
        width = self.ncols  # in chars
        # WARNING: every Widget2D has self.width in native Width units; don't assign ncols to self.width or you'll mess that up.
        #e probably we should rename this localvar to ncols, same for height/nlines.
        height = self.nlines  # in chars

        if 1:
            # until we have Arg type coercion, see if this detects caller errors -- it does:
            ## ValueError: invalid literal for int(): line 1
            ## line 2
            width = int(width)
            height = int(height)

        from graphics.drawing.texture_fonts import drawfont2
        glPushMatrix()  ####k guess, not sure needed
        #e translate by margin
        drawfont2(glpane, msg, width, height, pixelwidth=PIXELS)
        #061211 pass pixelwidth so rotation won't matter (warning: different value than before, even w/o rotation)
        glPopMatrix()
        return
Esempio n. 30
0
def SaveMatrix():
    "Save the current opengl matrix over a with block"
    glPushMatrix()
    try:
        yield
    finally:
        glPopMatrix()
Esempio n. 31
0
    def _draw_jig(self, glpane, color, highlighted = False):
        """
        Draw a Grid Plane jig as a set of grid lines.
        """
        glPushMatrix()

        glTranslatef( self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef( q.angle*180.0/math.pi, q.x, q.y, q.z)

        hw = self.width/2.0; hh = self.height/2.0
        corners_pos = [V(-hw, hh, 0.0), V(-hw, -hh, 0.0), V(hw, -hh, 0.0), V(hw, hh, 0.0)]
        
        if highlighted:
            grid_color = color
        else:
            grid_color = self.grid_color
        
        if self.picked:
            drawLineLoop(self.color, corners_pos)
        else:
            drawLineLoop(color, corners_pos)
            
        if self.grid_type == SQUARE_GRID:
            drawGPGrid(glpane, grid_color, self.line_type, self.width, self.height, self.x_spacing, self.y_spacing,
                       q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))
        else:
            drawSiCGrid(grid_color, self.line_type, self.width, self.height,
                        q.unrot(self.assy.o.up), q.unrot(self.assy.o.right))
        
        glPopMatrix()
    def draw_glpane_label_text(self, text):
        """
        Draw a text label for the glpane as a whole.
        
        @note: called indirectly from GLPane.paintGL shortly after
               it calls _do_graphicsMode_Draw(), via GraphicsMode.draw_glpane_label
        """
        #bruce 090219 moved this here from part of Part.draw_text_label
        # (after a temporary stop in the short-lived class PartDrawer);
        # the other part is now our caller GraphicsMode.draw_glpane_label.

        # (note: caller catches exceptions, so we don't have to bother)
        
        glDisable(GL_LIGHTING)
        glDisable(GL_DEPTH_TEST)
            # Note: disabling GL_DEPTH_TEST properly affects 2d renderText
            # (as used here), but not 3d renderText. For more info see
            # today's comments in Guides.py. [bruce 081204 comment]
        glPushMatrix() # REVIEW: needed? [bruce 081204 question]
        font = QFont(QString("Helvetica"), 24, QFont.Bold)
        self.qglColor(Qt.red) # this needs to be impossible to miss -- not nice-looking!
            #e tho it might be better to pick one of several bright colors
            # by hashing the partname, so as to change the color when the part changes.
        # this version of renderText uses window coords (0,0 at upper left)
        # rather than model coords (but I'm not sure what point on the string-image
        # we're setting the location of here -- guessing it's bottom-left corner):
        self.renderText(25,40, QString(text), font)
        glPopMatrix()
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_LIGHTING)
        return
Esempio n. 33
0
    def _gl_select_(self, x, y):
        '''

        '''
        _gw, gh = self.GetSize()

        self.draw(offscreen=True)
        b = glReadPixels(x, gh - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE)

        _buff = glSelectBuffer(128)
        view = glGetIntegerv(GL_VIEWPORT)
        glRenderMode(GL_SELECT)
        glInitNames()
        glPushName(0)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        gluPickMatrix(x, gh - y, 1.0, 1.0, view)
        self._set_view_volume()

        glMatrixMode(GL_MODELVIEW)
        self.draw(offscreen=True)

        glMatrixMode(GL_PROJECTION)
        glPopMatrix()

        hits = glRenderMode(GL_RENDER)
        glMatrixMode(GL_MODELVIEW)

        self.scene_graph.set_view_cube_face(struct.unpack('BBB', b))  # get the top object

        return min([(h.near, h.names[0]) for h in hits])[1] if hits else None
Esempio n. 34
0
def Draw_model(mode, glpane, superclass):  # called by testmode.Draw_model
    if env.prefs.get("A9 devel/testdraw/super.Draw first?", True):  # 070404
        glPushMatrix()  # k needed??
        superclass.Draw_model(mode)
        glPopMatrix()
    # glpane.part.draw(glpane) # this doesn't draw the model in any different place as when done below... [061211]
    return
Esempio n. 35
0
    def draw(self):
        """
        Draws each frame.
        """
        print("draw()")
        # DRAW STUFF HERE
        glDisable(GL_TEXTURE_RECTANGLE_ARB)
        glColor4f(1.0, 0.8, 0.2, 1.0)
        glPushMatrix()
        glScale(0.5, 0.5, 1.0)
        draw_square()
        glPopMatrix()

        glColor4f(1.0, 1.0, 0.0, 0.8)
        num = 64
        for i in range(num):
            x = (i / float(num)) * 4 - 2
            draw_line(float(x), -2.0, float(x), 2.0)
            draw_line(-2.0, float(x), 2.0, float(x))

        if self.texture_id is not None:
            glColor4f(1.0, 1.0, 1.0, 1.0)
            glEnable(GL_TEXTURE_RECTANGLE_ARB)
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.texture_id)
            glPushMatrix()
            glScale(0.4, 0.3, 1.0)
            draw_textured_square(320, 240)
            glPopMatrix()
        else:
            print "No texture to draw"
Esempio n. 36
0
File: graph.py Progetto: reims/wesen
 def Draw(self):
     """draw a curve of all previous data,
     up to a certain point (self.resolution)"""
     self.vbo.bind()
     self.vbo.copy_data()
     glEnableClientState(GL_VERTEX_ARRAY)
     glVertexPointer(2, GL_FLOAT, 0, self.vbo)
     if self.buffer_full:
         if self.previous_index != self.size - 1:
             glPushMatrix()
             glTranslatef(-1 * (self.previous_index + 1), 0.0, 0.0)
             glDrawArrays(GL_LINE_STRIP,
                          (self.previous_index + 1),
                          (self.size - self.previous_index - 1))
             glPopMatrix()
         glPushMatrix()
         glTranslatef(self.size - self.previous_index - 1, 0.0, 0.0)
         glDrawArrays(GL_LINE_STRIP, 0,
                      (self.previous_index + 1))
         glPopMatrix()
     else:
         glDrawArrays(GL_LINE_STRIP, 0,
                      (self.previous_index + 1))
     glDisableClientState(GL_VERTEX_ARRAY)
     self.vbo.unbind()
Esempio n. 37
0
def drawwiresphere_worker(params):
    """
    Draw a wireframe sphere.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    """

    (color, pos, radius, detailLevel) = params
    ## assert detailLevel == 1 # true, but leave out for speed
    from utilities.debug_prefs import debug_pref, Choice_boolean_True
    #bruce 060415 experiment, re iMac G4 wiresphere bug; fixes it!
    newway = debug_pref("new wirespheres?", Choice_boolean_True)
    oldway = not newway
    # These objects want a constant line color even if they are selected or
    # highlighted.
    glColor3fv(color)
    glDisable(GL_LIGHTING)
    if oldway:
        glPolygonMode(GL_FRONT, GL_LINE)
    glPushMatrix()
    glTranslatef(pos[0], pos[1], pos[2])
    glScale(radius, radius, radius)
    if oldway:
        glCallList(drawing_globals.sphereList[detailLevel])
    else:
        glCallList(drawing_globals.wiresphere1list)
    glEnable(GL_LIGHTING)
    glPopMatrix()
    if oldway:
        glPolygonMode(GL_FRONT, GL_FILL)
    return
Esempio n. 38
0
def draw_text_2d(text, x, y, line_height=17, color=None):
    """Draw a text at a given 2D position.

    A very basic 2D drawing function for drawing (multi-line) text."
    """
    width = glutGet(GLUT_WINDOW_WIDTH)
    height = glutGet(GLUT_WINDOW_HEIGHT)

    glMatrixMode(GL_PROJECTION)
    glPushMatrix()  #matrix = glGetDouble( GL_PROJECTION_MATRIX )
    glLoadIdentity()
    glOrtho(0.0, width, 0.0, height, -1.0, 1.0)
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix()
    glLoadIdentity()
    if color:
        glColor3f(*color)
    glRasterPos2i(x, y)
    lines = 0
    for character in text:
        if character == '\n':
            lines += 1
            glRasterPos(x, y - (lines * line_height))
        else:
            glutBitmapCharacter(GLUT_BITMAP_8_BY_13, ord(character))
    glPopMatrix()
    glMatrixMode(GL_PROJECTION)
    glPopMatrix()  #glLoadMatrixd(matrix)
    glMatrixMode(GL_MODELVIEW)
Esempio n. 39
0
    def render(self):
        #初始化投影矩阵
        self.init_view()

        #启动光照
        glEnable(GL_LIGHTING)
        #清空颜色缓存与深度缓存
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        #设置模型视图矩阵,这节课先用单位矩阵就行了。
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        glMultMatrixf(self.interaction.trackball.matrix)

        # 存储ModelView矩阵与其逆矩阵之后做坐标系转换用
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))
        #渲染场景
        self.scene.render()

        #每次渲染后复位光照状态
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()
        #把数据刷新到显存上
        glFlush()
Esempio n. 40
0
def drawRotateSign(color, pos1, pos2, radius, rotation = 0.0):
    """Rotate sign on top of the caps of the cylinder """
    glPushMatrix()
    glColor3fv(color)
    vec = pos2-pos1
    axis = norm(vec)
    glTranslatef(pos1[0], pos1[1], pos1[2])

    ##Huaicai 1/17/05: To avoid rotate around (0, 0, 0), which causes 
    ## display problem on some platforms
    angle = -acos(axis[2])*180.0/pi
    if (axis[2]*axis[2] >= 1.0):
        glRotate(angle, 0.0, 1.0, 0.0)
    else:
        glRotate(angle, axis[1], -axis[0], 0.0)
    glRotate(rotation, 0.0, 0.0, 1.0) #bruce 050518
    glScale(radius,radius,Numeric.dot(vec,vec)**.5)

    glLineWidth(2.0)
    glDisable(GL_LIGHTING)
    glCallList(drawing_globals.rotSignList)
    glEnable(GL_LIGHTING)
    glLineWidth(1.0)

    glPopMatrix()
    return
Esempio n. 41
0
    def draw_player(self):
        glLineWidth(2)
        glPushMatrix()

        if self.degree == 90:
            if not self.check_goal(self.player, self.board):
                direction = self.get_direction(self.player)
                self.draw_main_cube(self.player[0], direction)
                self.draw_secondary_cube(self.player[1], direction)
        else:
            direction = self.get_direction(self.previous)
            self.draw_secondary_cube(self.player[1], direction)
            if direction != Direction.none and self.get_direction(
                    self.player) == Direction.none:
                done = self.teleport_player(10, rotating_speed / 2)
                if self.rotate_before_swap():
                    if not done:
                        self.steps = 1
                        self.degree = 0
            elif self.check_goal(self.player, self.board):
                done = self.teleport_player(-10, rotating_speed / 5)
                if self.rotate_before_swap():
                    if not done:
                        self.steps = 1
                        self.degree = 0
            else:
                self.rotate_player()
            self.draw_main_cube(self.previous[0], direction)
        glPopMatrix()
        glLineWidth(1)
Esempio n. 42
0
def drawArrowHead(color, 
                  basePoint, 
                  drawingScale, 
                  unitBaseVector, 
                  unitHeightVector):



    arrowBase = drawingScale * 0.08
    arrowHeight = drawingScale * 0.12
    glDisable(GL_LIGHTING)
    glPushMatrix()
    glTranslatef(basePoint[0],basePoint[1],basePoint[2])
    point1 = V(0, 0, 0)
    point1 = point1 + unitHeightVector * arrowHeight    
    point2 = unitBaseVector * arrowBase    
    point3 = - unitBaseVector * arrowBase
    #Draw the arrowheads as filled triangles
    glColor3fv(color)
    glBegin(GL_POLYGON)
    glVertex3fv(point1)
    glVertex3fv(point2)
    glVertex3fv(point3)
    glEnd()    
    glPopMatrix()
    glEnable(GL_LIGHTING)
Esempio n. 43
0
    def InitGL(self, Width, Height):
        self.view_port_xr = 1
        self.view_port_yr = 1
        self.original_x = Width
        self.original_y = Height

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        glOrtho(0, Width, 0, Height, -1, 1)
        glScalef(1, -1, 1)
        glTranslatef(0, -Height, 0)
        glMatrixMode(GL_MODELVIEW)
        glDisable(GL_DEPTH_TEST)  # Disables Depth Testing
        glShadeModel(GL_SMOOTH)  # Enables Smooth Color Shading

        # Anti-aliasing/prettyness stuff
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glEnable(GL_BLEND)
        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
        glHint(GL_POINT_SMOOTH_HINT, GL_NICEST)
        glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
        glEnable(GL_LINE_SMOOTH)
        glEnable(GL_POINT_SMOOTH)
        glEnable(GL_POLYGON_SMOOTH)
        glClearColor(background_color()[0],
                     background_color()[1],
                     background_color()[2], 1.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
Esempio n. 44
0
def drawbrick(color, center, axis, l, h, w, opacity = 1.0):

    if len(color) == 3:
        color = (color[0], color[1], color[2], opacity)

    if opacity != 1.0:	
        glDepthMask(GL_FALSE)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)  


    apply_material(color)
    glPushMatrix()
    glTranslatef(center[0], center[1], center[2])

    ##Huaicai 1/17/05: To avoid rotate around (0, 0, 0), which causes 
    ## display problem on some platforms
    angle = -acos(axis[2])*180.0/pi
    if (axis[2]*axis[2] >= 1.0):
        glRotate(angle, 0.0, 1.0, 0.0)
    else:
        glRotate(angle, axis[1], -axis[0], 0.0)



    glScale(h, w, l)
    #bruce 060302 revised the contents of solidCubeList while fixing bug 1595
    glCallList(drawing_globals.solidCubeList)

    if opacity != 1.0:	
        glDisable(GL_BLEND)
        glDepthMask(GL_TRUE)

    glPopMatrix()
    return
Esempio n. 45
0
    def _draw_jig(self, glpane, color, highlighted=False):
        """
        Draw a linear motor as a long box along the axis, with a thin cylinder (spoke) to each atom.
        """
        glPushMatrix()
        try:
            glTranslatef( self.center[0], self.center[1], self.center[2])
            q = self.quat
            glRotatef( q.angle*180.0/pi, q.x, q.y, q.z)

            orig_center = V(0.0, 0.0, 0.0)
            drawbrick(color, orig_center, self.axis, 
                      self.length, self.width, self.width, 
                      opacity = self.opacity)
            
            drawLinearSign((0,0,0), orig_center, self.axis, self.length, self.width, self.width)
                # (note: drawLinearSign uses a small depth offset so that arrows are slightly in front of brick)
                # [bruce comment 060302, a guess from skimming drawLinearSign's code]
            for a in self.atoms[:]:
                drawcylinder(color, orig_center, 
                             a.posn()-self.center, 
                             self.sradius, 
                             opacity = self.opacity)
        except:
            #bruce 060208 protect OpenGL stack from exception analogous to that seen for RotaryMotor in bug 1445
            print_compact_traceback("exception in LinearMotor._draw, continuing: ")
        glPopMatrix()
Esempio n. 46
0
 def draw_in_abs_coords(self, glpane, color):
     """
     Draw the handle as a highlighted object.
     
     @param glpane: The 3D Graphics area.
     @type  gplane: L{GLPane}
     
     @param color: Unused.
     @type  color:
     
     @attention: I{color} is not used.
     """          
     q = self.parent.quat  
     glPushMatrix()
     if self.parent.center:
         glTranslatef( self.parent.center[0],
                       self.parent.center[1], 
                       self.parent.center[2])
     if q:
         glRotatef( q.angle * ONE_RADIAN, 
                    q.x,
                    q.y,
                    q.z)            
     
     self._draw(highlighted = True)
     glPopMatrix()
Esempio n. 47
0
    def draw(self):
        """
        Draws each frame.
        """
        print("draw()")
        # DRAW STUFF HERE
        glDisable(GL_TEXTURE_RECTANGLE_ARB)
        glColor4f(1.0, 0.8, 0.2, 1.0)
        glPushMatrix()
        glScale(0.5, 0.5, 1.0)
        draw_square()
        glPopMatrix()

        glColor4f(1.0, 1.0, 0.0, 0.8)
        num = 64
        for i in range(num):
            x = (i / float(num)) * 4 - 2
            draw_line(float(x), -2.0, float(x), 2.0)
            draw_line(-2.0, float(x), 2.0, float(x))

        if self.texture_id is not None:
            glColor4f(1.0, 1.0, 1.0, 1.0)
            glEnable(GL_TEXTURE_RECTANGLE_ARB)
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.texture_id)
            glPushMatrix()
            glScale(0.4, 0.3, 1.0)
            draw_textured_square(320, 240)
            glPopMatrix()
        else:
            print "No texture to draw"
Esempio n. 48
0
 def render(self):
     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
     glMatrixMode(GL_MODELVIEW)
     glPushMatrix()
     glTranslated(self.center[0], self.center[1], self.center[2])
     glCallList(G_OBJ_CUBE)
     glPopMatrix()
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Esempio n. 49
0
 def _draw_geometry(self, glpane, color, highlighted=False):   
     glPushMatrix()
     if not highlighted:
         color = self.color
     drawPolyLine(color, self.controlPoints)
     if self.picked:
         self._draw_handles(self.controlPoints)
     glPopMatrix()
Esempio n. 50
0
    def draw(self):
        # this code is modified from GLPane.drawcompass

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()

        glMatrixMode(
            GL_PROJECTION
        )  # WARNING: we're now in nonstandard matrixmode (for sake of gluPickMatrix and glOrtho -- needed??##k)
        glPushMatrix()
        glLoadIdentity()

        try:
            glpane = self.env.glpane
            ##            aspect = 1.0 ###WRONG -- should use glpane.aspect (which exists as of 070919)
            aspect = glpane.aspect  # revised by bruce 070919, UNTESTED
            corner = self.corner
            delegate = self.delegate

            ###e should get glpane to do this for us (ie call a method in it to do this if necessary)
            # (this code is copied from it)
            glselect = glpane.current_glselect
            if glselect:
                # print "%r (ipath %r) setting up gluPickMatrix" % (self, self.ipath)
                x, y, w, h = glselect
                gluPickMatrix(
                    x, y, w, h, glGetIntegerv(GL_VIEWPORT)  # k is this arg needed? it might be the default...
                )

            # the first three cases here are still ###WRONG
            if corner == UPPER_RIGHT:
                glOrtho(-50 * aspect, 5.5 * aspect, -50, 5.5, -5, 500)  # Upper Right
            elif corner == UPPER_LEFT:
                glOrtho(-5 * aspect, 50.5 * aspect, -50, 5.5, -5, 500)  # Upper Left
            elif corner == LOWER_LEFT:
                glOrtho(-5 * aspect, 50.5 * aspect, -5, 50.5, -5, 500)  # Lower Left
            else:
                ## glOrtho(-50*aspect, 5.5*aspect, -5, 50.5,  -5, 500) # Lower Right
                ## glOrtho(-50*aspect, 0, 0, 50,  -5, 500) # Lower Right [used now] -- x from -50*aspect to 0, y (bot to top) from 0 to 50
                glOrtho(-glpane.width * PIXELS, 0, 0, glpane.height * PIXELS, -5, 500)
                # approximately right for the checkbox, but I ought to count pixels to be sure (note, PIXELS is a pretty inexact number)

            glMatrixMode(GL_MODELVIEW)  ###k guess 061210 at possible bugfix (and obviously needed in general) --
            # do this last to leave the matrixmode standard
            # (status of bugs & fixes unclear -- hard to test since even Highlightable(projection=True) w/o any change to
            # projection matrix (test _9cx) doesn't work!)
            offset = (-delegate.bright, delegate.bbottom)  # only correct for LOWER_RIGHT
            glTranslatef(offset[0], offset[1], 0)
            self.drawkid(delegate)  ## delegate.draw()

        finally:
            glMatrixMode(GL_PROJECTION)
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)  # be sure to do this last, to leave the matrixmode standard
            glPopMatrix()

        return
Esempio n. 51
0
    def paint(self):
        if self.quad is None:
            self.quad = gluNewQuadric()

        glPushMatrix()
        glColor(self.color.red, self.color.green, self.color.blue)
        glTranslate(self.center.x, self.center.y, self.center.z)
        gluSphere(self.quad, self.radius, 25, 25)
        glPopMatrix()
Esempio n. 52
0
 def draw_doms(self, size=3):
     glPushMatrix()
     glPointSize(size)
     glColor3f(1.0, 1.0, 1.0)
     glBegin(GL_POINTS)
     for position in self.dom_positions:
         glVertex3f(position[0], position[1], position[2])
     glEnd()
     glPopMatrix()
Esempio n. 53
0
    def start_render(self):
        '''
        '''
        glDisable(GL_DEPTH_TEST)

        glPushMatrix()
        glLoadIdentity()

        glTranslatef(*self.translate)
Esempio n. 54
0
 def render(self):
     """ 渲染显示包围盒,可在调试的时候使用 """
     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
     glMatrixMode(GL_MODELVIEW)
     glPushMatrix()
     glTranslated(self.center[0], self.center[1], self.center[2])
     glCallList(G_OBJ_CUBE)
     glPopMatrix()
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Esempio n. 55
0
 def render(self):
     """ render the AABB. This can be useful for debugging purposes """
     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
     glMatrixMode(GL_MODELVIEW)
     glPushMatrix()
     glTranslated(self.center[0], self.center[1], self.center[2])
     glCallList(G_OBJ_CUBE)
     glPopMatrix()
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Esempio n. 56
0
    def _draw_jig(self, glpane, color, highlighted = False):
        """
        Draw an ESPImage jig (self) as a plane with an edge and a bounding box.

        @note: this is not called during graphicsMode.Draw_model as with most
            Jigs, but during graphicsMode.Draw_after_highlighting.
        """
        glPushMatrix()

        glTranslatef( self.center[0], self.center[1], self.center[2])
        q = self.quat
        glRotatef( q.angle*180.0/math.pi, q.x, q.y, q.z) 

        #bruce 060207 extensively revised texture code re fixing bug 1059
        if self.tex_name is not None and self.image_obj: 
            # self.image_obj cond is needed, for clear_esp_image() to work
            textureReady = True
            glBindTexture(GL_TEXTURE_2D, self.tex_name)
                # review: maybe this belongs in draw_plane instead?
            self._initTextureEnv() # sets texture params the way we want them
        else:
            textureReady = False
        drawPlane(self.fill_color, self.width, self.width, textureReady,
                  self.opacity, SOLID = True, 
                  pickCheckOnly = self.pickCheckOnly )

        hw = self.width/2.0
        corners_pos = [V(-hw,  hw, 0.0), 
                       V(-hw, -hw, 0.0), 
                       V( hw, -hw, 0.0), 
                       V( hw,  hw, 0.0)]
        drawLineLoop(color, corners_pos)  

        # Draw the ESP Image bbox.
        if self.show_esp_bbox:
            wo = self.image_offset
            eo = self.edge_offset
            drawwirecube(color, V(0.0, 0.0, 0.0), V(hw + eo, hw + eo, wo), 1.0) 
                #drawwirebox

            # This is for debugging purposes. This draws a green normal vector
            # using local space coords. [Mark 050930]
            if 0:
                from graphics.drawing.CS_draw_primitives import drawline
                drawline(green, V(0.0, 0.0, 0.0), V(0.0, 0.0, 1.0), 0, 3)

        glpane.kluge_reset_texture_mode_to_work_around_renderText_bug()

        glPopMatrix()

        # This is for debugging purposes. This draws a yellow normal vector
        # using model space coords. [Mark 050930]
        if 0:
            from graphics.drawing.CS_draw_primitives import drawline
            from utilities.constants import yellow
            drawline(yellow, self.center, self.center + self.planeNorm, 0, 3)