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


Python Mesh.draw方法代码示例

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


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

示例1: draw

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import draw [as 别名]
	def draw( self ) :
		qm = tr.quaternion_matrix( self.Q[3:] )
		if self.drawstate & MESH :
			glPushMatrix()
			glMultTransposeMatrixf( qm )
			Mesh.draw( self )
			glPopMatrix()

		if self.drawstate & WIREFRAME :
			glPushMatrix()
			glMultTransposeMatrixf( qm )
			glDisable(GL_LIGHTING)
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
			glDisable(GL_CULL_FACE)
			Mesh.draw( self )
			glBegin(GL_LINES)
			glVertex3f(0,0,0)
			glVertex3f( self.x[-1,0] , self.x[-1,1] , self.x[-1,2] )
			glEnd()
			glEnable(GL_CULL_FACE)
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
			glEnable(GL_LIGHTING)
			glPopMatrix()

		if self.drawstate & TRACE :
			glDisable(GL_LIGHTING)
			glBegin(GL_POINTS)
			for p in self.trace : glVertex3f( *p[:3] )
			glEnd()
			glEnable(GL_LIGHTING)

		if self.drawstate & GRAVITY :
			glPushMatrix()
			glDisable(GL_LIGHTING)
			glTranslatef( 2 , 2 , 0 )
			glScalef(.1,.1,.1)
			glMultTransposeMatrixf( qm )
			glColor3f(1,.5,0)
			glBegin(GL_LINES)
			glVertex3f( 0 , 0 , 0 )
			glVertex3f( *self.G )
			glEnd()
			glEnable(GL_LIGHTING)
			glPopMatrix()
开发者ID:jkotur,项目名称:spinning_top,代码行数:46,代码来源:top.py

示例2: __init__

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import draw [as 别名]
class Scene :
	def __init__( self , fov , ratio , near , far  , skybox_img , duck_img ) :
		self.fov = fov
		self.far = far
		self.near = near 
		self.ratio = ratio

		self.last_time = timer()

		self.water = Water( 128 )
		self.box   = Skybox( skybox_img )
		self.duck  = Mesh( 'data/duck.gpt' , duck_img , 'shad/anisotropic' )
		self.path  = BSpline( (-1,1) , (-1,1) )

		self.light = np.array( (0,2,0) )

		self.water.drop_rnd()

	def gfx_init( self ) :
		self.camera = Camera( ( 0 , 5 ,  0 ) , ( 1 , 1 , 0 ) , ( 1 , 0 , 0 ) )
		self._update_proj()

		self.water.gfx_init()
		self.box  .gfx_init()
		self.duck .gfx_init()

	def draw( self ) :
		self.time = timer()
		dt = self.time - self.last_time

		glMatrixMode(GL_MODELVIEW)
		glLoadIdentity()
			   
		self.camera.look()

		self.box.draw()

		self.path.next( dt )
		self.water.drop( *((self.path.value+1.0)*self.water.n/2.0) ,
				force = np.linalg.norm(self.path.tangent)*25 )
		self.water.step( dt * .5 )
		self.water.draw( self.box.texture , self.camera.matrix )

		self.duck.draw( self.path.value , self.path.tangent , self.light )

		self.last_time = self.time

	def set_fov( self , fov ) :
		self.fov = fov
		self._update_proj()

	def set_near( self , near ) :
		self.near = near
		self._update_proj()

	def set_ratio( self , ratio ) :
		self.ratio = ratio
		self._update_proj()

	def set_screen_size( self , w , h ) :
		self.width  = w 
		self.height = h
		self.set_ratio( float(w)/float(h) )

	def set_fov( self , fov ) :
		self.fov = fov
		self._update_proj()

	def set_near( self , near ) :
		self.near = near
		self._update_proj()

	def set_ratio( self , ratio ) :
		self.ratio = ratio
		self._update_proj()

	def set_screen_size( self , w , h ) :
		self.width  = w
		self.height = h
		self.set_ratio( float(w)/float(h) )

	def mouse_move( self , df ) :
		self.camera.rot( *map( lambda x : -x*.2 , df ) )

	def key_pressed( self , mv ) :
		self.camera.move( *map( lambda x : x*.05 , mv ) )

	def _update_proj( self ) :                                         
		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()
		gluPerspective( self.fov , self.ratio , self.near , self.far )
		glMatrixMode(GL_MODELVIEW)
开发者ID:jkotur,项目名称:duck,代码行数:94,代码来源:scene.py

