Example #1
0
    def __init__(self, w, h, title):
        self.KeyInputState = {
            "reset": False,
            "space": False,
            "b": False,
            "v": False,
            "g": False,
            "h": False,
            "n": False
        }
        self.cam = Camera(60., 1.0, 0.1, 1000.0)
        #self.cam.setPos([0,10,1], [0,0,0])
        #self.cam.setPos([10,10,10], [0,0,0])
        #self.cam.setPos([10,5,10], [0,0,0])
        #self.cam.setPos([10,2,10], [0,0,0])
        self.cam.setPos([20, 10, 10], [0, 0, 0])
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1, 0, 0]
        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(100, 100)
        glutCreateWindow(title)
        glClearColor(0.25, 0.25, 0.25, 1.0)
        glEnable(GL_DEPTH_TEST)
        self.lighting.LightSet()
Example #2
0
    def __init__(self, w, h, title):
        self.cam = Camera(90.0, 800/600,1, 100000.0)
        self.eye = [0.0, -2000.0, 3800.0]
        self.target = [0.0, 0.0, 2500.0]
        self.up = [0.0, 0.0, 1.0]
        self.cam.setPos(self.eye, self.target)
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1,0,0]

        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()
        self.obj_basic = OBJ('island_basic_1.obj', swapyz=True)
        self.obj_snow = OBJ('island_basic_snow.obj', swapyz=True)
        self.obj_rain = OBJ('island_basic_rain.obj', swapyz=True)
        self.obj = self.obj_basic
        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(800, 600)


        glEnable(GL_DEPTH_TEST)
        glShadeModel(GL_SMOOTH)
        self.lighting.LightSet()
Example #3
0
def restoreLightController():
    import Lighting

    Lighting._setFromParams({
        "ratio":
        1.25,
        "brightness":
        1.16,
        "material": [30.0, (0.85, 0.85, 0.85), 0.0],
        "back": [
            (0.3574067443365933, 0.6604015517481455, -0.6604015517481456),
            (1.0, 1.0, 1.0),
            0.0,
        ],
        "mode":
        "two-point",
        "key": [
            (-0.3574067443365933, 0.6604015517481455, 0.6604015517481456),
            (1.0, 1.0, 1.0),
            1.0,
        ],
        "contrast":
        0.83,
        "fill": [
            (0.2505628070857316, 0.2505628070857316, 0.9351131265310294),
            (1.0, 1.0, 1.0),
            0.0,
        ],
    })
Example #4
0
 def attack(self):
     now = pygame.time.get_ticks()
     if self._current_mana > 0 and now - self._last_attack_time > self._attack_interval:
         self._last_attack_time = now
         if self._selected_attack == GameEnums.AttackTypes.FIREBALL.value:
             shell = Fireball.Fireball(
                 self._rect.centerx, self._rect.centery,
                 'resources/images/shells/fireball.png',
                 (float(pygame.mouse.get_pos()[0] - self._rect.centerx),
                  float(pygame.mouse.get_pos()[1] - self._rect.centery)))
             self._current_mana -= 4
             return [shell]
         else:
             shell_1 = Lighting.Lighting(
                 self._rect.centerx,
                 self._rect.centery,
                 animation_images=Textures.LIGHTING,
                 shooting_direction=(float(pygame.mouse.get_pos()[0] -
                                           self._rect.centerx),
                                     float(pygame.mouse.get_pos()[1] -
                                           self._rect.centery)))
             shell_2 = Lighting.Lighting(
                 self._rect.centerx,
                 self._rect.centery,
                 animation_images=Textures.LIGHTING,
                 shooting_direction=(float(pygame.mouse.get_pos()[0] - 50 -
                                           self._rect.centerx),
                                     float(pygame.mouse.get_pos()[1] - 50 -
                                           self._rect.centery)))
             shell_3 = Lighting.Lighting(
                 self._rect.centerx,
                 self._rect.centery,
                 animation_images=Textures.LIGHTING,
                 shooting_direction=(float(pygame.mouse.get_pos()[0] - 50 -
                                           self._rect.centerx),
                                     float(pygame.mouse.get_pos()[1] + 50 -
                                           self._rect.centery)))
             shell_4 = Lighting.Lighting(
                 self._rect.centerx,
                 self._rect.centery,
                 animation_images=Textures.LIGHTING,
                 shooting_direction=(float(pygame.mouse.get_pos()[0] + 50 -
                                           self._rect.centerx),
                                     float(pygame.mouse.get_pos()[1] - 50 -
                                           self._rect.centery)))
             shell_5 = Lighting.Lighting(
                 self._rect.centerx,
                 self._rect.centery,
                 animation_images=Textures.LIGHTING,
                 shooting_direction=(float(pygame.mouse.get_pos()[0] + 50 -
                                           self._rect.centerx),
                                     float(pygame.mouse.get_pos()[1] + 50 -
                                           self._rect.centery)))
             self._current_mana -= 20
             return [shell_1, shell_2, shell_3, shell_4, shell_5]
     return []
Example #5
0
 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
