当前位置: 首页>>代码示例>>Python>>正文


Python GL.glPushName方法代码示例

本文整理汇总了Python中opengltk.OpenGL.GL.glPushName方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPushName方法的具体用法?Python GL.glPushName怎么用?Python GL.glPushName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opengltk.OpenGL.GL的用法示例。


在下文中一共展示了GL.glPushName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
 def Draw(self):
     #print"Box.Draw"
     self.oldFPM = self.frontPolyMode
     if self.frontPolyMode == GL.GL_LINE:
         GL.glDisable(GL.GL_LIGHTING)
         #c is 8x3 array 
         c= self.vertexSet.vertices.array
         #lines parallel to x-axis should be red, y->blue and z->green
         col = ((1,0,0),(0,1,0),(0,0,1))
         #these groups of 4 pairs of points define lines parallel to x, y, and z axes
         alines=[[(c[0],c[1]),(c[2],c[3]),(c[4],c[5]),(c[6],c[7])],
             [(c[0],c[3]),(c[1],c[2]),(c[4],c[7]),(c[5],c[6])],
             [(c[0],c[4]),(c[1],c[5]),(c[3],c[7]),(c[2],c[6])]]
         namectr=0
         for i in range(3):
             if not self.inheritMaterial:
                 GL.glColor3fv(col[i])
             for vpairs in alines[i]:
                 GL.glPushName(namectr)
                 GL.glBegin(GL.GL_LINES)
                 GL.glVertex3dv(list(vpairs[0]))
                 GL.glVertex3dv(list(vpairs[1]))
                 GL.glEnd()
                 GL.glPopName()
                 namectr=namectr+1
         self.viewer.enableOpenglLighting()
         return 1
     else:
         return IndexedPolygons.Draw(self)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:31,代码来源:Box.py

