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


Python GL.glNormal3dv方法代码示例

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


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

示例1: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glNormal3dv [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

示例2: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glNormal3dv [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


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