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