示例#1
0
文件: disk.py 项目: ComSciCtr/vroom
def disk(radius, **kwargs):
   ''' Draw a disk with given radius. '''

   # Get any keyword arguments 
   style   = kwargs.get('style', 'wireframe')
   texture = kwargs.get('texture', None)

   quadric = _get_quadric()

   # Setup texture if specified
   if texture:
      style = 'solid'
      gluQuadricTexture(quadric, True)
      texture.bind()
   
   # Set the quadric draw style (line or fill)
   _set_draw_style(style)

   # Draw the disk
   gluDisk(quadric, 0, radius, DiskRes['slices'], DiskRes['loops'])

   # Clean up texture data if specified
   if texture:
      texture.unbind()
      gluQuadricTexture(quadric, False)
示例#2
0
 def draw_pin(self, x, y):
     glPushMatrix()
     glColor3f(1.0, 1.0, 0.0)
     glTranslatef(x, 0.0, -y) 
     glRotatef(-90, 1.0, 0.0, 0.0)
     obj = gluNewQuadric()
     gluCylinder(obj, 0.05, 0.05, 0.5, 10, 10)
     glPushMatrix()
     gluDisk(obj, 0.0, 0.05, 10, 10)
     glTranslatef(0.0, 0.5, 0.0) 
     glPopMatrix()
     glPopMatrix()
示例#3
0
文件: draw.py 项目: gavine199/pymt
def drawCircle(pos=(0, 0), radius=1.0, linewidth=0):
    '''Draw a simple circle

    :Parameters:
        `pos`: tuple, default to (0, 0)
            Position of circle
        `radius`: float, default to 1.0
            Radius of circle
    '''
    x, y = pos[0], pos[1]
    with gx_matrix:
        glTranslatef(x, y, 0)
        glScalef(radius, radius, 1.0)
        if linewidth > 0:
            gluDisk(gluNewQuadric(), 1 - linewidth / float(radius), 1, 32, 1)
        else:
            gluDisk(gluNewQuadric(), 0, 1, 32, 1)
示例#4
0
文件: draw.py 项目: imc/pymt
def drawCircle(pos=(0,0), radius=1.0, linewidth=0):
    '''Draw a simple circle

    :Parameters:
        `pos` : tuple, default to (0, 0)
            Position of circle
        `radius` : float, default to 1.0
            Radius of circle
    '''
    x, y = pos[0], pos[1]
    with gx_matrix:
        glTranslatef(x, y, 0)
        glScalef(radius, radius, 1.0)
        if linewidth > 0:
            gluDisk(gluNewQuadric(), 1-linewidth/float(radius), 1, 32,1)
        else:
            gluDisk(gluNewQuadric(), 0, 1, 32,1)
示例#5
0
    def OnDraw(self):
        if not self.drawing:
            return
        # clear color and depth buffers
        glClear(GL_COLOR_BUFFER_BIT)

        posx = 50.0
        posy = 50.0
        direction = 45
        size = 10

        #draw food
        glColor3f(0.0, 0.0, 1.0)
        for food in self.model.fooditems:
            # position viewer
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()

            # position object
            glTranslatef(food.x, food.y, 0)  #translation third
            glScalef(food.size, food.size, food.size)  #scale second

            gluDisk(self.quadricObject, 0, 0.5, 16, 1)

        #draw animals
        glColor3f(1.0, 1.0, 1.0)
        for forager in self.model.foragers:
            # position viewer
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()

            # position object
            glTranslatef(forager.x, forager.y, 0)  #translation third
            glScalef(forager.size, forager.size, forager.size)  #scale second
            #glRotatef(degrees(particle.rhoRad), 0, 0, 1) #rotation first

            gluDisk(self.quadricObject, 0, 0.5, 16, 1)

        self.SwapBuffers()
示例#6
0
def cylinder(radius, height, **kwargs):
    """ Draw a cylinder with given radius and height."""

    # Get any keyword arguments
    style = kwargs.get("style", "wireframe")
    texture = kwargs.get("texture", None)

    quadric = _get_quadric()

    # Setup texture if specified
    if texture:
        style = "solid"
        gluQuadricTexture(quadric, True)
        texture.bind()

    # Set the quadric draw style (line or fill)
    _set_draw_style(style)

    # Draw the bottom end of the cylinder
    glFrontFace(GL_CW)
    gluDisk(quadric, 0, radius, DiskRes["slices"], DiskRes["loops"])
    glFrontFace(GL_CCW)

    # Draw the body of the cylinder
    gluCylinder(quadric, radius, radius, height, CylinderRes["slices"], CylinderRes["stacks"])

    # Draw the top end of the cylinder
    glPushMatrix()
    translateZ(height)
    gluDisk(quadric, 0, radius, DiskRes["slices"], DiskRes["loops"])
    glPopMatrix()

    # Clean up texture data if specified
    if texture:
        texture.unbind()
        gluQuadricTexture(quadric, False)
示例#7
0
 def draw_disk(self, radius, quality):
     gluDisk(self.quadric, 0, radius, quality, 1)
示例#8
0
 def _disk_(self, radius=1, inner_radius=0):
     '''
     '''
     gluDisk(gluNewQuadric(), inner_radius, radius, xseg, yseg)
示例#9
0
 def draw_disk(self, radius, quality):
     gluDisk(self.quadric, 0, radius, quality, 1)