本文整理汇总了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])
示例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]