Example #6
0
 def __init__(self, size, cam, tilePics,itemList,tileCracks,weaponPics,armorPics,over, unit=32, lighting = True,special=True):
     self.size = size
     self.unit = unit
     self.rows = self.size[1] // self.unit
     self.columns = self.size[0] // self.unit
     self.cam = cam
     self.tilePics = tilePics
     self.startLighting = False
     self.itemList = itemList
     self.special = special
     self.entities = []
     self.physics = Physics.physics(self)
     self.AIOn = True
     self.tileCracks = tileCracks
     self.weaponPics = weaponPics
     self.spawners = []
     self.charList = CharacterList.characterList(armorPics)
     self.over = over
     self.armorPics = armorPics
     self.towns = []
     self.tileList = TileList.tileList()
     if lighting == True:
         self.lighting = Lighting.lighting(self)
         self.baseLightLevel = 255
     else:
         self.lighting = False
     self.resetTiles()
     self.resetMetadata()
     '''if lighting == True:
Example #7
0
def glossy_lighting():
    'Toggle glossy lighting'
    import Lighting
    l = Lighting.get()
    from chimera import viewer
    q = {True: 'normal', False: 'glossy'}[viewer.haveShader()]
    l._setQualityFromParams(q)
Example #8
0
def restoreLightController():
    import Lighting

    c = Lighting.get().setFromParams(
        {
            "quality": "normal",
            "shininess": (30.0, (0.84999999999999998, 0.84999999999999998, 0.84999999999999998), 1.0),
            "key": (
                True,
                (1.0, 1.0, 1.0),
                0.65327227115631104,
                (1.0, 1.0, 1.0),
                1.0,
                (-0.35740674433659325, 0.66040155174814552, 0.66040155174814552),
            ),
            "fill": (
                True,
                (1.0, 1.0, 1.0),
                0.49998998641967773,
                (1.0, 1.0, 1.0),
                0.0,
                (0.25056280708573153, 0.25056280708573153, 0.9351131265310294),
            ),
        }
    )
Example #9
0
def restoreLightController():
    import Lighting
    Lighting._setFromParams({
        'ratio':
        1.25,
        'brightness':
        1.16,
        'material': [30.0, (0.85, 0.85, 0.85), 1.0],
        'back': [(0.3574067443365933, 0.6604015517481455, -0.6604015517481456),
                 (1.0, 1.0, 1.0), 0.0],
        'mode':
        'two-point',
        'key': [(-0.3574067443365933, 0.6604015517481455, 0.6604015517481456),
                (1.0, 1.0, 1.0), 1.0],
        'contrast':
        0.83,
        'fill': [(0.2505628070857316, 0.2505628070857316, 0.9351131265310294),
                 (1.0, 1.0, 1.0), 0.0]
    })
Example #10
0
	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
Example #11
0
 def __init__(self,
              size,
              cam,
              tilePics,
              itemList,
              tileCracks,
              weaponPics,
              armorPics,
              over,
              unit=32,
              lighting=True,
              special=True):
     self.size = size
     self.unit = unit
     self.rows = self.size[1] // self.unit
     self.columns = self.size[0] // self.unit
     self.cam = cam
     self.tilePics = tilePics
     self.startLighting = False
     self.itemList = itemList
     self.special = special
     self.entities = []
     self.physics = Physics.physics(self)
     self.AIOn = True
     self.tileCracks = tileCracks
     self.weaponPics = weaponPics
     self.spawners = []
     self.charList = CharacterList.characterList(armorPics)
     self.over = over
     self.armorPics = armorPics
     self.towns = []
     self.tileList = TileList.tileList()
     if lighting == True:
         self.lighting = Lighting.lighting(self)
         self.baseLightLevel = 255
     else:
         self.lighting = False
     self.resetTiles()
     self.resetMetadata()
     '''if lighting == True:
Example #12
0
#create a list of values
triangleList = []

#read triangle data from a file
triangleList = AppInfo.FileRead(triangleList, fileName)

copyList = []

#transform each of the triangles by the world matrix
#also, create the normals and calculate the color of lighting

for t in triangleList:
    t = Triangle.MultiplyTriangle(t, AppInfo.worldMatrix)
    t = Triangle.MultiplyTriangle(t, AppInfo.viewMatrix)
    t.normal = Triangle.CreateTransformedNormal(t)
    t.colour = Lighting.CalculateColour(t)
    copyList.append(t)

triangleList = copyList
copyList = []

#get rid of unneeded triangles in the copylist
for t in triangleList:
    #t.normal = Triangle.CreateTransformedNormal(t)
    if Triangle.TestForCull(t) == False:
        copyList.append(t)

#set the triangleList to point at the new copylist
triangleList = copyList
copyList = []
Example #13
0
    def __init__(self):
        QMainWindow.__init__(self)
        UI.Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.stackedWidget.setCurrentIndex(0)
        if not (os.path.exists("process")):
            os.makedirs("process")

        # 程序启动即初始化栈数据结构
        global s
        s = Stack()
        s.__init__()

        global lig
        lig = Lighting()

        global col
        col = Color()

        # 打开
        self.open_.clicked.connect(self.open)
        # 储存
        self.save_.clicked.connect(self.save)
        # 重置按钮
        self.reset_.clicked.connect(self.reset)
        # 撤销按钮
        self.undo_.clicked.connect(self.undo)
        # 裁剪
        self.btn_cut.clicked.connect(self.cut_)
        # 旋转
        self.rotate.clicked.connect(self.page_rotate_show)
        self.rotate_ensure.clicked.connect(self.rotate_)

        # 分页
        self.editor.clicked.connect(self.page_0_show)
        self.btn_text.clicked.connect(self.page_1_show)
        self.btn_denoise.clicked.connect(self.page_2_show)
        self.btn_statistic.clicked.connect(self.page_3_show)
        self.btn_filter.clicked.connect(self.page_4_show)
        self.btn_cutout.clicked.connect(self.page_5_show)
        self.btn_face.clicked.connect(self.page_6_show)
        self.btn_sticker.clicked.connect(self.page_7_show)
        self.btn_change_face.clicked.connect(self.page_8_show)
        self.filter_more.clicked.connect(self.page_9_show)
        self.filter_back.clicked.connect(self.page_4_show)

        # 光效
        self.brightness.sliderReleased.connect(self.bright_)
        self.contrast.sliderReleased.connect(self.contrast_)
        self.sharpness.sliderReleased.connect(self.sharpness_)
        # 色彩
        self.saturate.sliderReleased.connect(self.saturate_)

        # 直方图
        self.btn_rgb.clicked.connect(self.showRGB)
        self.btn_pixel.clicked.connect(self.showPixel)

        # 降噪
        self.btn_gaussian.clicked.connect(self.gaussian_)
        self.btn_blur.clicked.connect(self.blur_)
        self.btn_smooth_more.clicked.connect(self.smooth_more_)

        # 文字
        self.text_color.clicked.connect(self.text_color_)
        self.textEnsure.clicked.connect(self.text_)

        # 滤镜
        self.filter_pencil.clicked.connect(self.pencil)
        self.filter_emboss.clicked.connect(self.emboss)
        self.filter_blur.clicked.connect(self.blur__)
        self.filter_smooth.clicked.connect(self.smooth)
        self.filter_sharpen.clicked.connect(self.sharpen)
        self.filter_edge.clicked.connect(self.edge)
        self.filter_sunny.clicked.connect(lambda :self.filter_more_("sunny"))
        self.filter_trip.clicked.connect(lambda: self.filter_more_("trip"))
        self.filter_sakura.clicked.connect(lambda: self.filter_more_("sakura"))
        self.filter_jiangnan.clicked.connect(lambda: self.filter_more_("jiang_nan"))
        self.filter_wangjiawei.clicked.connect(lambda: self.filter_more_("wangjiawei"))
        self.filter_prague.clicked.connect(lambda: self.filter_more_("prague"))

        # 抠图
        self.cutout_auto.clicked.connect(self.autocutout_)
        self.cutout_manu.clicked.connect(self.manucutout_)

        # 人像
        self.face_ensure.clicked.connect(self.face_)

        # 贴图
        self.stick_select.clicked.connect(self.stick_open)
        self.stick_ensure.clicked.connect(self.stick_)

        # 换脸
        self.change_face_select.clicked.connect(self.change_face_open)
        self.change_face_ensure.clicked.connect(self.changeface_)
