本文整理汇总了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
示例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)