示例2: pickDraw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def pickDraw(self):
        """called by the picking process to operate the selection
"""
        #print "colorMapLegend.pickDraw", self
        # we draw just flat quad of the insert2d
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPushMatrix()       
        #GL.glLoadIdentity()
        GL.glLoadMatrixf(self.viewer.currentCamera.pickMatrix) 
        GL.glOrtho(0, float(self.viewer.currentCamera.width),
                   0, float(self.viewer.currentCamera.height), -1, 1)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
        #GL.glColor3f(1,0,0)

        if self.resizeSpot is not None:
            GL.glPushName(1)
            GL.glBegin(GL.GL_QUADS)
            GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
                          float(self.resizeSpot[1]-self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
                          float(self.resizeSpot[1]+self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
                          float(self.resizeSpot[1]+self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
                          float(self.resizeSpot[1]-self.resizeSpotRadius))
            GL.glEnd()
            GL.glPopName()

        GL.glPushName(0)
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex2fv(self.polygonContour[0])
        GL.glVertex2fv(self.polygonContour[1])
        GL.glVertex2fv(self.polygonContour[2])
        GL.glVertex2fv(self.polygonContour[3])
        GL.glEnd()
        GL.glPopName()

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPopMatrix()
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPopMatrix()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:46,代码来源:colorMapLegend.py

示例3: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):
        n = self.vertexSet.normals.array
        c = self.vertexSet.vertices.array

        ang = self.angles
        if len(self.angles)==1:
            self._arcTemplate(self.anges[0])
            if self.materials[GL.GL_FRONT].binding[1]==viewerConst.PER_VERTEX:
                col = self.materials[GL.GL_FRONT].prop[1]
                for i in xrange(len(self.vertexSet)):
                    if len(self.radii)==1:
                        rad = self.radii[0]
                    else:
                        rad = self.radii[i]
                    GL.glPushName(i)
                    self.arcdraw( c[i], n[i], rad, col[i] )
                    GL.glPopName()
            else:
                col = self.materials[GL.GL_FRONT].prop[1][0]
                for i in xrange(len(self.vertexSet)):
                    if len(self.radii)==1:
                        rad = self.radii[0]
                    else:
                        rad = self.radii[i]
                    GL.glPushName(i)
                    self.arcdraw( c[i], n[i], rad, col )
                    GL.glPopName()
        else:
             if self.materials[GL.GL_FRONT].binding[1]==viewerConst.PER_VERTEX:
                col = self.materials[GL.GL_FRONT].prop[1]
                for i in xrange(len(self.vertexSet)):
                    if i==0 or ang[i]!=ang[i-1]:
                        self._arcTemplate(ang[i])
                    if len(self.radii)==1:
                        rad = self.radii[0]
                    else:
                        rad = self.radii[i]
                    GL.glPushName(i)
                    self.arcdraw( c[i], n[i], rad, col[i] )
                    GL.glPopName()
             else:
                col = self.materials[GL.GL_FRONT].prop[1][0]
                for i in xrange(len(self.vertexSet)):
                    if i==0 or ang[i]!=ang[i-1]:
                        self._arcTemplate(ang[i])
                    if len(self.radii)==1:
                        rad = self.radii[0]
                    else:
                        rad = self.radii[i]
                    GL.glPushName(i)
                    self.arcdraw( c[i], n[i], rad, col )
                    GL.glPopName()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:54,代码来源:Arcs3D.py

示例4: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):

        OVERALL, PER_VERTEX, PER_PART, PER_FACE = 10, 11, 12, 13
        #NONE, OVERALL, PER_VERTEX, PER_PART, PER_FACE = -1, 10, 11, 12, 13
        
        propConst = DejaVu.viewerConst.propConst
        noCol = 1
        vert = self.vertexSet.vertices.array
        if len(vert)==0: return
        if not self.stripBegin or len(self.stripBegin)==0: return


        if self.materials[GL.GL_FRONT] and not self.inheritMaterial:
            frontMat = fpProp = []
            frontMatBind = fpBind = []
            mat = self.materials[GL.GL_FRONT]
            for propInd in range(4):
                b, p = mat.GetProperty(propInd)
                fpProp.append(p)
                fpBind.append(b)
            fpProp.append(mat.prop[4])
            fpBind.append(mat.binding[4])

        else:
            frontMat = None
            frontMatBind = None

        if self.materials[GL.GL_BACK] and not self.inheritMaterial:
            backMat = bpProp = []
            backMatBind = bpBind = []
            mat = self.materials[GL.GL_BACK]
            for propInd in range(4):
                b, p = mat.GetProperty(propInd)
                bpProp.append(p)
                bpBind.append(b)
            bpProp.append(mat.prop[4])
            bpBind.append(mat.binding[4])

        else:
            backMat = None
            backMatBind = None

        if not self.frontAndBack is None:
            face = GL.GL_FRONT
        else:
            face = GL.GL_FRONT_AND_BACK

        n = self.normals
        if self.normals is None:    # overall color for no normals or lighting
            if frontMat:
                if frontMatBind[noCol] == OVERALL:
                    GL.glColor4fv( frontMat[noCol][0] )
        else:
            if len(self.normals)==1:             # overall normal
                GL.glNormal3dv(n[0])
            if frontMat:
                for j in range(5):               # overall materials
                    if frontMatBind[j] == OVERALL:
                        glMaterialWithCheck( face, propConst[j],
                                             frontMat[j][0] )
            if backMat and not self.frontAndBack:
                for j in range(5):
                    if backMatBind[j] == OVERALL:
                        glMaterialWithCheck( GL.GL_BACK, propConst[j],
                                             backMat[j][0] )

        self.isNewColor()
        #self.isNewMaterial(0,0,0)

        # loop over each strip
        sB = self.stripBegin
        sE = self.stripEnd
        self.sE = sE
        self.sB= sB
        for stripNum in range(len(sB)):
            #print 'stripNum',stripNum
            GL.glPushName(stripNum)
            GL.glBegin(GL.GL_TRIANGLE_STRIP)

            # per part material properties
            if frontMat:
                if frontMatBind[noCol] == PER_PART:
                    if self.isNewColor(c=frontMat[noCol][stripNum]):
                        GL.glColor4fv(frontMat[noCol][stripNum])

            if n is not None:
                if frontMat:
                    for j in range(5):
                        if frontMatBind[j]==PER_PART:
                            glMaterialWithCheck( face,
                                                 propConst[j],
                                                 frontMat[j][stripNum] )

                if backMat and not self.frontAndBack:
                    for j in range(5):
                        if backMatBind[j] ==  PER_PART:
                            glMaterialWithCheck( GL.GL_BACK,
                                                 propConst[j],
                                                 backMat[j][stripNum] )

