コード例 #1
0
ファイル: axes.py プロジェクト: ysbwbyw/quaternion-sim
    def draw_arrow(self, color):

        # Set material
        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color)
        #glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color)
        #glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [1, 1, 1, 0.0])
        #glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20)

        # Draw cylinder
        quad = gluNewQuadric()
        gluQuadricDrawStyle(quad, GLU_FILL)
        gluQuadricTexture(quad, True)
        gluQuadricNormals(quad, GLU_SMOOTH)
        gluCylinder(quad, self.size / 30, self.size / 30,
                    self.size * 0.8, 20, 20)

        # Move to the arrowhead position
        glTranslatef(0, 0, self.size * 0.8)

        # Draw arrowhead
        gluQuadricDrawStyle(quad, GLU_FILL)
        gluQuadricTexture(quad, True)
        gluQuadricNormals(quad, GLU_SMOOTH)
        gluCylinder(quad, self.size / 15, 0,
                    self.size * 0.2, 20, 20)

        # Revert to the original position
        glTranslatef(0, 0, -self.size * 0.8)
コード例 #2
0
def make_Cylinder():  #2
    #glNewList(G_OBJ_PLANE, GL_COMPILE)                             #2
    #glLineWidth(50.0)                                              #2
    #glColor3f(0.0, 0.0, 0.0)                                       #2
    #glBegin(GL_LINES)                                              #2
    #glVertex3f(1.0, 0.0, 0.0)                                      #2
    #glVertex3f(0.0, 1.0, 0.0)                                      #2
    #glEnd()                                                        #2
    #2
    #glColor3f(1.0, 0.0, 0.0)                                       #2
    #glBegin(GL_TRIANGLE_STRIP)                                     #2
    #glVertex3f(1.000000 ,0.000000, 0.000000)
    #glVertex3f(0.000000, 1.000000, 0.000000)
    #glVertex3f(1.000000, 1.000000, 1.000000)
    #glEnd()

    glNewList(G_OBJ_CYLINDER, GL_COMPILE)

    quad = gluNewQuadric()

    gluCylinder(quad, 0.2, 0.2, 2.0, 32, 32)  #半径半径长切分次数切分次数

    #glRotatef(2, 0, 0, 1)

    gluDeleteQuadric(quad)

    glEndList()  #2
コード例 #3
0
ファイル: gui.py プロジェクト: steabert/molito
 def drawBallAndStick(self, r_ball = 0.4, r_stick = 0.1):
     res = self.quality * 6
     quad = gluNewQuadric()
     glNewList(1,GL_COMPILE)
     for i in range(self.mol.natoms):
         glPushMatrix()
         # set atom color
         r,g,b = self.mol.col[i]
         glColor3f(r,g,b)
         # translate to atom position
         x,y,z = self.mol.pos[i]
         glTranslatef(x,y,z)
         # draw the atom
         gluSphere(quad, r_ball*self.mol.rad[i], res, res)
         glPopMatrix()
     for i,c in enumerate(self.mol.con):
         m = c[0]
         n = c[1]
         glPushMatrix()
         # set bond color
         r,g,b = self.mol.col[m]
         glColor3f(r,g,b)
         # translate to atom position
         x,y,z = self.mol.pos[m]
         glTranslatef(x,y,z)
         # draw the bond
         v = self.mol.pos[n] - self.mol.pos[m]
         angle = math.acos(numpy.dot([0.0,0.0,1.0], v)/self.mol.dist[i])*180./math.pi
         x,y,z = numpy.cross([0.0,0.0,1.0], v)
         glRotatef(angle,x,y,z)
         h = self.mol.dist[i] * self.mol.rad[m] / (self.mol.rad[m] + self.mol.rad[n])
         gluCylinder(quad, r_stick, r_stick, h, res, res)
         glPopMatrix()
     glEndList()
コード例 #4
0
ファイル: imu_gl_widget.py プロジェクト: smunix/brickv
 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()