Example #14
0
def display():
    import Lighting
    controller = Lighting.get()
    from chimera.extension.StdTools import raiseViewingTab
    raiseViewingTab(controller.Name)
    controller.showInterface(controller.Interface_Shininess)
Example #15
0
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()
		self.balltable.drawSurface()

		glDisable(GL_DEPTH_TEST)
		self.balltable.drawLine()
		for ball in self.balls:
			ball.drawShadow()
		glEnable(GL_DEPTH_TEST)

		self.balltable.drawBorder()

		distance=0;   #distance
		resolution=1; #Display resolution
		for ball in self.balls:
			x=ball.Pos_xCM()-self.camera.Pos_x;
			y=ball.Pos_yCM()-self.camera.Pos_y;
			z=self.camera.Pos_z;
			distance=sqrt(x*x+y*y+z*z);
			resolution=(400/distance)
			if (resolution<3): 
				resolution=3;
			resolution=(resolution/2)*2+1;
			if (resolution>ParamDef.BallResolution):
				resolution=ParamDef.BallResolution;
			ball.draw(resolution);    

		glDisable(GL_DEPTH_TEST);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glDisable(GL_LIGHTING);

		self.menu.draw();

		if (self.state != GameState.START) :
			self.shotStrength.draw();

		glEnable(GL_DEPTH_TEST);

		glutSwapBuffers()

	def Visible(self,visible):
		print "Visible"
		if(visible == GLUT_VISIBLE):
			glutIdleFunc(self.timerEvent)

	def StartHandling(self) :
		self.camera.ScenicFlight(ParamDef.Factor)
		self.menu.Update(ParamDef.Factor)

	def ViewingHandling(self) :
		self.menu.Update(ParamDef.Factor)

		if (KEY_UP) :
			self.camera.Move_Front(ParamDef.Factor);
		if (KEY_DOWN) :
			self.camera.Move_Back(ParamDef.Factor);
		if (KEY_RIGHT):
			self.camera.Move_Right(ParamDef.Factor);
		if (KEY_LEFT) :
			self.camera.Move_Left(ParamDef.Factor);
		if (KEY_SHIFT) :
			self.camera.Move_Up(ParamDef.Factor);
		if (KEY_CTRL) :
			self.camera.Move_Down(ParamDef.Factor);
		if (KEY_PAGE_UP) :
			self.camera.Move_In(ParamDef.Factor);
		if (KEY_PAGE_DOWN) :
			self.camera.Move_Out(ParamDef.Factor);
		if (KEY_HOME) :
			self.camera.Zoom_In(ParamDef.Factor);
		if (KEY_END) :
			self.camera.Zoom_Out(ParamDef.Factor);


	'''
	* Aim Handling
	'''
	def AimHandling(self) :
		if (KEY_UP)  :
			self.camera.Move_In(ParamDef.Factor)
		if (KEY_DOWN) :
			self.camera.Move_Out(ParamDef.Factor)
		if (KEY_RIGHT):
			self.camera.SwingRight(2*ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM())
		if (KEY_LEFT) :
			self.camera.SwingLeft(2*ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM())
		if (KEY_SHIFT) :
			self.camera.SwingDown(ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM())
		if (KEY_CTRL)        :
			self.camera.SwingUp(ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM())
		if (KEY_PAGE_UP)    :
			self.camera.Move_In(ParamDef.Factor)
		if (KEY_PAGE_DOWN)     :
			self.camera.Move_Out(ParamDef.Factor)
		if (KEY_HOME)        :
			self.camera.Vertigo_In(ParamDef.Factor)
		if (KEY_END) :
			self.camera.Vertigo_Out(ParamDef.Factor)


	def BackswingHandling(self) :
		'''
		'''
		if (KEY_UP)  :
			self.camera.Move_In(ParamDef.Factor);
		if (KEY_DOWN) :
			self.camera.Move_Out(ParamDef.Factor);
		if (KEY_RIGHT):
			self.camera.SwingRight(2*ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM());
		if (KEY_LEFT) :
			self.camera.SwingLeft(2*ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM());
		if (KEY_SHIFT) :
			self.camera.SwingDown(ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM());
		if (KEY_CTRL) :
			self.camera.SwingUp(ParamDef.Factor,self.balls[0].Pos_xCM(),self.balls[0].Pos_yCM());
		if (KEY_PAGE_UP)  :
			self.camera.Move_In(ParamDef.Factor);
		if (KEY_PAGE_DOWN)  :
			self.camera.Move_Out(ParamDef.Factor);
		if (KEY_HOME) :
			self.camera.Zoom_In(ParamDef.Factor);
		if (KEY_END) :
			self.camera.Zoom_Out(ParamDef.Factor);

		shotStrength=MaxAusholStaerke*(1-exp((-ParamDef.FrameTimePoint+ParamDef.ShotStartTime)/400.0));
		self.ShotStrength.setShockStrength(shotStrength/3.333);

	'''
	 * 击球处理
	 *
	 '''
	def ShotHandling(self):
		FirstShot=0;
		#WeisseVersetzbar=0;

		if (KEY_UP)  :
			self.camera.Move_Front(ParamDef.Factor)
		if (KEY_DOWN) :
			self.camera.Move_Back(ParamDef.Factor)
		if (KEY_RIGHT):
			self.camera.Move_Right(ParamDef.Factor)
		if (KEY_LEFT) :
			self.camera.Move_Left(ParamDef.Factor)
		if (KEY_SHIFT):
			self.camera.Move_Up(ParamDef.Factor)
		if (KEY_CTRL):
			self.camera.Move_Down(ParamDef.Factor)
		if (KEY_PAGE_UP):
			self.camera.Move_In(ParamDef.Factor)
		if (KEY_PAGE_DOWN):
			self.camera.Move_Out(ParamDef.Factor)
		if (KEY_HOME) :
			self.camera.Zoom_In(ParamDef.Factor)
		if (KEY_END) :
			self.camera.Zoom_Out(ParamDef.Factor)

		#Frames++;                       # F"ur die Frames/sec-Anzeige

		# Zeit seit Stossbeginn
		time=ParamDef.FrameTimePoint-ParamDef.StartTime;  #time

		# Letzten Zustand noch zeichnen, wenn Stoss
		if (time>ParamDef.ShotTime):
			time=ParamDef.ShotTime # eigentlich schon vorbei

		#printf("%i-%i=%i: ",FrameZeitpunkt,Startzeit,Zeit);

		for i in range(16) : # Alle Kugeln neu positionieren
			if (LightingList[time][i][2]<=0) :
				self.balls[i].newPositionD(LightingList[Zeit][i]);


		self.ShotStrength.setShockStrength(shotStrength/3.333-Zeit/3.0);

		if (not (time & 31)) :
			neu=0;
			for i in range(16):
				if (self.ballsInGame[i] and self.ballsInHole[i]!=0
						and (self.balls[i].Pos_x()==3000)):
					self.ballsInHole[i]=1;
					neu=1;
			if (neu) :
				self.menu.NewMenuState()


		if (time==ParamDef.ShotTime and
				not( self.mode == GameMode.TUTORIAL 
					and ParamDef.FrameTimePoint-ParamDef.StartTime < 1900
					)
				):
			# Animation schon fertig?

			##ifndef _WIN32 
			#printf(" %f Frames/sec\n",(Frames*100.0)/(Stossdauer+1.0));
			##endif    

			for i in range(16)  :
				if (self.ballssInGame[i] 
					and not self.ballssInHole[i] 
					and (self.balls[i].Pos_x()==3000) ) :
					self.ballssInHole[i]=1;
			if (self.mode == GameMode.TRAINING or self.mode == GameMode.TUTORIAL ) :
				if (self.balls[0].Pos_x()==3000) :
					self.state=GameState.NEW_WHITE;
					ShotStrength.setShockStrength(0.0);
					ParamDef.LageVerbesserung=1;
					ParamDef.LageVerbesserungKopffeld=1;
					WhiteChosen();
					self.menu.NewMenuState();
				else :
					self.state=GameState.VIEWING;
					ShotStrength.setShockStrength(0.0);
					self.menu.NewMenuState();
			elif self.decision.Decisioning()==0 :
				self.state=GameState.JUDGEING
				ShotStrength.setShockStrength(0.0);
			else :
				self.state=GameState.VIEWING;
				self.shotStrength.setShockStrength(0.0);
				self.menu.NewMenuState();

	'''
	* 放置白球
	'''
	def NewWhiteHandling(self):
		if (self.mode == GameMode.TRAINING) :
			#ParamDef.
			LageVerbesserungKopffeld=0; #Location improving header
			LageVerbesserung=1;

		x=self.balls[0].Pos_xCM();
		y=self.balls[0].Pos_yCM();

		self.Factor2=sqrt((self.balls[0].Pos_xCM()-self.camera.Pos_xCM())*
				(self.balls[0].Pos_xCM()-self.camera.Pos_xCM())+
				(self.balls[0].Pos_yCM()-self.camera.Pos_yCM())*
				(self.balls[0].Pos_yCM()-self.camera.Pos_yCM())+
				self.camera.Pos_zCM()*self.camera.Pos_zCM());

		self.Factor2*=.005;

		if (KEY_UP) :
			x+=.3*Factor*Faktor2*sin(self.camera.Beta*M_PI/180.0);
			y+=.3*Factor*Faktor2*cos(self.camera.Beta*M_PI/180.0);
		if (KEY_DOWN) :
			x-=.3*Factor*Faktor2*sin(self.camera.Beta*M_PI/180.0);
			y-=.3*Factor*Faktor2*cos(self.camera.Beta*M_PI/180.0);
		if (KEY_LEFT) :
			x-=.3*Factor*Faktor2*cos(self.camera.Beta*M_PI/180.0);
			y+=.3*Factor*Faktor2*sin(self.camera.Beta*M_PI/180.0);
		if (KEY_RIGHT) :
			x+=.3*Factor*Faktor2*cos(self.camera.Beta*M_PI/180.0);
			y-=.3*Factor*Faktor2*sin(self.camera.Beta*M_PI/180.0);

		invalid=0;
		if (x<-124 or x>124 or (x>-63.5 and LageVerbesserungKopffeld)) :
			x=self.balls[0].Pos_xCM();

		if (y<-60.5 or y>60.5) :
			y=self.balls[0].Pos_yCM();

		for i in range(16) :
			if ((self.balls[i].Pos_xCM()-x)*(self.balls[i].Pos_xCM()-x)+
					(self.balls[i].Pos_yCM()-y)*(self.balls[i].Pos_yCM()-y)<32.7) :
				invalid=1;  #与其他球太近,无效

		#invalid
		if (not invalid) :
			self.self.balls[0].newPositionCM(x,y);
		if (KEY_SHIFT):
			self.camera.Move_Up(Factor)
		if (KEY_CTRL):
			self.camera.Move_Down(Factor)
		if (KEY_PAGE_UP):
			self.camera.Move_In(Factor)
		if (KEY_PAGE_DOWN):
			self.camera.Move_Out(Factor)
		if (KEY_HOME):
			self.camera.Zoom_In(Factor)
		if (KEY_END):
			self.camera.Zoom_Out(Factor)

	def JudgeHandling(self):
		if (ParamDef.JudgeDecision == -1) :
			ParamDef.JudgeDecision = Judge.Decisioning();
			ParamDef.RecodingChanges = ParamDef.JudgeDecision & 1;
			ParamDef.Foul = ParamDef.JudgeDecision & 2;
			ParamDef.LageVerbesserungKopffeld = ParamDef.JudgeDecision & 4;
			ParamDef.LageVerbesserung = ParamDef.JudgeDecision & 8;
			ParamDef.NeuAufbauenOderWeiterspielen = ParamDef.JudgeDecision & 16;
			ParamDef.NeuAufbauenOderAchtEinsetzen = ParamDef.JudgeDecision & 32;
			ParamDef.Player1Win = ParamDef.JudgeDecision & 64;
			ParamDef.Player2Win = ParamDef.JudgeDecision & 128;

			self.menu.NewMenuState();