示例3: glfwGetKey

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import draw [as 别名]
        camera.translate(0, 0, -speed*dt)
    if glfwGetKey(window, GLFW_KEY_S):
        camera.translate(0, 0,  speed*dt)
    if glfwGetKey(window, GLFW_KEY_A):
        camera.translate(-speed*dt, 0, 0)
    if glfwGetKey(window, GLFW_KEY_D):
        camera.translate( speed*dt, 0, 0)

    if glfwGetKey(window, GLFW_KEY_LEFT):
        camera.rotate_euler(radians( 5*speed*dt), 0, 0)
    if glfwGetKey(window, GLFW_KEY_RIGHT):
        camera.rotate_euler(radians(-5*speed*dt), 0, 0)
    if glfwGetKey(window, GLFW_KEY_UP):
        camera.rotate_euler(0, 0, radians( 5*speed*dt))
    if glfwGetKey(window, GLFW_KEY_DOWN):
        camera.rotate_euler(0, 0, radians(-5*speed*dt))

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    view = camera.inverse()

    with shader as s, texture as t:
        s.uniform_matrix_4x4('ModelViewInvMat', camera)
        s.uniform('EyePos', camera * Point3(0,0,0))

        mesh.draw()

    glfwSwapBuffers(window)

glfwTerminate()
开发者ID:imclab,项目名称:aurae,代码行数:32,代码来源:raycast.py

示例4: __init__

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import draw [as 别名]
class Scene :
	def __init__( self , fovy , ratio , near , far ) :
		self.fovy = fovy
		self.near = near 
		self.far = far
		self.ratio = ratio

		self.camera = None
		self.mesh = Mesh('plane.mesh')

		self.x = 0.0

		self.last_time = timer()

		self.plane_alpha = 65.0 / 180.0 * m.pi

		self.lpos = [ 1 ,-1 , 0 ]

	def gfx_init( self ) :
		self.camera = Camera( ( 0 , 0 , 5 ) , ( 0 , 0 , 0 ) , ( 0 , 1 , 0 ) )

		self._update_proj()

		glEnable( GL_DEPTH_TEST )
		glEnable( GL_NORMALIZE )
#        glEnable( GL_CULL_FACE )
		glEnable( GL_COLOR_MATERIAL )
		glColorMaterial( GL_FRONT , GL_AMBIENT_AND_DIFFUSE )

	def draw( self ) :
		self._update_proj()

		self.time = timer()

		dt = self.time - self.last_time

		self._step( dt )

		glMatrixMode(GL_MODELVIEW)
		glLoadIdentity()

		self.camera.look()

		self.lpos = [ m.sin(self.x/100)*2 , -1 , m.cos(self.x/100)*2 ]

		self._set_lights()

		self._draw_scene()

		self.x+=dt*.3

		self.last_time = self.time

	def _step( self , dt ) :
		pass

	def _draw_scene( self ) :
		self.mesh.draw()

	def _update_proj( self ) :
		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()
		gluPerspective( self.fovy , self.ratio , self.near , self.far )
		glMatrixMode(GL_MODELVIEW)

	def _set_lights( self ) :
		glEnable(GL_LIGHTING);
		glLightfv(GL_LIGHT0, GL_AMBIENT, [ 0.2 , 0.2 , 0.2 ] );
		glLightfv(GL_LIGHT0, GL_DIFFUSE, [ 0.9 , 0.9 , 0.9 ] );
		glLightfv(GL_LIGHT0, GL_SPECULAR,[ 0.3 , 0.3 , 0.3 ] );
		glLightfv(GL_LIGHT0, GL_POSITION, self.lpos );
		glEnable(GL_LIGHT0); 

	def set_fov( self , fov ) :
		self.fov = fov
		self._update_proj()

	def set_near( self , near ) :
		self.near = near
		self._update_proj()

	def set_ratio( self , ratio ) :
		self.ratio = ratio
		self._update_proj()

	def set_screen_size( self , w , h ) :
		self.width  = w 
		self.height = h
		self.set_ratio( float(w)/float(h) )

	def mouse_move( self , df , buts ) :
		if 3 in buts and buts[3] :
			self.camera.rot( *map( lambda x : -x*.2 , df ) )

	def key_pressed( self , mv ) :
		self.camera.move( *map( lambda x : x*.25 , mv ) )
开发者ID:jkotur,项目名称:empty_pyglgtk,代码行数:98,代码来源:scene.py


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