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


Python GL.glLoadIdentity方法代码示例

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


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

示例1: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [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)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:9,代码来源:test_togl.py

示例2: ConcatRotation

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def ConcatRotation(self, matrix, redo=1):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Apply the rotation matrix to the object [matrix.shape==(16,)]"""
	
	if self.redirectXform: obj = self.redirectXform
	else: obj = self
        obj._modified = True
	GL.glPushMatrix()
	GL.glLoadIdentity()
	GL.glMultMatrixf(obj.Ri)#.astype('f'))
	GL.glMultMatrixf(matrix)
	GL.glMultMatrixf(obj.R)#.astype('f'))
	GL.glMultMatrixf(obj.rotation)

	m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        obj.rotation = glCleanRotMat(m).astype('f')
	obj.rotation.shape = (16, )
	GL.glPopMatrix()
        for o in self.copyXform: o.ConcatRotation(matrix)

        ## This code made rotation very slow because it would rebuild the
        ## master dpyList in cases where it was not needed
##         if redo and not self.immediateRendering:
##             vi = self.viewer
##             print 'faga'
##             vi.deleteOpenglList()
           
        vi = self.viewer
        if vi.activeClippingPlanes > 0 or vi.activeScissor > 0 or \
          (vi.currentObject!=vi.rootObject and not \
           vi.redirectTransformToRoot) and redo and \
           not self.immediateRendering:
            vi.deleteOpenglList()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:36,代码来源:Transformable.py

示例3: GetMatrix

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def GetMatrix(self, root=None, instance=None, scale=True, transpose=True):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Returns the matrix by which this object is transformed
scale = False: returns the rotation and translation. no scaling info included
               Used to save the transformed geom --> coords --> new pdb file
instance is a list of integer instance indices for all parents
"""
        if root is None:
            root = self.viewer.rootObject

        if instance is None:
            instance = [0]
            p = self.parent
            while p:
                instance.append(0)
                p = p.parent

        GL.glPushMatrix()
        GL.glLoadIdentity()
        #print 'GetMatrix', instance
        self.BuildMat(self, root, scale, instance)
        #GL.glMultMatrixf(self.instanceMatricesFortran[instanceList[0]]])
        m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        GL.glPopMatrix()
        if Numeric.alltrue(m==Numeric.zeros(16).astype('f')):
            # this happens when Pmv has no GUI
            m = Numeric.identity(4)
        if transpose:
            return Numeric.transpose(Numeric.reshape(m, (4,4)))
        else:
            return Numeric.reshape(m, (4,4))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:34,代码来源:Transformable.py

示例4: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def Draw(self):
        #print "StickerImage.Draw", self

        if self.image is None:
            return

        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); 

        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
        #print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom

        # used for picking
        self.polygonContour = [ (posxFromLeft, posyFrombottom),
                                (posxFromLeft+width, posyFrombottom),
                                (posxFromLeft+width, posyFrombottom+height),
                                (posxFromLeft, posyFrombottom+height)
                              ]

        # this accept negative values were GL.glRasterPos2f(x,y) doesn't
        GL.glRasterPos2f(0, 0)
        _gllib.glBitmap(0, 0, 0, 0, posxFromLeft, posyFrombottom, 0)

        GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
        if self.image.mode == 'RGBA':
                _gllib.glDrawPixels(self.image.size[0], self.image.size[1], 
                                    GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, 
                                    self.image.tostring() )
        elif self.image.mode == 'RGB':
                _gllib.glDrawPixels(self.image.size[0], self.image.size[1], 
                                    GL.GL_RGB, GL.GL_UNSIGNED_BYTE, 
                                    self.image.tostring() )
        elif self.image.mode == 'L':
                _gllib.glDrawPixels(self.image.size[0], self.image.size[1], 
                                    GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE, 
                                    self.image.tostring() )

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPopMatrix()
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPopMatrix()

        return 1
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:61,代码来源:StickerImage.py