#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:103,代码来源:triangle_strip.py

示例5: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):
        c = self.vertexSet.vertices.array
        if len(c)==0: return
        GL.glDisable(GL.GL_LIGHTING)

        if self.materials[GL.GL_FRONT]:
            mat = self.materials[GL.GL_FRONT]
            binding = self.materials[GL.GL_FRONT].binding[mat.diff]
        else:
            binding = viewerConst.OVERALL        

        if binding == viewerConst.INHERIT:
            for i in xrange(c.shape[0]): #loop over lines
                GL.glPushName(i)
                GL.glBegin(self.primitiveType)
                for v in c[i]:
                    #GL.glVertex3dv(v.tolist())
                    #gllib.glVertex3dv(v)
                    gllib.glVertex3fv(v)
                GL.glEnd()
                GL.glPopName()

        elif binding == viewerConst.OVERALL:
            if self.materials[GL.GL_FRONT]:
                col = mat.prop[mat.diff][0]
            GL.glColor4fv(col)
            for i in xrange(c.shape[0]): #loop over lines
                GL.glPushName(i)
                GL.glBegin(self.primitiveType)
                for v in c[i]:
                    #GL.glVertex3dv(v.tolist())
                    #gllib.glVertex3dv(v)
                    gllib.glVertex3fv(v)
                GL.glEnd()
                GL.glPopName()

        elif binding == viewerConst.PER_VERTEX:
            if self.materials[GL.GL_FRONT]:
                col = mat.prop[mat.diff]
            vi = 0
            for i in xrange(c.shape[0]):
                GL.glPushName(i)
                GL.glBegin(self.primitiveType)
                for v in c[i]:
                    GL.glColor4fv(col[vi])
                    vi = vi + 1
                    #GL.glVertex3dv(v.tolist())
                    #gllib.glVertex3dv(v)
                    gllib.glVertex3fv(v)
                GL.glEnd()
                GL.glPopName()

        elif binding == viewerConst.PER_PART: # i.e. line
            if self.materials[GL.GL_FRONT]:
                col = mat.prop[mat.diff]
            for i in xrange(c.shape[0]):
                GL.glColor4fv(col[i])
                GL.glPushName(i)
                GL.glBegin(self.primitiveType)
                for v in c[i]:
                    #GL.glVertex3dv(v.tolist())
                    #gllib.glVertex3dv(v)
                    gllib.glVertex3fv(v)
                GL.glEnd()
                GL.glPopName()

        #glEnable(GL_LIGHTING)
        if self.viewer is not None:
            self.viewer.enableOpenglLighting()
        return True
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:72,代码来源:Polylines.py

示例6: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):
        """ Draw function of the geom
return status 0 or 1
If you want fast rendering, you need to set self.templateDSPL
using MakeTemplate.
"""
        #print "Ellipsoids.Draw"
        
        assert self.templateDSPL is not None

        currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag')
        if currentcontext != self.templateDSPL[1]:
            warnings.warn("""draw failed because the current context is the wrong one""")
            #print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[1]
            return 0

        centers = self.vertexSet.vertices.array
        if len(centers) == 0: return
        scaling = self.scaling
        orientation = self.orientation
        vertices = self.vertexSet.vertices.array
        
        if len(vertices) != len(scaling) or len(vertices) != len(orientation):
            return

        if self.inheritMaterial:
            fp = None
            bp = None
        else:
            fp = self.materials[GL.GL_FRONT]
            if not self.frontAndBack:
                bp = self.materials[GL.GL_BACK]
                face = GL.GL_FRONT
            else:
                bp = None
                face = GL.GL_FRONT_AND_BACK

        for i in xrange(len(vertices)):
            GL.glPushName(i)

            if fp:
                for m in (0,1,2,3,4):
                    if fp.binding[m] != viewerConst.OVERALL:
                        glMaterialWithCheck( face,
                                             viewerConst.propConst[m],
                                             fp.prop[m][i] )
            if bp:
                for m in (0,1,2,3,4):
                    if bp.binding[m] != viewerConst.OVERALL:
                        glMaterialWithCheck( face,
                                             viewerConst.propConst[m],
                                             bp.prop[m][i] )

            GL.glPushMatrix()
            GL.glTranslatef(float(vertices[i][0]),
                            float(vertices[i][1]),
                            float(vertices[i][2]))
            GL.glMultMatrixf( orientation[i].ravel() )
            GL.glScalef(float(scaling[i][0]),
                        float(scaling[i][1]),
                        float(scaling[i][2]))
            #print '#%d'%self.templateDSPL[0], "glCallList Ellipsoids0"
            GL.glCallList(self.templateDSPL[0])
            GL.glPopMatrix()

            GL.glPopName()

        return True
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:70,代码来源:Ellipsoids.py

