本文整理汇总了Python中opengltk.OpenGL.GL.glPopName方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPopName方法的具体用法?Python GL.glPopName怎么用?Python GL.glPopName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glPopName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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)
示例2: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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()
示例3: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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()
示例4: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [as 别名]
#.........这里部分代码省略.........
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] )
# loop over each vertex in a strip
i = 0
for ind in range(sB[stripNum],sE[stripNum]):
if ind >= len(vert):
print 'ERROR',ind
v = vert[ind]
# normals for flat or smooth shading
if n is not None:
if self.shading==GL.GL_FLAT:
if i > 1:
GL.glNormal3dv(n[sB[stripNum]+i-(2*(stripNum+1))])
elif self.shading==GL.GL_SMOOTH:
GL.glNormal3fv(n[ind])
else:
pass
# per face (per triangle) material properties
if n is None:
if frontMat:
if frontMatBind[noCol] == PER_FACE:
if i > 1:
if self.isNewColor(c=frontMat[noCol][sB[stripNum]+i-(2*(stripNum+1))]):
GL.glColor4fv(frontMat[noCol][sB[stripNum]+i-(2*(stripNum+1))])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_FACE:
if i > 1:
glMaterialWithCheck( face,
propConst[k],
frontMat[k][sB[stripNum]+i-(2*(stripNum+1))] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_FACE:
if i > 1 and i%2==0:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][sB[stripNum]+i-(2*(stripNum+1))] )
# per vertex material properties
if n is None:
if frontMat:
if frontMatBind[noCol] == PER_VERTEX:
if self.isNewColor(c=frontMat[noCol][sB[stripNum]+i]):
GL.glColor4fv(frontMat[noCol][sB[stripNum]+i])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_VERTEX:
glMaterialWithCheck( face,
propConst[k],
frontMat[k][sB[stripNum]+i] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_VERTEX:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][sB[stripNum]+i] )
# draw vertex
#GL.glVertex3dv(v)
gllib.glVertex3fv(v)
i = i + 1
GL.glEnd()
GL.glPopName()
return 1
示例5: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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
示例6: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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
示例7: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [as 别名]
#.........这里部分代码省略.........
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],
c[vi2][1]-self.headLength*vect[1],
c[vi2][2]-self.headLength*vect[2]]
if self.oneRadius:
# cylinder
self.cyldraw(c[vi1], headBase,
radius, radius,
fpp1, bpp1, fpp2, bpp2, face)
# cone
self.cyldraw(headBase, c[vi2],
0.0, radius*self.headRadius,
fpp1, bpp1, fpp2, bpp2, face)
else:
if vi1 < vi2:
self.cyldraw(c[vi1], c[vi2],
radii[vi2], radii[vi1],
fpp1, bpp1, fpp2, bpp2, face)
else:
self.cyldraw(c[vi1], c[vi2],
radii[vi1], radii[vi2],
fpp1, bpp1, fpp2, bpp2, face)
GL.glPopName()
pickName = pickName +1
#print 'CYLINDERS done'
return 1
示例8: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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
示例9: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [as 别名]
#.........这里部分代码省略.........
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],
backMat[j][stripNum-1] )
# loop over each vertex in a strip
i = 0
for v in c:
if n:
if self.shading==GL.GL_FLAT:
if i > 1 and i%2==0:
GL.glNormal3dv(n[(self.stripBegin[stripNum-1]+i-(2*stripNum))/2])
elif self.shading==GL.GL_SMOOTH:
GL.glNormal3dv(n[self.stripBegin[stripNum-1]+i])
else:
pass
# per face (per triangle) material properties
if not n:
if frontMat:
if frontMatBind[noCol] == PER_FACE:
if i > 1 and i%2==0:
if self.isNewColor(c=frontMat[noCol][(self.stripBegin[stripNum-1]+i-(2*stripNum))/2]):
GL.glColor4fv(frontMat[noCol][(self.stripBegin[stripNum-1]+i-(2*stripNum))/2])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_FACE:
if i > 1 and i%2==0:
glMaterialWithCheck( face,
propConst[k],
frontMat[k][(self.stripBegin[stripNum-1]+i-(2*stripNum))/2] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_FACE:
if i > 1 and i%2==0:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][(self.stripBegin[stripNum-1]+i-(2*stripNum))/2] )
# per vertex material properties
if not n:
if frontMat:
if frontMatBind[noCol] == PER_VERTEX:
if self.isNewColor(c=frontMat[noCol][self.stripBegin[stripNum-1]+i]):
GL.glColor4fv(frontMat[noCol][self.stripBegin[stripNum-1]+i])
else:
if frontMat:
for k in range(5):
if frontMatBind[k] == PER_VERTEX:
glMaterialWithCheck( face, propConst[k],
frontMat[k][self.stripBegin[stripNum-1]+i] )
if backMat and not self.frontAndBack:
for k in range(5):
if backMatBind[k] == PER_VERTEX:
glMaterialWithCheck( GL.GL_BACK,
propConst[k],
backMat[k][self.stripBegin[stripNum-1]+i] )
# draw vertex
GL.glVertex3dv(v)
i = i + 1
GL.glEnd()
GL.glPopName()
return 1
示例10: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopName [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