Example #16
0
class Loading(object):
    def __init__(self, w, h, title):
        self.KeyInputState = {
            "reset": False,
            "space": False,
            "b": False,
            "v": False,
            "g": False,
            "h": False,
            "n": False
        }
        self.cam = Camera(60., 1.0, 0.1, 1000.0)
        #self.cam.setPos([0,10,1], [0,0,0])
        #self.cam.setPos([10,10,10], [0,0,0])
        #self.cam.setPos([10,5,10], [0,0,0])
        #self.cam.setPos([10,2,10], [0,0,0])
        self.cam.setPos([20, 10, 10], [0, 0, 0])
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1, 0, 0]
        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(100, 100)
        glutCreateWindow(title)
        glClearColor(0.25, 0.25, 0.25, 1.0)
        glEnable(GL_DEPTH_TEST)
        self.lighting.LightSet()

    def setBackground(self, filename):
        self.background.loadImage(filename)

    def reshape(self, w, h):
        self.cam.setAsp(w, h)
        glViewport(0, 0, w, h)

    def grid(self, option):
        self.gridMode = option

    def rotateGrid(self, angle, axis):
        self.gridAngle = angle
        self.gridAxis = axis

    def timerStart(self):
        self.timer.start()

    def timerStop(self):
        self.timer.stop()

    def timerReset(self):
        self.timer.reset()

    def getDt(self):
        return self.timer.getDt()

    def getEt(self):
        return self.timer.getEt()

    def frame(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        self.cam.applyCamera(self.background)

        self.lighting.LightPosition()
        if self.gridMode:
            self.graphics.drawGrid(100, self.gridAngle, self.gridAxis)

    def afterFrame(self):

        self.scene.draw()
        glFlush()

    def start(self, displayCallback, keyCallback):
        glutDisplayFunc(displayCallback)
        glutIdleFunc(displayCallback)
        glutKeyboardFunc(keyCallback)
        glutReshapeFunc(self.reshape)
        glutMainLoop()

    def drawBall(self, pos, radius=1.0):
        self.graphics.drawBall(pos, radius)

    def cameraAt(self, eye, target, up=[0, 1, 0]):
        self.cam.setPos(eye, target, up)

    def addObject(self, name, type):
        obj = VisualObj()
        obj.setNameAndType(name, type)
        self.scene.opaqueChildren.add(obj)
        return obj

    def addSphere(self, name):
        return self.addObject(name, 0)

    def addCube(self, name):
        return self.addObject(name, 1)

    def addTransparentObject(self, name, type):
        obj = VisualObj()
        obj.setNameAndType(name, type)
        self.scene.transChildren.add(obj)
        return obj

    def addTransparentSphere(self, name):
        return self.addTransparentObject(name, 0)

    def addTransparentCube(self, name):
        return self.addTransparentObject(name, 1)
def restoreLightController():
	import Lighting
	Lighting._setFromParams({'ratio': 1.0, 'brightness': 0.9090909090909091, 'material': [52.0, (0.85, 0.85, 0.85), 0.6], 'back': [(0.35740674433659325, 0.6604015517481454, -0.6604015517481455), (1.0, 1.0, 1.0), 0.0], 'mode': 'two-point', 'key': [(0.5818540202717035, 0.6065088516391486, 0.5418421467337303), (1.0, 1.0, 1.0), 1.0], 'contrast': 0.54, 'fill': [(0.5029585598958792, 0.3205128077767858, 0.8026856340302251), (1.0, 1.0, 1.0), 0.0]})
Example #18
0
        self.updateForce()
        print(self.vel[0])
        print("\n") 
        acc = self.gravity + self.force / self.mass
        self.vel = self.vel + acc*time
        self.loc = self.loc + self.vel*time

## initialize object ##
game = myGame(750, 750, "201724515 À±½ÂÈñ assigment02")
game.grid(True)
table = BillTable(billSize, [0, billSize[1]/2.0, 0])
ball1 = Ball(billSize, 5, [1, 0, 0, 1])
ball2 = Ball(billSize, -5, [0, 0, 1, 1]) 
clock = Timer()
clock.start()
light = Lighting([0, 100, 0, 0])
light.LightSet() 

## toggle setting ##
round = False;
lightON = True;

def draw():
    global angle 
    game.frame()
    drawBackGround()
    if(round is True) : 
        angle = angle + 0.02
    game.setCamera([cameraPos[0]*math.cos(angle) , cameraPos[1], cameraPos[2]*math.sin(angle)], cameraCen, [0, 1, 0])
    table.showing()
    ball1.simulate(clock.getDt())
Example #19
0
def display():
	import Lighting
	controller = Lighting.get()
	from chimera.extension.StdTools import raiseViewingTab
	raiseViewingTab(controller.Name)
	controller.showInterface(controller.Interface_Shininess)
Example #20
0
class Loading(object):
    def __init__(self, w, h, title):
        self.cam = Camera(90.0, 800/600,1, 100000.0)
        self.eye = [0.0, -2000.0, 3800.0]
        self.target = [0.0, 0.0, 2500.0]
        self.up = [0.0, 0.0, 1.0]
        self.cam.setPos(self.eye, self.target)
        self.timer = Timer()
        self.gridMode = False
        self.gridAngle = 0
        self.gridAxis = [1,0,0]

        self.graphics = Graphics()
        self.lighting = Lighting()
        self.scene = Scene()
        self.background = Background()
        self.obj_basic = OBJ('island_basic_1.obj', swapyz=True)
        self.obj_snow = OBJ('island_basic_snow.obj', swapyz=True)
        self.obj_rain = OBJ('island_basic_rain.obj', swapyz=True)
        self.obj = self.obj_basic
        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
        glutInitWindowSize(w, h)
        glutInitWindowPosition(800, 600)


        glEnable(GL_DEPTH_TEST)
        glShadeModel(GL_SMOOTH)
        self.lighting.LightSet()

    def changeModel_basic(self):
        self.obj = self.obj_basic

    def changeModel_snow(self):
        self.obj = self.obj_snow
    def changeModel_rain(self):
        self.obj = self.obj_rain
    def setBackground(self, filename):
        self.background.loadImage(filename)


    def reshape(self, w, h):
        self.cam.setAsp(w,h)
        glViewport(0,0, w,h)

    def grid(self, option):
        self.gridMode = option

    def rotateGrid(self, angle, axis):
        self.gridAngle = angle
        self.gridAxis = axis


    def timerStart(self):
        self.timer.start()

    def timerStop(self):
        self.timer.stop()

    def timerReset(self):
        self.timer.reset()


    def getDt(self):
        return self.timer.getDt()

    def getEt(self):
        return self.timer.getEt()

    def frame(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        self.cam.applyCamera(self.background)

        self.lighting.LightPosition(cos(self.getEt()) * 2000, sin(self.getEt()) * 2000 + 2000)

        if self.gridMode :
            self.graphics.drawGrid(100, self.gridAngle, self.gridAxis)

        glCallList(self.obj.gl_list)

    def afterFrame(self):

        self.scene.draw()
        glFlush()

    def start(self, displayCallback, keyCallback):
        glutDisplayFunc(displayCallback)
        glutIdleFunc(displayCallback)
        glutKeyboardFunc(keyCallback)
        glutReshapeFunc(self.reshape)
        glEnableClientState(GL_NORMAL_ARRAY)

        #glutMainLoop()

    def drawBall(self, pos, radius=0.0):
        self.graphics.drawBall(pos, radius)

    def cameraAt(self, eye, target, up=[0,0,1]):
        self.cam.setPos(eye, target, up)

    def addObject(self, name, type):
        obj = VisualObj()
        obj.setNameAndType(name, type)
        self.scene.opaqueChildren.add(obj)
        return obj

    def addSphere(self, name):
        return self.addObject(name, 0)

    def addCube(self, name):
        return self.addObject(name, 1)

    def addTransparentObject(self, name, type):
        obj = VisualObj()
        obj.setNameAndType(name, type)
        self.scene.transChildren.add(obj)
        return obj

    def addTransparentSphere(self, name):
        return self.addTransparentObject(name, 0)


    def addTransparentCube(self, name):
        return self.addTransparentObject(name, 1)
def restoreLightController():
	import Lighting
	Lighting._setFromParams({'ratio': 1.25, 'brightness': 1.16, 'material': [30.0, (0.85, 0.85, 0.85), 1.0], 'back': [(0.35740674433659325, 0.6604015517481455, -0.6604015517481455), (1.0, 1.0, 1.0), 0.0], 'mode': 'two-point', 'key': [(-0.35740674433659325, 0.6604015517481455, 0.6604015517481455), (1.0, 1.0, 1.0), 1.0], 'contrast': 0.83, 'fill': [(0.25056280708573153, 0.25056280708573153, 0.9351131265310294), (1.0, 1.0, 1.0), 0.0]})
Example #22
0
def restoreLightController():
	import Lighting
	c = Lighting.get().setFromParams({'quality': 'normal', 'shininess': (30.0, (0.84999999999999998, 0.84999999999999998, 0.84999999999999998), 1.0), 'key': (True, (1.0, 1.0, 1.0), 0.65327227115631104, (1.0, 1.0, 1.0), 1.0, (-0.35740674433659325, 0.66040155174814552, 0.66040155174814552)), 'fill': (True, (1.0, 1.0, 1.0), 0.49998998641967773, (1.0, 1.0, 1.0), 0.0, (0.25056280708573153, 0.25056280708573153, 0.9351131265310294))})
Example #23
0
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()
        self.balltable.drawSurface()

        glDisable(GL_DEPTH_TEST)
        self.balltable.drawLine()
        for ball in self.balls:
            ball.drawShadow()
        glEnable(GL_DEPTH_TEST)

        self.balltable.drawBorder()

        distance = 0
        #distance
        resolution = 1
        #Display resolution
        for ball in self.balls:
            x = ball.Pos_xCM() - self.camera.Pos_x
            y = ball.Pos_yCM() - self.camera.Pos_y
            z = self.camera.Pos_z
            distance = sqrt(x * x + y * y + z * z)
            resolution = (400 / distance)
            if (resolution < 3):
                resolution = 3
            resolution = (resolution / 2) * 2 + 1
            if (resolution > ParamDef.BallResolution):
                resolution = ParamDef.BallResolution
            ball.draw(resolution)

        glDisable(GL_DEPTH_TEST)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glDisable(GL_LIGHTING)

        self.menu.draw()

        if (self.state != GameState.START):
            self.shotStrength.draw()

        glEnable(GL_DEPTH_TEST)

        glutSwapBuffers()

    def Visible(self, visible):
        print "Visible"
        if (visible == GLUT_VISIBLE):
            glutIdleFunc(self.timerEvent)

    def StartHandling(self):
        self.camera.ScenicFlight(ParamDef.Factor)
        self.menu.Update(ParamDef.Factor)

    def ViewingHandling(self):
        self.menu.Update(ParamDef.Factor)

        if (KEY_UP):
            self.camera.Move_Front(ParamDef.Factor)
        if (KEY_DOWN):
            self.camera.Move_Back(ParamDef.Factor)
        if (KEY_RIGHT):
            self.camera.Move_Right(ParamDef.Factor)
        if (KEY_LEFT):
            self.camera.Move_Left(ParamDef.Factor)
        if (KEY_SHIFT):
            self.camera.Move_Up(ParamDef.Factor)
        if (KEY_CTRL):
            self.camera.Move_Down(ParamDef.Factor)
        if (KEY_PAGE_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_PAGE_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_HOME):
            self.camera.Zoom_In(ParamDef.Factor)
        if (KEY_END):
            self.camera.Zoom_Out(ParamDef.Factor)

    '''
	* Aim Handling
	'''

    def AimHandling(self):
        if (KEY_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_RIGHT):
            self.camera.SwingRight(2 * ParamDef.Factor,
                                   self.balls[0].Pos_xCM(),
                                   self.balls[0].Pos_yCM())
        if (KEY_LEFT):
            self.camera.SwingLeft(2 * ParamDef.Factor, self.balls[0].Pos_xCM(),
                                  self.balls[0].Pos_yCM())
        if (KEY_SHIFT):
            self.camera.SwingDown(ParamDef.Factor, self.balls[0].Pos_xCM(),
                                  self.balls[0].Pos_yCM())
        if (KEY_CTRL):
            self.camera.SwingUp(ParamDef.Factor, self.balls[0].Pos_xCM(),
                                self.balls[0].Pos_yCM())
        if (KEY_PAGE_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_PAGE_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_HOME):
            self.camera.Vertigo_In(ParamDef.Factor)
        if (KEY_END):
            self.camera.Vertigo_Out(ParamDef.Factor)

    def BackswingHandling(self):
        '''
		'''
        if (KEY_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_RIGHT):
            self.camera.SwingRight(2 * ParamDef.Factor,
                                   self.balls[0].Pos_xCM(),
                                   self.balls[0].Pos_yCM())
        if (KEY_LEFT):
            self.camera.SwingLeft(2 * ParamDef.Factor, self.balls[0].Pos_xCM(),
                                  self.balls[0].Pos_yCM())
        if (KEY_SHIFT):
            self.camera.SwingDown(ParamDef.Factor, self.balls[0].Pos_xCM(),
                                  self.balls[0].Pos_yCM())
        if (KEY_CTRL):
            self.camera.SwingUp(ParamDef.Factor, self.balls[0].Pos_xCM(),
                                self.balls[0].Pos_yCM())
        if (KEY_PAGE_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_PAGE_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_HOME):
            self.camera.Zoom_In(ParamDef.Factor)
        if (KEY_END):
            self.camera.Zoom_Out(ParamDef.Factor)

        shotStrength = MaxAusholStaerke * (1 - exp(
            (-ParamDef.FrameTimePoint + ParamDef.ShotStartTime) / 400.0))
        self.ShotStrength.setShockStrength(shotStrength / 3.333)

    '''
	 * 击球处理
	 *
	 '''

    def ShotHandling(self):
        FirstShot = 0
        #WeisseVersetzbar=0;

        if (KEY_UP):
            self.camera.Move_Front(ParamDef.Factor)
        if (KEY_DOWN):
            self.camera.Move_Back(ParamDef.Factor)
        if (KEY_RIGHT):
            self.camera.Move_Right(ParamDef.Factor)
        if (KEY_LEFT):
            self.camera.Move_Left(ParamDef.Factor)
        if (KEY_SHIFT):
            self.camera.Move_Up(ParamDef.Factor)
        if (KEY_CTRL):
            self.camera.Move_Down(ParamDef.Factor)
        if (KEY_PAGE_UP):
            self.camera.Move_In(ParamDef.Factor)
        if (KEY_PAGE_DOWN):
            self.camera.Move_Out(ParamDef.Factor)
        if (KEY_HOME):
            self.camera.Zoom_In(ParamDef.Factor)
        if (KEY_END):
            self.camera.Zoom_Out(ParamDef.Factor)

        #Frames++;                       # F"ur die Frames/sec-Anzeige

        # Zeit seit Stossbeginn
        time = ParamDef.FrameTimePoint - ParamDef.StartTime
        #time

        # Letzten Zustand noch zeichnen, wenn Stoss
        if (time > ParamDef.ShotTime):
            time = ParamDef.ShotTime  # eigentlich schon vorbei

        #printf("%i-%i=%i: ",FrameZeitpunkt,Startzeit,Zeit);

        for i in range(16):  # Alle Kugeln neu positionieren
            if (LightingList[time][i][2] <= 0):
                self.balls[i].newPositionD(LightingList[Zeit][i])

        self.ShotStrength.setShockStrength(shotStrength / 3.333 - Zeit / 3.0)

        if (not (time & 31)):
            neu = 0
            for i in range(16):
                if (self.ballsInGame[i] and self.ballsInHole[i] != 0
                        and (self.balls[i].Pos_x() == 3000)):
                    self.ballsInHole[i] = 1
                    neu = 1
            if (neu):
                self.menu.NewMenuState()

        if (time == ParamDef.ShotTime
                and not (self.mode == GameMode.TUTORIAL and
                         ParamDef.FrameTimePoint - ParamDef.StartTime < 1900)):
            # Animation schon fertig?

            ##ifndef _WIN32
            #printf(" %f Frames/sec\n",(Frames*100.0)/(Stossdauer+1.0));
            ##endif

            for i in range(16):
                if (self.ballssInGame[i] and not self.ballssInHole[i]
                        and (self.balls[i].Pos_x() == 3000)):
                    self.ballssInHole[i] = 1
            if (self.mode == GameMode.TRAINING
                    or self.mode == GameMode.TUTORIAL):
                if (self.balls[0].Pos_x() == 3000):
                    self.state = GameState.NEW_WHITE
                    ShotStrength.setShockStrength(0.0)
                    ParamDef.LageVerbesserung = 1
                    ParamDef.LageVerbesserungKopffeld = 1
                    WhiteChosen()
                    self.menu.NewMenuState()
                else:
                    self.state = GameState.VIEWING
                    ShotStrength.setShockStrength(0.0)
                    self.menu.NewMenuState()
            elif self.decision.Decisioning() == 0:
                self.state = GameState.JUDGEING
                ShotStrength.setShockStrength(0.0)
            else:
                self.state = GameState.VIEWING
                self.shotStrength.setShockStrength(0.0)
                self.menu.NewMenuState()

    '''
	* 放置白球
	'''

    def NewWhiteHandling(self):
        if (self.mode == GameMode.TRAINING):
            #ParamDef.
            LageVerbesserungKopffeld = 0
            #Location improving header
            LageVerbesserung = 1

        x = self.balls[0].Pos_xCM()
        y = self.balls[0].Pos_yCM()

        self.Factor2 = sqrt((self.balls[0].Pos_xCM() - self.camera.Pos_xCM()) *
                            (self.balls[0].Pos_xCM() - self.camera.Pos_xCM()) +
                            (self.balls[0].Pos_yCM() - self.camera.Pos_yCM()) *
                            (self.balls[0].Pos_yCM() - self.camera.Pos_yCM()) +
                            self.camera.Pos_zCM() * self.camera.Pos_zCM())

        self.Factor2 *= .005

        if (KEY_UP):
            x += .3 * Factor * Faktor2 * sin(self.camera.Beta * M_PI / 180.0)
            y += .3 * Factor * Faktor2 * cos(self.camera.Beta * M_PI / 180.0)
        if (KEY_DOWN):
            x -= .3 * Factor * Faktor2 * sin(self.camera.Beta * M_PI / 180.0)
            y -= .3 * Factor * Faktor2 * cos(self.camera.Beta * M_PI / 180.0)
        if (KEY_LEFT):
            x -= .3 * Factor * Faktor2 * cos(self.camera.Beta * M_PI / 180.0)
            y += .3 * Factor * Faktor2 * sin(self.camera.Beta * M_PI / 180.0)
        if (KEY_RIGHT):
            x += .3 * Factor * Faktor2 * cos(self.camera.Beta * M_PI / 180.0)
            y -= .3 * Factor * Faktor2 * sin(self.camera.Beta * M_PI / 180.0)

        invalid = 0
        if (x < -124 or x > 124 or (x > -63.5 and LageVerbesserungKopffeld)):
            x = self.balls[0].Pos_xCM()

        if (y < -60.5 or y > 60.5):
            y = self.balls[0].Pos_yCM()

        for i in range(16):
            if ((self.balls[i].Pos_xCM() - x) * (self.balls[i].Pos_xCM() - x) +
                (self.balls[i].Pos_yCM() - y) *
                (self.balls[i].Pos_yCM() - y) < 32.7):
                invalid = 1
                #与其他球太近,无效

        #invalid
        if (not invalid):
            self.self.balls[0].newPositionCM(x, y)
        if (KEY_SHIFT):
            self.camera.Move_Up(Factor)
        if (KEY_CTRL):
            self.camera.Move_Down(Factor)
        if (KEY_PAGE_UP):
            self.camera.Move_In(Factor)
        if (KEY_PAGE_DOWN):
            self.camera.Move_Out(Factor)
        if (KEY_HOME):
            self.camera.Zoom_In(Factor)
        if (KEY_END):
            self.camera.Zoom_Out(Factor)

    def JudgeHandling(self):
        if (ParamDef.JudgeDecision == -1):
            ParamDef.JudgeDecision = Judge.Decisioning()
            ParamDef.RecodingChanges = ParamDef.JudgeDecision & 1
            ParamDef.Foul = ParamDef.JudgeDecision & 2
            ParamDef.LageVerbesserungKopffeld = ParamDef.JudgeDecision & 4
            ParamDef.LageVerbesserung = ParamDef.JudgeDecision & 8
            ParamDef.NeuAufbauenOderWeiterspielen = ParamDef.JudgeDecision & 16
            ParamDef.NeuAufbauenOderAchtEinsetzen = ParamDef.JudgeDecision & 32
            ParamDef.Player1Win = ParamDef.JudgeDecision & 64
            ParamDef.Player2Win = ParamDef.JudgeDecision & 128

            self.menu.NewMenuState()