示例7: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):

        # for some reason, under Mac OS X, if I do not always set he material
        # only the first cylinder gets the right color (MS)
        if sys.platform=='darwin' \
          or DejaVu.preventIntelBug_BlackTriangles is True:
            self.checkMat = False
        else:
            self.checkMat = True

        if len(self.vertexSet.vertices) == 0:
            return

        if self.inheritMaterial:
            fp = None
            bp = None
            face = None
        else:
            mat = self.materials[GL.GL_FRONT]
            rmat = self.realFMat
            bind = [10,10,10,10]
            for pInd in range(4):
                bind[pInd], rmat.prop[pInd] = mat.GetProperty(pInd)
            rmat.prop[4] = mat.prop[4]
            rmat.prop[5] = mat.prop[5]
            rmat.binding[:4] = bind
            rmat.binding[4:] = rmat.binding[4:]
            fp = rmat
            #                fp = self.materials[GL.GL_FRONT]
            if fp:
                if self.frontAndBack:
                    face = GL.GL_FRONT_AND_BACK
                    bp = None
                else:
                    face = GL.GL_FRONT
                    mat = self.materials[GL.GL_BACK]
                    rmat = self.realBMat
                    bind = [10,10,10,10]
                    for pInd in range(4):
                        bind[pInd], rmat.prop[pInd]=mat.GetProperty(pInd)
                    rmat.prop[4] = mat.prop[4]
                    rmat.prop[5] = mat.prop[5]
                    rmat.binding[:4] = bind
                    rmat.binding[4:] = rmat.binding[4:]
                    bp = rmat

        c = self.vertexSet.vertices.array

        if self.oneRadius == viewerConst.NO:
            radii = self.vertexSet.radii.array
        else:
            radius = self.vertexSet.radii.array[0]

        pickName = 0
        for i in xrange(len(self.faceSet.faces.array)):
            #print 'CYLINDERS', i, '********************************'
            for j in xrange(len(self.faceSet.faces.array[i])-1):
                vi1 = self.faceSet.faces.array[i][j]
                vi2 = self.faceSet.faces.array[i][j+1]

                if fp:
                    fpp1 = [None,None,None,None,None]
                    fpp2 = [None,None,None,None,None]
                    for m in (0,1,2,3,4):
                        if fp.binding[m] == viewerConst.PER_VERTEX:
                            fpp1[m] = fp.prop[m][vi2]
                            fpp1[m] = array(fpp1[m],copy=1)
                            fpp2[m] = fp.prop[m][vi1]
                            fpp2[m] = array(fpp2[m],copy=1)
                        elif fp.binding[m] == viewerConst.PER_PART:
                            fpp2[m] = fpp1[m] = fp.prop[m][i]
                            fpp1[m] = array(fpp1[m],copy=1)
                            fpp2[m] = array(fpp2[m],copy=1)
                else:
                    fpp1 = fpp2 = None

                if bp and not self.frontAndBack:
                    bpp1 = [None,None,None,None,None]
                    bpp2 = [None,None,None,None,None]
                    for m in (0,1,2,3,4):
                        if bp.binding[m] == viewerConst.PER_VERTEX:
                            bpp1[m] = bp.prop[m][vi2]
                            bpp1[m] = array(bpp1[m],copy=1)
                            bpp2[m] = bp.prop[m][vi1]
                            bpp2[m] = array(bpp2[m],copy=1)
                        elif bp.binding[m] == viewerConst.PER_PART:
                            bpp2[m] = bpp1[m] = bp.prop[m][i]
                            bpp1[m] = array(bpp1[m],copy=1)
                            bpp2[m] = array(bpp2[m],copy=1)
                else:
                    bpp1 = bpp2 = None

                GL.glPushName(pickName)
                # compute point at base of cone
                vect = [c[vi2][0]-c[vi1][0],
                        c[vi2][1]-c[vi1][1],
                        c[vi2][2]-c[vi1][2]]
                norm = 1./math.sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2])
                vect = [vect[0]*norm, vect[1]*norm, vect[2]*norm]
                headBase = [c[vi2][0]-self.headLength*vect[0],
#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:103,代码来源:Cylinders.py

示例8: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):

        if len(self.vertexSet.vertices) == 0:
            return 0

        if self.inheritMaterial:
            fp = None
            bp = None
            face = None
        else:
            mat = self.materials[GL.GL_FRONT]
            rmat = self.realFMat
            bind = [10,10,10,10]
            for pInd in range(4):
                bind[pInd], rmat.prop[pInd] = mat.GetProperty(pInd)
            rmat.prop[4] = mat.prop[4]
            rmat.prop[5] = mat.prop[5]
            rmat.binding[:4] = bind
            rmat.binding[4:] = rmat.binding[4:]
            fp = rmat
            if fp:
                if self.frontAndBack:
                    face = GL.GL_FRONT_AND_BACK
                    bp = None
                else:
                    face = GL.GL_FRONT
                    mat = self.materials[GL.GL_BACK]
                    rmat = self.realBMat
                    bind = [10,10,10,10]
                    for pInd in range(4):
                        bind[pInd], rmat.prop[pInd]=mat.GetProperty(pInd)
                    rmat.prop[4] = mat.prop[4]
                    rmat.prop[5] = mat.prop[5]
                    rmat.binding[:4] = bind
                    rmat.binding[4:] = rmat.binding[4:]
                    bp = rmat


        c = self.vertexSet.vertices.array
        #if self.oneRadius == viewerConst.NO:
            #radii = self.vertexSet.radii.array

        pickName = 0
        for i in xrange(len(self.faceSet.faces.array)):
            for j in xrange(len(self.faceSet.faces.array[i])-1):
                vi1 = self.faceSet.faces.array[i][j]
                vi2 = self.faceSet.faces.array[i][j+1]
                #print vi1,vi2
                if fp:
                    fpp1 = [None,None,None,None,None]
                    fpp2 = [None,None,None,None,None]
                    for m in (0,1,2,3,4):
                        if fp.binding[m] == viewerConst.PER_VERTEX:
                            fpp1[m] = fp.prop[m][vi2]
                            # to make sure array is contiguous
                            fpp1[m] = array(fpp1[m],copy=1)
                            fpp2[m] = fp.prop[m][vi1]
                            fpp2[m] = array(fpp2[m],copy=1)
                        elif fp.binding[m] == viewerConst.PER_PART:
                            fpp2[m]= fpp1[m] = fp.prop[m][i]
                            fpp1[m] = array(fpp1[m],copy=1)
                            fpp2[m] = array(fpp2[m],copy=1)
                else:
                    fpp1 = fpp2 = None

                if bp and not self.frontAndBack:
                    bpp1 = [None,None,None,None,None]
                    bpp2 = [None,None,None,None,None]
                    for m in (0,1,2,3,4):
                        if bp.binding[m] == viewerConst.PER_VERTEX:
                            bpp1[m] = bp.prop[m][vi2]
                            bpp1[m] = array(bpp1[m],copy=1)
                            bpp2[m] = bp.prop[m][vi1]
                            bpp2[m] = array(bpp2[m],copy=1)
                        elif bp.binding[m] == viewerConst.PER_PART:
                            bpp2[m] = bpp1[m] = bp.prop[m][i]
                            bpp1[m] = array(bpp1[m],copy=1)
                else:
                    bpp1 = bpp2 = None

                GL.glPushName(pickName)
                self.arrowdraw(c[vi1], c[vi2],fpp1, bpp1, fpp2, bpp2,face)
                GL.glPopName()
                pickName = pickName +1
        return 1
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:87,代码来源:Arrows.py

