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


Python GL.glMaterialf方法代码示例

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


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

示例1: setMaterial

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMaterialf [as 别名]
    def setMaterial(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        mat = self.material
        GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, mat[self.ambi][0])
        diff = mat[self.diff][0]
        diff[3] = mat[self.opac][0]
        GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, mat[self.diff][0])
        GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, mat[self.spec][0])
        GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, mat[self.emis][0])
        GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, float(mat[self.shini][0]))

        GL.glColor4fv(mat[self.diff][0])
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:15,代码来源:MaterialEditor.py

示例2: glMaterialWithCheck

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glMaterialf [as 别名]
def glMaterialWithCheck(face, property, material, eps=0.001, check=True):
    """
    Only calls glMaterial if the material is different from he current value
    face can be GL_FRONT or GL_BACK
    propety can be GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR or GL_EMISSION
    material is a 3-sequence RGBA, Alpha values are only test for ambient and
    diffuse properties
    """
    global materialMemory

    #print 'glMaterialWithCheck', property, material
    
    if face==GL.GL_FRONT_AND_BACK:
        face=GL.GL_FRONT
    if property==GL.GL_SHININESS:
        matMem = materialMemory[face]
        if not check or fabs(matMem[4]-material) > eps:
            matMem[4] = material
            #GL.glMaterialfv( face, property, matMem[4] )
            GL.glMaterialf( face, property, float(matMem[4]) )
    else:
        if not material.flags.contiguous:
            material = Numeric.array(material,copy=1)
        propNum = viewerConst.propNum[property]
        matMem = materialMemory[face][propNum]
##         print 'DIFFERENCE'
##         print id(matMem), id(materialMemory[face][propNum])
##         print matMem
##         print material
##         print fabs(matMem[0]-material[0]) > eps
##         print fabs(matMem[1]-material[1]) > eps
##         print fabs(matMem[2]-material[2]) > eps
##         print (fabs(matMem[3]-material[3]) > eps and propNum in (0,1))
        if check:
            newCol = fabs(matMem[0]-material[0]) > eps or \
                     fabs(matMem[1]-material[1]) > eps or \
                     fabs(matMem[2]-material[2]) > eps or \
                     (fabs(matMem[3]-material[3]) > eps and propNum in (0,1))
        else:
            newCol = True
            
        if newCol:
            #GL.glMaterialfv( face, property, material.tolist() )
            #print 'SETTING'
            gllib.glMaterialfv( face, property, material)
            matMem[0] = material[0]
            matMem[1] = material[1]
            matMem[2] = material[2]
            matMem[3] = material[3]
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:51,代码来源:colorTool.py


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