本文整理汇总了Python中opengltk.OpenGL.GL.glTranslatef方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glTranslatef方法的具体用法?Python GL.glTranslatef怎么用?Python GL.glTranslatef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glTranslatef方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initProjection
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def initProjection(self):
GL.glMatrixMode (GL.GL_PROJECTION)
GL.glLoadIdentity ()
GL.glOrtho(-10., 10., -10., 10., -10., 10.)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glTranslatef(0, 0, 10.0)
示例2: arcdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def arcdraw(self, x, n, radius, colxf=None):
# determine scale and rotation of template
import math
sz=0.0
y = [0, 0, 0]
for i in (0,1,2):
y[i] = x[i]+n[i]
for i in (0,1,2):
sz=sz+(x[i]-y[i])*(x[i]-y[i])
sz = sqrt(sz)
if sz==0.0:
return
rx = -180.0*acos((y[2]-x[2])/sz)/pi
rz = -180.0*atan2(y[0]-x[0],y[1]-x[1])/pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0:
GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
GL.glScalef(float(radius),float(radius),float(sz))
# draw circle
GL.glColor4fv(colxf)
GL.glBegin(GL.GL_LINE_STRIP)
for i in range(self.nsegments+1):
GL.glVertex3fv(self.v[i])
GL.glEnd()
GL.glPopMatrix()
示例3: arrowdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def arrowdraw(self, x, y, colxf=None, colxb=None,
colyf=None, colyb=None,face=None):
# draw a cylinder going from x to y
# col for materials
# face can be GL_FRONT_AND_BACK or something else
# determine scale and rotation of template
import math
sz=0.0
for i in (0,1,2): sz=sz+(x[i]-y[i])*(x[i]-y[i])
if sz <= 0.0: return
sz = math.sqrt(sz)
rx = -180.0*math.acos((y[2]-x[2])/sz)/math.pi
dx = y[0]-x[0]
dy = y[1]-x[1]
if math.fabs(dx) < 0.00001 and math.fabs(dy) < 0.00001:
rz = 0.0
else:
rz = -180.0*math.atan2(dx,dy)/math.pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0: GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
# draw arrow
GL.glBegin(GL.GL_LINES)
if colxf:
for m in (0,1,2,3,4):
if colxf[m] is not None:
glMaterialWithCheck( face, viewerConst.propConst[m],
colxf[m] )
if colxb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colxb[m] is not None:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colxb[m] )
GL.glVertex3f(float(self.v[0][0]), float(self.v[0][1]), float(self.v[0][2]*sz))
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]), float(self.v[1][2]*sz))
for i in range(self.npoly):
h = i+2
vx = self.v[h]
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]),
float(self.v[1][2]*sz))
GL.glVertex3f(float(vx[0]*sz), float(vx[1]*sz), float(vx[2]*sz))
GL.glEnd()
GL.glPopMatrix()
示例4: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def Draw(self):
#print "Sticker.Draw", self
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
Insert2d.Draw(self)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_LIGHTING);
lLabelbounds = self.calculateSize()
width = self.size[0]
height = self.size[1]
fullWidth = self.viewer.currentCamera.width
fullHeight = self.viewer.currentCamera.height
# we want the anchor of the image to be at the given position
posxFromLeft = self.position[0] * fullWidth - self.anchor[0] * width
posyFrombottom = (1.-self.position[1]) * fullHeight - (1.-self.anchor[1]) * height
posxFromLeft = int(floor( posxFromLeft ) )
posyFrombottom = int(floor( posyFrombottom ) )
if (self.position[1] == 0.):
posyFrombottom -= 1
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
GL.glTranslatef(float(posxFromLeft), float(posyFrombottom), 0)
self.drawSticker(lLabelbounds)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnable(GL.GL_LIGHTING);
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
return 1
示例5: initProjection
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def initProjection(self):
""" guillaume: prepare the opengl matrices
for drawing the widget
(for instance the sliders in the case of the MaterialEditor)
"""
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
GL.glMatrixMode (GL.GL_PROJECTION)
GL.glLoadIdentity ()
GL.glOrtho(0., 1., 0., 1., -2.5, 2.5)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
GL.glTranslatef(0, 0, 2.0)
示例6: DrawStuff
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def DrawStuff ():
GL.glClear (GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
# set up some matrices so that the object spins with the mouse
GL.glPushMatrix ()
GL.glTranslatef (0.0, 0.0, -80.0)
GL.glRotatef (lastx, 0.0, 1.0, 0.0)
GL.glRotatef (lasty, 1.0, 0.0, 0.0)
# Phew. FINALLY, Draw the polycylinder --
#gle.glePolyCylinder (NPTS, points, colors, 2.3)
gle.glePolyCylinder (points, colors, 2.3)
GL.glPopMatrix ()
GLUT.glutSwapBuffers ()
示例7: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def drawSticker(self, lLabelbounds):
if self.framePolygonMode != GL.GL_NONE:
lenFrameColor = len(self.frameColor)
if lenFrameColor == 4:
GL.glColor4fv(self.frameColor)
elif lenFrameColor == 3:
GL.glColor3fv(self.frameColor)
GL.glPolygonMode(GL.GL_FRONT, self.framePolygonMode)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(0, 0)
GL.glVertex2f(float(self.size[0]), 0)
GL.glVertex2f(float(self.size[0]), float(self.size[1]))
GL.glVertex2f(0, float(self.size[1]))
GL.glEnd()
GL.glScalef(float(self.fontScales[0]),
float(self.fontScales[1]),
0)
GL.glTranslatef(float(self.frameSpace[0]),
float(self.frameSpace[1]),
0)
# this corrects the glf draw function to start the label at the proper position
GL.glTranslatef(1, float(-lLabelbounds[1]), 0)
lenFontColor = len(self.fontColor)
if lenFontColor == 4:
GL.glColor4fv(self.fontColor)
elif lenFontColor == 3:
GL.glColor3fv(self.fontColor)
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
if self.wireFont in [0, False]:
glf.glfDrawSolidString(self.label)
else:
glf.glfDrawWiredString(self.label)
示例8: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
#.........这里部分代码省略.........
if verticalLegend is True:
if leftOrBelowLabels is True:
lRoomLeftToLabel = -fontScaleHalf + lRoomToLegendCloseLongSide
lRoomLeftToName = -fontScaleHalf + lRoomToLegendFarLongSide - lNameWidth
lRoomLeftToUnit = -fontScaleHalf + lRoomToLegendFarLongSide - lUnitWidth
lRoomBelowName = -fontScaleHalf + roomBelowLegend - lMaxLabelsHeight - lNameHeight
lRoomBelowUnit = fontScaleHalf + roomBelowLegend + legendLongSide + lMaxLabelsHeight
else:
lRoomLeftToLabel = fontScaleHalf + lRoomToLegendFarLongSide
lRoomLeftToName = fontScaleHalf + lRoomToLegendCloseLongSide
lRoomLeftToUnit = lRoomLeftToName
lRoomBelowName = -fontScaleHalf + roomBelowLegend - lMaxLabelsHeight - lNameHeight
lRoomBelowUnit = fontScaleHalf + roomBelowLegend + legendLongSide + lMaxLabelsHeight
else:
if leftOrBelowLabels is True:
lRoomBelowLabel = -fontScaleHalf + lRoomToLegendFarLongSide \
- legendShortSide - lMaxLabelsHeight
lRoomBelowName = lRoomToLegendCloseLongSide + legendShortSideHalf \
- lMaxNameUnitHeightHalf
else:
lRoomBelowLabel = fontScaleHalf + lRoomToLegendCloseLongSide \
+ legendShortSide
lRoomBelowName = lRoomToLegendCloseLongSide + legendShortSideHalf \
- lMaxNameUnitHeightHalf
lRoomBelowUnit = lRoomBelowName
lRoomLeftToName = -fontScaleHalf + lRoomToLegendCloseShortSide - lNameWidth
lRoomLeftToUnit = fontScaleHalf + lRoomToLegendFarShortSide
# set the color of the text
GL.glColor3fv(labelColor2)
# print the legend name
GL.glPushMatrix()
GL.glTranslatef(
float(lRoomLeftToName+fontScale),
float(lRoomBelowName-lNameMinAndMax[1]),
0)
GL.glScalef(float(fontScale), float(fontScale), 0);
glf.glfDrawSolidString(name)
GL.glPopMatrix()
if unit is not None and (len(unit) > 0):
GL.glPushMatrix()
GL.glTranslatef(
float(lRoomLeftToUnit+fontScale),
float(lRoomBelowUnit-lUnitMinAndMax[1]),
0)
GL.glScalef(float(fontScale), float(fontScale), 1);
glf.glfDrawSolidString(unit)
GL.glPopMatrix()
if mini is not None and maxi is not None:
i = 0
for v in lOnScreenLabelValues:
#calculate label position
lLabel = "%.*g" % (significantDigits,v)
lStep = (v - mini) * lUnitStep
GL.glPushMatrix()
if verticalLegend:
if leftOrBelowLabels:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale-lLabelsWidth[i]),
float(roomBelowLegend-(lLabelsHeight[i]/2+lLabelsMinAndMax[i][1])+lStep),
0)
else:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale),
示例9: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [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
示例10: cyldrawWithInterpolatedColors
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def cyldrawWithInterpolatedColors(self,
x, y, radx, rady, colxf=None, colxb=None,
colyf=None, colyb=None, face=None, **kw):
# draw a cylinder going from x to y with radii rx, and ry and materials
# colxf and colxb for front and back mterial in x
# colyf and colyb for front and back mterial in y
# face can be GL_FRONT_AND_BACK or something else
# determine scale and rotation of template
import math
sz=0.0
for i in (0,1,2): sz=sz+(x[i]-y[i])*(x[i]-y[i])
if sz <= 0.0: return
sz = math.sqrt(sz)
valueCos = (y[2]-x[2])/sz
valueCos = min(valueCos, 1)
valueCos = max(valueCos, -1)
rx = -180.0*math.acos(valueCos)/math.pi
dx = y[0]-x[0]
dy = y[1]-x[1]
if math.fabs(dx) < 0.00001 and math.fabs(dy) < 0.00001:
rz = 0.0
else:
rz = -180.0*math.atan2(dx,dy)/math.pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0: GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
# draw cylinder
GL.glBegin(GL.GL_QUAD_STRIP)
for i in range(self.npoly+1):
if self.invertNormals:
GL.glNormal3fv(-self.n[i])
else:
GL.glNormal3fv(self.n[i])
if colxf:
for m in (0,1,2,3,4):
if colxf[m] is not None:
#print "colxf[m]",type(colxf[m])
#print 'AAAAA', colxf[m]
glMaterialWithCheck( face, viewerConst.propConst[m],
colxf[m], check=self.checkMat )
if colxf[1] is not None:
GL.glColor4fv(colxf[1])
if colxb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colxb[m] is not None:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colxb[m], check=self.checkMat )
vx = self.v[i][0]
GL.glVertex3f(float(vx[0]*radx), float(vx[1]*radx), float(vx[2]*sz))
if colyf:
for m in (0,1,2,3,4):
if colyf[m] is not None:
#print 'BBBBB', colyf[m]
glMaterialWithCheck( face, viewerConst.propConst[m],
colyf[m], check=self.checkMat )
if colyf[1] is not None:
GL.glColor4fv(colyf[1])
if colyb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colyb[m] is not None:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colyb[m], check=self.checkMat )
vy = self.v[i][1]
GL.glVertex3f(float(vy[0]*rady), float(vy[1]*rady), float(vy[2]*sz))
GL.glEnd()
GL.glPopMatrix()
示例11: cyldrawWithSharpColorBoundaries
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def cyldrawWithSharpColorBoundaries(self,
x, y, radx, rady,
colxf=None, colxb=None,
colyf=None, colyb=None, face=None,
highlightX=0, highlightY=0):
# determine scale and rotation of template
import math
sz=0.0
for i in (0,1,2):
sz=sz+(x[i]-y[i])*(x[i]-y[i])
if sz <= 0.0: return
sz = math.sqrt(sz)
sz2 = sz * .5
valueCos = (y[2]-x[2])/sz
valueCos = min(valueCos, 1)
valueCos = max(valueCos, -1)
rx = -180.0*math.acos(valueCos)/math.pi
dx = y[0]-x[0]
dy = y[1]-x[1]
if math.fabs(dx) < 0.00001 and math.fabs(dy) < 0.00001:
rz = 0.0
else:
rz = -180.0*math.atan2(dx,dy)/math.pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0:
GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
if colyf:
for m in (0,1,2,3,4):
if colyf[m] is not None:
glMaterialWithCheck( face, viewerConst.propConst[m],
colyf[m], check=self.checkMat)
if colyf[1] is not None:
GL.glColor4fv(colyf[1])
if colyb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colyb[m] is not None:
self.checkMat = 0
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colyb[m], check=self.checkMat)
# this tests (colxf==colyf)
self.checkMat = 1
idem = (highlightX == highlightY)
if idem is True:
if colxf is None:
if colyf is not None:
idem = False
else:
if colyf is None:
idem = False
else:
lencol = len(colxf)
if lencol != len(colyf):
idem = False
else:
for i in range(lencol):
if colxf[i] is not None:
if bool(numpy.alltrue(colxf[i] == colyf[i])) is False:
idem = False
break
if idem is True:
if colxb is None:
if colyb is not None:
idem = False
else:
if colyb is None:
idem = False
else:
lencol = len(colxb)
if lencol != len(colyb):
idem = False
else:
for i in range(lencol):
if colxb[i] is not None:
if bool(numpy.alltrue(colxb[i] == colyb[i])) is False:
idem = False
break
quality = self.quality * 5
if idem is True:
if highlightX != 0:
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
solidCylinder(float(rady), float(radx), sz, quality, 1, self.invertNormals)
GL.glStencilFunc(GL.GL_ALWAYS, 0, 1)
else:
solidCylinder(float(rady), float(radx), sz, quality, 1, self.invertNormals)
else:
midRadius = (radx + rady) * .5
if highlightX != 0:
GL.glStencilFunc(GL.GL_ALWAYS, 1, 1)
solidCylinder(midRadius, float(radx), sz2, quality, 1, self.invertNormals)
GL.glStencilFunc(GL.GL_ALWAYS, 0, 1)
else:
#.........这里部分代码省略.........
示例12: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [as 别名]
def DisplayFunction(self):
"""Draw a square with diagonals to represent the clipping plane
"""
#print "ClippingPlane.DisplayFunction"
#trans = self.eqn[3]*(self.eqn[:3]*self.n)
resetMaterialMemory()
trans = self.translation
GL.glPushMatrix()
#GL.glTranslatef(-trans[0],-trans[1],-trans[2])
GL.glTranslatef(float(trans[0]),
float(trans[1]),
float(trans[2]))
GL.glMultMatrixf(self.rotation)
GL.glScalef(float(self.scale[0]),
float(self.scale[1]),
float(self.scale[2]))
if self.polyMode == GL.GL_QUADS:
GL.glPushAttrib(GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT |
GL.GL_POLYGON_BIT)
GL.glDisable(GL.GL_LIGHTING)
GL.glMaterialWithCheck(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,
self.color)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
GL.glBegin (GL.GL_QUADS)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopAttrib()
else:
# MS disabling GL.GL_BLEND breaks display of transparent surfaces
## if self.antialiased==True:
## GL.glEnable(GL.GL_LINE_SMOOTH)
## GL.glEnable(GL.GL_BLEND)
## else:
## GL.glDisable(GL.GL_LINE_SMOOTH)
## GL.glDisable(GL.GL_BLEND)
GL.glColor4fv (self.color)
GL.glLineWidth(self.lineWidth)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
# could and should be a display list made once for all planes
GL.glBegin (GL.GL_LINE_STRIP)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopMatrix()
示例13: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glTranslatef [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