示例9: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]
    def Draw(self):

        OVERALL, PER_VERTEX, PER_PART, PER_FACE = -1, 10, 11, 12, 13
        #NONE, OVERALL, PER_VERTEX, PER_PART, PER_FACE = -1, 10, 11, 12, 13
        propConst = DejaVu.viewerConst.propConst
        noCol = 1
        vert = self.vertexSet.vertices.array
        if len(vert)==0: return

        if self.materials[GL.GL_FRONT] and not self.inheritMaterial:
            mat = self.materials[GL.GL_FRONT]
            frontMat = fpProp = []
            frontMatBind = fpBind = []
            for propInd in range(4):
                b, p = mat.GetProperty(propInd)
                fpProp.append(p)
                fpBind.append(b)
            fpProp.append(mat.prop[4])
            fpBind.append(mat.binding[4])
#		frontMat = self.materials[GL.GL_FRONT].prop
#		frontMatBind = self.materials[GL.GL_FRONT].binding
        else:
            frontMat = None
            frontMatBind = None

        if self.materials[GL.GL_BACK] and not self.inheritMaterial:
            mat = self.materials[GL.GL_BACK]
            backMat = bpProp = []
            backMatBind = bpBind = []
            for propInd in range(4):
                b, p = mat.GetProperty(propInd)
                bpProp.append(p)
                bpBind.append(b)
            bpProp.append(mat.prop[4])
            bpBind.append(mat.binding[4])