コード例 #5
0
 def paintCylinder(self, diameter, height):
     r = diameter / 70.
     height = 2 * height / 70.
     glColor3f(0., 0., 0.)
     glPushMatrix()
     glTranslatef(*self.offsets)  # move down
     glRotatef(-90., 1., 0., 0.)
     quadric = gluNewQuadric()
     gluQuadricDrawStyle(quadric, GLU_LINE)
     slices = max(int(round(r * 32)), 15)
     gluCylinder(quadric, r, r, height, slices, 1)
     glPopMatrix()
コード例 #6
0
 def paintArrow(self, direction, color):
     d = 0.01
     length = 0.5
     glPushMatrix()
     glColor3fv(color)
     if direction == 'n':
         glTranslatef(0., -1.1, 2.)
     elif direction == 'gamma':
         glTranslatef(1.2, -1.1, 0.)
     else:
         glTranslatef(-1., -1., 1.)
     quadric = gluNewQuadric()
     if direction in ('x', 'gamma'):
         glRotatef(90., 0., 1., 0.)
     elif direction == 'y':
         glRotatef(90, -1., 0., 0.)
     elif direction in ('z', 'n'):
         glRotatef(180, -1, 0, 0)
     gluCylinder(quadric, d, d, length, 48, 48)
     glTranslatef(0, 0, length)
     glutSolidCone(2. * d, 0.1, 48, 48)
     glPopMatrix()
コード例 #7
0
 def drawBallAndStick(self, r_ball=0.4, r_stick=0.1):
     res = self.quality * 6
     quad = gluNewQuadric()
     glNewList(1, GL_COMPILE)
     for i in range(self.mol.natoms):
         glPushMatrix()
         # set atom color
         r, g, b = self.mol.col[i]
         glColor3f(r, g, b)
         # translate to atom position
         x, y, z = self.mol.pos[i]
         glTranslatef(x, y, z)
         # draw the atom
         gluSphere(quad, r_ball * self.mol.rad[i], res, res)
         glPopMatrix()
     for i, c in enumerate(self.mol.con):
         m = c[0]
         n = c[1]
         glPushMatrix()
         # set bond color
         r, g, b = self.mol.col[m]
         glColor3f(r, g, b)
         # translate to atom position
         x, y, z = self.mol.pos[m]
         glTranslatef(x, y, z)
         # draw the bond
         v = self.mol.pos[n] - self.mol.pos[m]
         angle = math.acos(
             numpy.dot([0.0, 0.0, 1.0], v) /
             self.mol.dist[i]) * 180. / math.pi
         x, y, z = numpy.cross([0.0, 0.0, 1.0], v)
         glRotatef(angle, x, y, z)
         h = self.mol.dist[i] * self.mol.rad[m] / (self.mol.rad[m] +
                                                   self.mol.rad[n])
         gluCylinder(quad, r_stick, r_stick, h, res, res)
         glPopMatrix()
     glEndList()
コード例 #8
0
ファイル: cylinder.py プロジェクト: ComSciCtr/vroom
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)
コード例 #9
0
ファイル: vis_backends.py プロジェクト: molmod/zeobuilder
 def draw_cone(self, radius1, radius2, length, quality):
     gluCylinder(self.quadric, radius1, radius2, length, quality, 1)
コード例 #10
0
ファイル: vis_backends.py プロジェクト: molmod/zeobuilder
 def draw_cylinder(self, radius, length, quality):
     gluCylinder(self.quadric, radius, radius, length, quality, 1)
コード例 #11
0
ファイル: object3D.py プロジェクト: softtrainee/arlab
 def _cylinder_(self, r, h, rotate=True):
     '''
     '''
     if rotate:
         glRotatef(90, 1, 0, 0)
     gluCylinder(gluNewQuadric(), r, r, h, xseg, yseg)
コード例 #12
0
 def draw_cone(self, radius1, radius2, length, quality):
     gluCylinder(self.quadric, radius1, radius2, length, quality, 1)
コード例 #13
0
 def draw_cylinder(self, radius, length, quality):
     gluCylinder(self.quadric, radius, radius, length, quality, 1)