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


Python Camera.setPerspective方法代码示例

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


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

示例1: Game

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import setPerspective [as 别名]

#.........这里部分代码省略.........
		pygame.mouse.set_pos((w//2,h//2))

		glEnable(GL_LIGHTING)
		glLightfv(GL_LIGHT1, GL_AMBIENT,(0,0,0,1,0 ))
		glLightfv(GL_LIGHT1, GL_DIFFUSE, (0.95,0.95,0.95,1.0))
		glLightfv(GL_LIGHT1, GL_SPECULAR, (0.95,0.95,0.95,1.0))
		glLightfv(GL_LIGHT1, GL_POSITION, (128, 128.0 , 2.0, 1.0 ))
		glEnable(GL_LIGHT1)

		#glEnable(GL_FOG)
		glFogfv(GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.69, 1.0, 1))
		glHint(GL_FOG_HINT, GL_DONT_CARE)
		glFogi(GL_FOG_MODE, GL_LINEAR)
		glFogf(GL_FOG_DENSITY, 0.35)
		glFogf(GL_FOG_START, 20.0)
		glFogf(GL_FOG_END, 60.0)

		print(glGetString(GL_VERSION))

		glFrontFace(GL_CW)
		glEnable(GL_ALPHA_TEST)
		glEnable (GL_DEPTH_TEST)

		glMaterialfv(GL_FRONT, GL_SPECULAR, (0.1,0.1,0.1, 1.0));
		glMaterialfv(GL_FRONT, GL_SHININESS, (10.0));
		glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
		glEnable(GL_COLOR_MATERIAL);


	def renderScene(self,delta):
		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
		glLoadIdentity()

		self.camera.setPerspective()
		playerPos = self.camera.position.copy()
		playerPos.z = -playerPos.z
		
		near,far = self.camera.getMouseRay(*pygame.mouse.get_pos())

		direction = far-near
		direction.normalise()

		position = Vector3(self.camera.position)
		position.z = -position.z

		self.groundpos = None

		self.hit = world.getRayHit(position,direction)
		if self.hit:
			self.groundpos = Vector3(self.hit[:3])
			self.delPos = Vector3(self.hit[3:6])


		# Instance of Tessellator
		tes = Tessellator.instance


		glPushMatrix()

		# Render Sky

		self.skybox.render()

		glDisable(GL_FOG)

		# Render Sun
开发者ID:zzh8829,项目名称:PythonCraft,代码行数:70,代码来源:oldpc.py

示例2: print

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import setPerspective [as 别名]
						print("Command excuted")

			elif event.type == MOUSEBUTTONDOWN:
				pass
			elif event.type == MOUSEMOTION:
				x,y =pygame.mouse.get_pos()
				camera.Yaw(0.15*(x-SCREEN_SIZE[0]//2))
				camera.Pitch(0.15*(y-SCREEN_SIZE[1]//2))
				pygame.mouse.set_pos((SCREEN_SIZE[0]//2,SCREEN_SIZE[1]//2))

		key_handler(pygame.key.get_pressed())

		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
		glLoadIdentity()

		camera.setPerspective()

		glPushMatrix()

		glCallList(plane)

		
		tes = Tessellator.instance
		tes.startDrawingQuads()
		tes.addColor(0,0,0,0)
		tes.addVertex(1,1,0)
		tes.addColor(1,0,0,1)
		tes.addVertex(100,1,0)
		tes.addColor(1,0,0,0)
		tes.addVertex(100,100,0)
		tes.addColor(1,0,0,0)
开发者ID:zzh8829,项目名称:PythonCraft,代码行数:33,代码来源:Tessellator.py


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