#		backMat = self.materials[GL.GL_BACK].prop
#		backMatBind = self.materials[GL.GL_BACK].binding
        else:
            backMat = None
            backMatBind = None

##              texCoords = None
##  	    if hasattr(self.vertexSet, "texCoords"):
##  		if self.vertexSet.texCoords.status >= viewerConst.COMPUTED:
##  		    texCoords = self.vertexSet.texCoords.array

        if not self.frontAndBack is None:
            face = GL.GL_FRONT
        else:
            face = GL.GL_FRONT_AND_BACK

        if not self.normals:     # overall color for no normals or lighting
            if frontMat:
                if frontMatBind[noCol] == OVERALL:
                    GL.glColor4fv( frontMat[noCol][0] )
        else:
            if len(self.normals)==1:             # overall normal
                n = self.normals
                GL.glNormal3dv(n[0])
            if frontMat:
                for j in range(5):		     # overall materials
                    if frontMatBind[j] == OVERALL:
                        glMaterialWithCheck( face, propConst[j],
                                             frontMat[j][0] )
            if backMat and not self.frontAndBack:
                for j in range(5):
                    if backMatBind[j] == OVERALL:
                        glMaterialWithCheck( GL.GL_BACK, propConst[j],
                                             backMat[j][0] )

        self.isNewColor()
        #self.isNewMaterial(0,0,0)

        n = self.normals            

        # loop over each strip
        for stripNum in range(1,len(self.stripBegin)):
            c = vert[self.stripBegin[stripNum-1]:self.stripBegin[stripNum]]
            GL.glPushName(stripNum)
            GL.glBegin(GL.GL_QUAD_STRIP)

            # per part material properties
            if frontMat:
                if frontMatBind[noCol] == PER_PART:
                    if self.isNewColor(c=frontMat[noCol][stripNum-1]):
                        GL.glColor4fv(frontMat[noCol][stripNum-1])

            if n:
                if frontMat:
                    for j in range(5):
                        if frontMatBind[j]==PER_PART:
                            glMaterialWithCheck( face,
                                                 propConst[j],
                                                 frontMat[j][stripNum-1] )

                if backMat and not self.frontAndBack:
                    for j in range(5):
                        if backMatBind[j] ==  PER_PART:
                            glMaterialWithCheck( GL.GL_BACK,
                                                 propConst[j],
#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:103,代码来源:quad_strip.py

示例10: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPushName [as 别名]

#.........这里部分代码省略.........
                if fp.binding[m] == viewerConst.OVERALL:
                    glMaterialWithCheck( face,
                                         viewerConst.propConst[m],
                                         fpProp[m][0])
            if fp.binding[1] == viewerConst.OVERALL:
                GL.glColor4fv(colorFront[0])

            if fp:
                for m in (0,1,2,3,4):
                    if fp.binding[m] != viewerConst.OVERALL:
                        glMaterialWithCheck( face,
                                             viewerConst.propConst[m],
                                             fpProp[m][0])

                if fp.binding[1] != viewerConst.OVERALL:
                    GL.glColor4fv(colorFront[0])
            if bp:
                for m in (0,1,2,3,4):
                    if bp.binding[m] != viewerConst.OVERALL:
                        glMaterialWithCheck( GL.GL_BACK,
                                             viewerConst.propConst[m],
                                             bp.prop[m][0])

        #print self.name
        #if fp: print fp.prop[1], fp.binding
        #else: print
        
        if self.fastSpheres:
            #print "self.fastSpheres", self.fastSpheres
            if self.oneRadius == viewerConst.NO:
                radii = self.vertexSet.radii.array
                #FIXME: quick fix because can be called from base class Set
                # method after centers have been set BUT before radii have been
                # set
                if len(self.vertexSet.vertices) != len(radii):
                    return 0
            else:
                radii = Numeric.ones( centers.shape[0] ) * self.radius
            radii.shape = (-1,1)
            coords = Numeric.concatenate ( (centers, radii), 1 )

##             if not self.inheritMaterial:
##                 mat = self.materials[GL.GL_FRONT]
##                 fpProp = []
##                 for propInd in range(4):
##                     b, p = mat.GetProperty(propInd)
##                     fpProp.append(p)
##                 fpProp.append(mat.prop[4])
##                 #fpProp = self.materials[GL.GL_FRONT].prop[:5]
##             else:
##                 fpProp = None

            #print 'FUGU OVERWRITE COLOR', fpProp
            #import numpy
            #GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, numpy.array((.6,.6,.6,1), 'f'))
            #GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, numpy.array((1.,1.,1.,1), 'f'))
            #GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, numpy.array((.4,.4,.4,1), 'f'))
            #GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, numpy.array((0,0,0,1), 'f'))
            #GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 1.)

            status = glDrawSphereSet( 
                                  self.templateDSPL[0],
                                  coords.astype('f'),
                                  fpProp, #self.materials[GL.GL_FRONT].prop,
                                  highlight=self.highlight,
                                  )
            #print "Spheres, status: ", status
            return status
        else:
            resetMaterialMemory()
            #print "SLOW Spheres"
            if self.oneRadius == viewerConst.NO:
                radii = self.vertexSet.radii.array
            else:
                radii = Numeric.ones( centers.shape[0] ) * self.radius

            if len(self.vertexSet.vertices) != len(radii):
                return 0
            
            for i in xrange(centers.shape[0]):
                GL.glPushName(i)
                GL.glPushMatrix()
                GL.glTranslatef(float(centers[i][0]),
                                float(centers[i][1]),
                                float(centers[i][2]))
                if not self.oneRadius:
                    GL.glScalef(float(radii[i]),float(radii[i]),float(radii[i]))
                else:
                    GL.glScalef(float(self.radius), float(self.radius), float(self.radius))
                #print '#%d'%self.templateDSPL[0], "glCallList Spheres0"
                if fp:
                    for m in (0,1,2,3,4):
                        if fp.binding[m] != viewerConst.OVERALL:
                            glMaterialWithCheck( face,
                                                 viewerConst.propConst[m],
                                                 fp.prop[m][0], geom=self)
                GL.glCallList(self.templateDSPL[0])
                GL.glPopMatrix()
                GL.glPopName()
            return 1
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:104,代码来源:Spheres.py


注:本文中的opengltk.OpenGL.GL.glPushName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。