本文整理汇总了Python中opengltk.OpenGL.GL.glRotatef方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glRotatef方法的具体用法?Python GL.glRotatef怎么用?Python GL.glRotatef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glRotatef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arcdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRotatef [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()
示例2: arrowdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRotatef [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()
示例3: DrawStuff
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRotatef [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 ()
示例4: cyldrawWithInterpolatedColors
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRotatef [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()
示例5: cyldrawWithSharpColorBoundaries
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glRotatef [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:
#.........这里部分代码省略.........