示例5: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
 def initProjection(self):
     if self.imarray is None:
         return
     self.tk.call(self._w, 'makecurrent')
     GL.glViewport(0, 0, self.width, self.height)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GL.glOrtho(0, float(self.width), 0, float(self.height), -1.0, 1.0)
     GL.glMatrixMode(GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:imageViewer.py

示例6: display

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
 def display(self):
        GL.glClear( GL.GL_COLOR_BUFFER_BIT)
        GL.glColor3f( 1.0, 1.0, 1.0)
        GL.glLoadIdentity()             # clear the matrix 
        # viewing transformation 
        GLU.gluLookAt( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
        GL.glScalef( 1.0, 2.0, 1.0)      # modeling transformation 
        GLUT.glutWireCube( 1.0)
        GL.glFlush()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:test_cube.py

示例7: reshape

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
 def reshape(self, w, h):
    GL.glViewport( 0, 0, w, h)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    if(w <= h):
       GLU.gluOrtho2D( 0.0, 30.0, 0.0, 30.0 * h/w)
    else:
       GLU.gluOrtho2D( 0.0, 30.0 * w/h, 0.0, 30.0)
    GL.glMatrixMode( GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:test_smooth.py

示例8: Draw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [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
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:54,代码来源:glfSticker.py

示例9: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [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)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:16,代码来源:MaterialEditor.py

示例10: ConcatRotationRelative

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def ConcatRotationRelative(self, matrix):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        """Apply the rotation matrix to the object (matrix.shape ==(16,)
        Unlike ConcatRotation you just concatenate the rotation of the object
        without considering Ri and R
        """
        self._modified = True
        obj = self
	GL.glPushMatrix()
	GL.glLoadIdentity()
##         GL.glMultMatrixf(obj.rotation)
        GL.glMultMatrixf(matrix)
        GL.glMultMatrixf(obj.rotation)
        m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        obj.rotation = m.astype('f')
        obj.rotation.shape = (16, )
        GL.glPopMatrix()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:20,代码来源:Transformable.py

示例11: pickDraw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [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()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:46,代码来源:colorMapLegend.py

示例12: FrameTransform

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def FrameTransform(self, camera=None):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Build the R an RI, the object's frame transformation and inverse"""

	GL.glPushMatrix()
	self.Si = Numeric.ones( (3, ) )
	GL.glLoadIdentity()
	if hasattr(self, 'parent'):
            if self.inheritXform:
                parent = self.parent
                while (parent):
                    m = Numeric.reshape( parent.rotation, (4,4) )
                    upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
                    GL.glMultMatrixf(upd)                
                    GL.glMultMatrixf(parent.MatrixRotInv)                
                    self.Si = self.Si / parent.scale
                    self.Si = self.Si / parent.MatrixScale
                    # we have to test here because we need to take into
                    # account the first parent that does not inherit while
                    # building R and Ri
                    if not parent.inheritXform:
                        break
                    parent = parent.parent


	if camera:
	    m = Numeric.reshape( camera.rotation, (4,4) )
	    upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
	    GL.glMultMatrixf(upd)
            self.Si = self.Si / camera.scale

	self.Ri = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
	GL.glPopMatrix()
	self.Ri = glCleanRotMat(self.Ri).astype('f')
        self.Ri.shape = (4,4)
	self.R = Numeric.reshape( Numeric.transpose(self.Ri), (16, ) ).astype('f')
	self.Ri.shape = (16, )

	if self.redirectXform: self.redirectXform.FrameTransform(camera)
	for o in self.copyXform: o.FrameTransform(camera)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:43,代码来源:Transformable.py

示例13: render

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def render(self, mode='render'):
        # call with mode='csg' to render simple shape to setup Zbuffer for CSG
        # call with mode='render' to render by calling geom's draw function
        if self.geom:
            #import traceback
            #print traceback.print_stack()
            #print self.geom
            #print "========================================================="
            root = self.geom.viewer.rootObject

            instance = [0]
            p = self.geom.parent
            while p:
                instance.append(0)
                p = p.parent

            #mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
            #print 'mat OK', mat
            GL.glPushMatrix()
            GL.glLoadIdentity()
            self.geom.viewer.currentCamera.BuildTransformation()
            self.geom.BuildMat(self.geom, root, True, instance)

            #mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
            #print 'mat PB', mat
            #print 'render ', mode, self.geom
            if mode=='csg':
                if self.dpyListCSG is None:
                    self.redoDisplayListCSG()
                GL.glCallList(self.dpyListCSG)
            elif mode=='render':
                obj = self.geom
                if not obj.inheritMaterial:
                    obj.InitMaterial(0)
                    obj.InitColor(0)
                obj.DisplayFunction()
                
            GL.glPopMatrix()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:40,代码来源:csgClip.py

示例14: FrameTransform

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def FrameTransform(self, camera=None):
	"""Build the R an RI, the object's frame transformation and inverse"""

	GL.glPushMatrix()
	self.Si = Numeric.ones( (3, ) )
	GL.glLoadIdentity()
	m = Numeric.reshape( self.object.rotation, (4,4) )
	upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
	GL.glMultMatrixf(self.object.Ri)
	GL.glMultMatrixf(upd)
        GL.glMultMatrixf(self.object.MatrixRotInv)
        self.Si = self.Si * self.object.Si / (self.object.scale *
                                              self.object.MatrixScale)

	self.Ri = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
	GL.glPopMatrix()
	#self.Ri = Numeric.reshape(glCleanRotMat(self.Ri), (4,4) )
        self.Ri = glCleanRotMat(self.Ri)
	self.R = Numeric.reshape( Numeric.transpose(self.Ri), (16, ) ).astype('f')
	self.Ri = Numeric.reshape(self.Ri, (16, )).astype('f')

	if self.redirectXform: self.redirectXform.FrameTransform(camera)
	for o in self.copyXform: o.FrameTransform(camera)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:25,代码来源:Clip.py

示例15: loopGeoms

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glLoadIdentity [as 别名]
    def loopGeoms(self, obj):
        """ this calls the recursive method """

## #commented out 2.7.02 DS, we discard now root transformation
##          # we reset the scale of rootObject to 1,1,1
##          if obj == obj.viewer.rootObject:
##              scaleFactor = obj.scale
##              obj.SetScale([1.,1.,1.])

        # initialize the progress bar to be ratio
        self.lenGeoms = 0 # initialize this to 0
        self.countGeoms(obj) # determine lenght of visible geoms
        self.lenGeoms = self.lenGeoms + 1 # FIXME: dont know why whe
                                              # always have 1 too few
        self.configureProgressBar(init=1, mode='increment',
                                  granularity=1,
                                  progressformat='ratio',
                                  labeltext='parse geoms to vrml2',
                                  max=self.lenGeoms)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        self._loopGeomsRec(obj) # call recursive method
        GL.glPopMatrix()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:25,代码来源:DataOutput.py


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