本文整理汇总了Python中Camera.Camera.height方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.height方法的具体用法?Python Camera.height怎么用?Python Camera.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.height方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import height [as 别名]
#.........这里部分代码省略.........
glPopMatrix()
glutSwapBuffers()
def mouseMove(self, x, y):
'''Called when the mouse is moved.'''
factor = 2
tmp_x = (self.camera.mouse_x - x)/factor
tmp_y = (self.camera.mouse_y - y)/factor
if tmp_x > self.camera.ROTATE:
tmp_x = self.camera.ROTATE
self.camera.rotate(0, tmp_x, 0)
x = self.WINDOW_WIDTH/2
y = self.WINDOW_HEIGHT/2
glutWarpPointer(x, y)
self.camera.mouse_x = x
self.camera.mouse_y = y
def keyPressed(self, key, x, y):
'''Called when a key is pressed.'''
if key.lower() in self.camera.keys:
self.camera.keys[key.lower()] = True
if glutGetModifiers() == GLUT_ACTIVE_SHIFT:
self.camera.keys["shift"] = True
if key == 'j':
self.camera.rotate(0,3,0)
elif key == 'l':
self.camera.rotate(0,-3,0)
elif key == 'i':
self.camera.rotate(3,0,0)
elif key == 'k':
self.camera.rotate(-3,0,0)
elif key == ' ':
self.camera.height(.1)
elif key == 'c':
self.camera.height(-.1)
elif key == 'x':
exit(0)
def keyUp(self, key, x, y):
'''Called when a key is released.'''
self.camera.keys[key.lower()] = False
if not glutGetModifiers() == GLUT_ACTIVE_SHIFT:
self.camera.keys["shift"] = False
def renderLightSource(self):
'''Resets the light sources to the right position.'''
glLightfv(GL_LIGHT0, GL_POSITION, self.diffuse_pos1)
glLightfv(GL_LIGHT2, GL_POSITION, self.diffuse_pos2)
glLightfv(GL_LIGHT3, GL_POSITION, self.diffuse_pos2)
glLightfv(GL_LIGHT4, GL_POSITION, self.diffuse_pos2)
def GenArray(self, mode='vert',pts=POINTS):
vert_ls=[]
if mode=='color':
for m in range(pts):
for n in range(pts):
for i in range(pts):
tmp_tup=(i*.1,n*.1,m*.1,1)
vert_ls.append(tmp_tup)
elif mode=='vert':
for m in range(pts):
for n in range(pts):
for i in range(pts):
tmp_tup=(i*.1,n*.1,m*.1)
vert_ls.append(tmp_tup)
示例2: blocks
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import height [as 别名]
#.........这里部分代码省略.........
self.makeFloor()
#Transparent blocks!
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
for obj in self.objects:
glPushMatrix()
if obj.get_type() == "block":
self.draw_block(obj)
elif obj.get_type() == "key":
self.draw_key(obj)
glPopMatrix()
glDisable(GL_BLEND)
glFlush()
def draw_block(self, obj):
#Set the blocks shininess, ambient, diffuse, and specular reflections. The blocks are slightly transparent.
color = obj.get_color()
pos = obj.get_pos()
#glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 75)
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], 1])
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, 1])
#glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .7])
glTranslate(pos[0],pos[1],pos[2])
glutSolidCube(2)
def draw_key(self, obj):
color = obj.get_color()
pos = obj.get_pos()
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .7])
glTranslate(pos[0],pos[1],pos[2])
#glutSolidTorus(.05, .25, 3, 3)
glutSolidCone(.1, 2.0, 30, 4)
def keyPressed(self, key, x, y):
'''Called when a key is pressed'''
if key == 'a':
self.camera.strafe(-.1)
elif key == 'd':
self.camera.strafe(.1)
elif key == 'w':
self.camera.walk(-.1)
elif key == 's':
self.camera.walk(.1)
elif key == 'j':
self.camera.rotate(0,3,0)
elif key == 'l':
self.camera.rotate(0,-3,0)
elif key == 'i':
self.camera.rotate(3,0,0)
elif key == 'k':
self.camera.rotate(-3,0,0)
elif key == ' ':
self.camera.height(.1)
elif key == 'c':
self.camera.height(-.1)
self.display()
def renderLightSource(self):
'''Resets the light sources to the right position'''
glLightfv(GL_LIGHT0, GL_POSITION, self.diffuse_pos1)
glLightfv(GL_LIGHT2, GL_POSITION, self.diffuse_pos2)
glLightfv(GL_LIGHT3, GL_POSITION, self.diffuse_pos2)
glLightfv(GL_LIGHT4, GL_POSITION, self.diffuse_pos2)
def makeFloor(self):
'''Makes a floor of size size and places an image (texture) on it'''
glEnable(GL_TEXTURE_2D)
size = 50
image = Image.open("OtherMods/checkerboard.bmp")
ix = image.size[0]
iy = image.size[1]
image = image.tostring("raw", "RGBX", 0, -1)
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0) ; glVertex(-size,-.5,-size)
glTexCoord2f(1.0, 0.0) ; glVertex(size,-.5,-size)
glTexCoord2f(1.0, 1.0) ; glVertex(size,-.5,size)
glTexCoord2f(0.0, 1.0) ; glVertex(-size,-.5,size)
glEnd()
glDisable(GL_TEXTURE_2D)
示例3: glutInitDisplayMode
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import height [as 别名]
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
glutInitWindowSize(1024, 768);
glutInitWindowPosition(100, 100);
glutCreateWindow('interactive')
initGlutCallbacks()
glClearColor(0.0, 0.0, 0.0, 0.0)
createVBO()
createIBO()
compileShaders()
camera = Camera()
camera.verticalFOV =90.0
camera.height = 768
camera.width = 1024
camera.near = 1.0
camera.far = 100.0
camera.position.z = -3.0
camera.target.z = 2.0
tr = Transform()
tr.position.set(0.0, 0.0, 4.0)
glutMainLoop()
# camera.target.z = 2.0
# camera.position.z = 10.0
# vpMat = camera.viewportTransform()
# perMat = camera.perspectiveTransform()