示例#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
文件: sphere.py 项目: ComSciCtr/vroom
def sphere(radius, **kwargs):
   ''' Draw a sphere with the 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()
   
   # Setup the quadric draw style (line or fill)
   _set_draw_style(style)

   # Draw the sphere
   gluSphere(quadric, radius, SphereRes['slices'], SphereRes['stacks'])

   # Clean up texture data if specified
   if texture:
      texture.unbind()
      gluQuadricTexture(quadric, False)
示例#3
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)