本文整理汇总了Python中Camera.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.draw方法的具体用法?Python Camera.draw怎么用?Python Camera.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameState
# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import draw [as 别名]
class GameState(siren.State):
def __init__(self):
siren.State.__init__(self)
self.ignoreMouseMove = True
self.fps = 0.0
self.numFrames = 0
self.frameTime = 0.0
# Initialize the input controls
self.initInput()
self.camera = Camera()
# Create the player
self.player = Player('Ben', 'John')
self.player.pos = gmtl.Point3f(0, 0, -5)
rot = gmtl.Quatf()
# gmtl.set(rot, gmtl.AxisAnglef(gmtl.deg2Rad(180), 0,1,0))
self.player.rot = rot
# Big hack to get player rotation control to work
self.vel_change = gmtl.Vec3f()
self.npcs = []
for i in range(4):
av = siren.Avatar.create('John')
av.setWCS(gmtl.EulerAngleXYZf(gmtl.deg2Rad(-90.0), 0, 0))
av.setPos(gmtl.Vec3f(4.0*i, 0, -10))
av.triggerAnimationCycle('DANCE')
self.npcs.append(av)
self.curAnim = 0
self.anims = ['WALK',
'RUN',
'DANCE',
'IDLE',
'TYPE',
'SIT',
'WORK1',
'WORK2']
# Create the texture to hold the motion blur
self.blurTexture = siren.Texture(512, 512, 3, GL_RGB)
# Inite the GL state
glEnable(GL_DEPTH_TEST)
glEnable(GL_TEXTURE_2D)
glClearColor(0,0,0,1)
def initInput(self):
'''
Initializes the input system, setting up all the appropriate bindings.
'''
# Load in the input bindings
self.inputMgr = siren.InputManager()
self.inputMgr.loadMappings('data/inputbindings.txt')
# Movement
self.actionForward = self.inputMgr.getAction('FORWARD')
self.actionBackward = self.inputMgr.getAction('BACKWARD')
self.actionStrafeLeft = self.inputMgr.getAction('STRAFE_LEFT')
self.actionStrafeRight = self.inputMgr.getAction('STRAFE_RIGHT')
# Camera control (for debugging)
self.actionCameraZoomIn = self.inputMgr.getAction('CAMERA_ZOOM_IN')
self.actionCameraZoomOut = self.inputMgr.getAction('CAMERA_ZOOM_OUT')
self.actionCameraPitchUp = self.inputMgr.getAction('CAMERA_PITCH_UP')
self.actionCameraPitchDown = self.inputMgr.getAction('CAMERA_PITCH_DOWN')
# Application control
self.actionQuit = self.inputMgr.getAction('QUIT')
def draw(self):
'''
Renders a visualization of the current state of the game simulation.
'''
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(80.0, float(self.getWidth()) / self.getHeight(),
0.01, 500.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
self.camera.draw()
# Redraw the current blur texture
glPushAttrib(GL_VIEWPORT_BIT)
# Change the viewport to match the size of the texture
glViewport(0, 0, self.blurTexture.getTexWidth(),
self.blurTexture.getTexHeight())
self.drawMotionBlur(self.player.drunkAmount)
self.drawScene()
# Copy the contents of the frame buffer into our blur texture
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import draw [as 别名]
class Game:
'''
'''
def __init__(self):
self.loading = LoadingScreen(self)
self.camera = Camera(self)
self.lighting = Lighting(self)
self.balltable = BallTable(self)
self.menu = Menu(self)
self.decision = Decision(self)
self.mousekey = MouseKey(self)
self.shotStrength = ShotStrength(self)
self.state = GameState.START
self.mode = GameMode.TUTORIAL
self.balls = [ Ball(self) ]*16
self.ballinHole = [ None ] * 16
self.LastFrameTimePoint = 0
def Load(self):
glutInit(sys.argv)
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH)
glutInitWindowSize(ParamDef.ScreenResolution[0], ParamDef.ScreenResolution[1])
glutInitWindowPosition(0,0)
glutCreateWindow(APP_NAME)
glClearColor(0,0,0,0)
glutIdleFunc(self.loading.Idle)
glutDisplayFunc(self.loading.UpdateGL)
self.currentWindow = glutGetWindow()
glutMainLoop()
def Run(self):
ParamDef.DelayCompensation=1
glutIgnoreKeyRepeat(1)
glEnable(GL_DEPTH_TEST)
glEnable(GL_CULL_FACE)
glEnable(GL_NORMALIZE)
glEnable(GL_BLEND)
glShadeModel(GL_SMOOTH)
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
glutMouseFunc(self.mousekey.MouseClick);
glutMotionFunc(self.mousekey.MouseMove);
glutKeyboardFunc(self.mousekey.KeyPress);
glutKeyboardUpFunc(self.mousekey.KeyRelease);
glutSpecialFunc(self.mousekey.SpecialKeyPress);
glutSpecialUpFunc(self.mousekey.SpecialKeyRelease)
glutVisibilityFunc(self.Visible)
glutIdleFunc(self.timerEvent)
glutDisplayFunc(self.updateGL)
def timerEvent(self):
#print "timerEvent"
ParamDef.FrameTimePoint=glutGet(GLUT_ELAPSED_TIME)/10
ParamDef.Factor=ParamDef.FrameTimePoint-self.LastFrameTimePoint;
if (ParamDef.DelayCompensation !=0 ) :
ParamDef.Factor=1;
ParamDef.DelayCompensation=0;
if (ParamDef.Factor !=0) :
if (ParamDef.ShowFPS) :
if ((ParamDef.FrameTimePoint%200)<(self.LastFrameTimePoint%200)) :
self.menu.SetFPS(Frames/2);
ParamDef.Frames=0;
else:
ParamDef.Frames+=1
self.menu.Update(ParamDef.Factor);
if self.state == GameState.START:
self.StartHandling()
elif self.state == GameState.VIEWING:
self.ViewingHandling()
elif self.state == GameState.AIMING:
self.AimHandling()
elif self.state == GameState.SWING:
self.BackswingHandling()
elif self.state == GameState.SHOT:
self.ShotHandling()
elif self.state == GameState.NEW_WHITE:
self.NewWhiteHandling()
elif self.state == GameState.JUDGEING:
self.JudgeHandling()
self.camera.Ride(ParamDef.Factor);
self.LastFrameTimePoint=ParamDef.FrameTimePoint;
glutPostWindowRedisplay(self.currentWindow);
def updateGL(self):
'''
'''
#print "updateGL"
if ParamDef.ZBufferDelete != 0:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
self.camera.draw()
self.lighting.draw()
#.........这里部分代码省略.........