本文整理汇总了Python中Camera.Camera.updateDimensions方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.updateDimensions方法的具体用法?Python Camera.updateDimensions怎么用?Python Camera.updateDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.updateDimensions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MeshDisplayGL
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import updateDimensions [as 别名]
#.........这里部分代码省略.........
glutMainLoop()
### Mouse/keyboard callbacks
def mousefunc(self, button, state, x, y):
"""Mouse-click callback"""
# Test if the shift key is being held
modState = glutGetModifiers()
shiftHeld = (modState & GLUT_ACTIVE_SHIFT) != 0
if button == GLUT_RIGHT_BUTTON:
pass
else:
self.camera.processMouse(button, state, x, y, shiftHeld)
glutPostRedisplay()
def keyfunc(self, key, x, y):
"""Keyboard callback"""
if key == chr(27): # escape key
exit(0)
if key == 'm':
self.drawEdges = not self.drawEdges
elif key == 'k':
self.drawShape = not self.drawShape
elif key == 'l':
self.drawVectors = not self.drawVectors
elif key == 'n':
self.drawVertices = not self.drawVertices
elif key == 'h':
self.printKeyCallbacks()
elif key in self.userKeyCallbacks:
self.userKeyCallbacks[key][0]()
else:
# Pass it on to the camera to see if the camera wants to do something
# with it
self.camera.processKey(key, x, y)
glutPostRedisplay()
def registerKeyCallback(self, key, function, docstring="Application-defined command"):
"""
Register a new keyboard command with the view. The given function (which
should take no argument) will be called when the key is pressed. A redraw
of the of the viewer is automatically triggered when any key is pressed,
so there is no need to trigger one within your callback function.
"""
reservedKey = [chr(27),'m','k','h','r','f','w','a','s','d','l','n']
if(key in reservedKey):
raise ValueError("ERROR: Cannot register key callback for " + key + ", key is reserved for the viewer application")
self.userKeyCallbacks[key] = (function, docstring)
def printKeyCallbacks(self):
"""Print out a list of all keyboard commands for the application"""
print("\n\n==== Keyboard controls ====\n")
print("== Viewer commands")
print("esc ---- Exit the viewer")
print("wasd ---- Pan the current view (also shift-mousedrag)")
print("r ---- Zoom the view in")
print("f ---- Zoom the view out")
print("h ---- Print this help dialog")
print("m ---- Toggle drawing the edges of the mesh")
print("k ---- Toggle drawing the faces of the mesh")
print("n ---- Toggle drawing the vertices of the mesh")
print("l ---- Toggle drawing the vector data on the mesh surface (if set)")
if len(self.userKeyCallbacks) > 0:
print("\n== Application commands")
for key in self.userKeyCallbacks:
print(key+" ---- "+self.userKeyCallbacks[key][1])
print("\n")
def motionfunc(self, x, y):
"""Mouse-move callback"""
self.camera.processMotion(x, y)
glutPostRedisplay()
def resize(self, w, h):
"""Window-resize callback"""
self.windowWidth = w
self.windowHeight = h
glViewport(0, 0, self.windowWidth, self.windowHeight)
self.camera.updateDimensions(w, h)
glutPostRedisplay()