Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Manager.py 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. import mathutils
  2. def main():
  3. #"""
  4. #Modified BGE Gameplay Recorder Version 2
  5. #originally written by Nicholas Anderson, aka Red Frost Games.
  6. #"""
  7. from bge import logic
  8. import Record
  9. import SortData
  10. dict = logic.globalDict
  11. #####Tweakables###############
  12. #Watch out! These numbers might bite!
  13. frame_rate = 60 #Set this to the framerate of your game.
  14. optimization = 1 #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
  15. recording_cutoff = dict['replay_record_length']
  16. #recording_cutoff = 7300 #3600 #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
  17. recorder_state = 1 #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
  18. allow_playback_break = True #Allow the player to resume playing from the position in the recording.
  19. #####Sensor names#############
  20. record_sensor = "Record"
  21. save_recording_sensor = "Save"
  22. load_recording_sensor = "Load"
  23. track_left_sensor = "Left"
  24. track_right_sensor = "Right"
  25. break_sensor = "Break"
  26. ##############################
  27. cont = logic.getCurrentController()
  28. own = cont.owner
  29. cont.sensors[record_sensor].skippedTicks = optimization
  30. #dict['recorder_on'] = recorder_on
  31. recorder_on = dict.get('recorder_on')
  32. own['recorder_on'] = recorder_on
  33. #print("recorder on: ", recorder_on)
  34. if recorder_on == 1:
  35. #----
  36. scene = logic.getCurrentScene()
  37. scene_list = logic.getSceneList()
  38. camList = scene.cameras
  39. followcam = camList["followcam"]
  40. freecam = camList["freecam"]
  41. skater = scene.objects["Char4"]
  42. cube = scene.objects["control_cube.002"]
  43. deck = scene.objects["deck"]
  44. trucks = scene.objects["trucks"]
  45. replay_cam_axis = own['replay_cam_axis']
  46. cam = own.actuators['Camera']
  47. #----
  48. joybutsens = "joyBut"
  49. #butt = cont.sensors[joybutsens]
  50. #aXis = cont.sensors["joysticksens"]
  51. #bk_but = 4
  52. back_on = dict['bkBut']
  53. #a_but = 0
  54. a_on = dict['aBut']
  55. #b_but = 1
  56. b_on = dict['bBut']
  57. #print(a on)
  58. last_back = own['last_back_but']
  59. lLR = dict['lLR']
  60. lUD = dict['lUD']
  61. rLR = dict['rLR']
  62. rUD = dict['rUD']
  63. lTrig = dict['lTrig']
  64. rTrig = dict['rTrig']
  65. aBut = dict['aBut']
  66. bBut = dict['bBut']
  67. xBut = dict['xBut']
  68. yBut = dict['yBut']
  69. lBump = dict['lBump']
  70. rBump = dict['rBump']
  71. bkBut = dict['bkBut']
  72. stBut = dict['stBut']
  73. xbBut = dict['xbBut']
  74. ltsBut = dict['ltsBut']
  75. rtsBut = dict['rtsBut']
  76. ldPad = dict['ldPad']
  77. rdPad = dict['rdPad']
  78. udPad = dict['udPad']
  79. ddPad = dict['ddPad']
  80. try:
  81. pause_state = dict['npause']
  82. last_pause = dict['last_npause']
  83. except:
  84. dict['npause'] = 0
  85. dict['last_npause'] = 0
  86. pause_state = 0
  87. last_pause = 0
  88. if own["playback"] != True:
  89. Record.main(recording_cutoff, cube)
  90. if cont.sensors[save_recording_sensor].positive:
  91. SortData.writeData.saveAll()
  92. #if cont.sensors[load_recording_sensor].positive or (cube["sel"] == 1 and cube["last_sel"] == 0):
  93. if own['back_state'] == 1 and back_on == 1 and last_back == 0:
  94. cube["last_sel"] == 1
  95. SortData.writeData.saveAll()
  96. own["playback"] = True
  97. own["playbackBroken"] = False
  98. freecam.worldPosition = own.worldPosition
  99. followcam.worldPosition = own.worldPosition
  100. cube['grindcement_vol'] = 0
  101. cube['grindcement_pitch'] = 0
  102. cube['grindrail_vol'] = 0
  103. cube['grindrail_pitch'] = 0
  104. cube['sroll_vol'] = 0
  105. cube['sroll_pitch'] = 0
  106. if own["playback"]:
  107. Record.loadData()
  108. #..................
  109. if cont.sensors[track_left_sensor].positive:
  110. own["objIndex"] -= 2
  111. logic.setLogicTicRate(frame_rate*own["playbackSpeed"])
  112. if cont.sensors[track_right_sensor].positive:
  113. own["objIndex"] += 2
  114. logic.setLogicTicRate(frame_rate*own["playbackSpeed"])
  115. if own["playback"] == True:
  116. #print("objIndex = ", own["lengthPos"], own['objIndex'])
  117. if rTrig > .01 and rTrig < .02:
  118. own["objIndex"] += 2
  119. logic.setLogicTicRate(frame_rate*.5)
  120. if (rTrig >= .02 and rTrig < .06) or own['loop_play'] == 1:
  121. own["objIndex"] += 2
  122. logic.setLogicTicRate(frame_rate*1)
  123. #print(own['objIndex'])
  124. if rTrig >= .06 and rTrig < .09:
  125. own["objIndex"] += 2
  126. logic.setLogicTicRate(frame_rate*1.5)
  127. if lTrig > .01 and lTrig < .02:
  128. own["objIndex"] -= 2
  129. logic.setLogicTicRate(frame_rate*.5)
  130. if lTrig >= .02 and lTrig < .06:
  131. own["objIndex"] -= 2
  132. logic.setLogicTicRate(frame_rate*1)
  133. if lTrig >= .06 and lTrig < .09:
  134. if own['loop_play'] == 1:
  135. own["objIndex"] -= 6
  136. #logic.setLogicTicRate(frame_rate*1.5)
  137. else:
  138. own["objIndex"] -= 2
  139. logic.setLogicTicRate(frame_rate*1.5)
  140. if b_on == True and pause_state == 0:
  141. #print("bbut_on")
  142. own['objIndex'] = 0
  143. own['valueIndex'] = 0
  144. logic.setLogicTicRate(frame_rate*1)
  145. #....................
  146. if allow_playback_break:
  147. if own['back_state'] == 0 and back_on == 1 and last_back == 0:
  148. own["playbackBroken"] = True
  149. own["playback"] = False
  150. elif own["playbackBroken"] and back_on == 0:
  151. Record.breakOut()
  152. logic.setLogicTicRate(frame_rate)
  153. #set value index
  154. own.state = recorder_state
  155. own["playbackBroken"] = False
  156. skater.stopAction(9999)
  157. deck.stopAction(9999)
  158. trucks.stopAction(9999)
  159. cont.activate(own.actuators['replayCam'])
  160. #print("unbreak")
  161. own['loop_play'] = 0
  162. #print("valueIndex = ", own['valueIndex'])
  163. if back_on == 1 and own['back_but'] == 0:
  164. #print("change back state")
  165. if own['back_state'] == True:
  166. own['back_state'] = False
  167. #elif own['back_state'] == False:
  168. else:
  169. own['back_state'] = True
  170. ###
  171. if own['last_playback'] != own['playback']:
  172. if own['last_playback'] == True:
  173. cont.activate(own.actuators['remove_hud'])
  174. cont.activate(own.actuators['add_stance'])
  175. own['camnum'] = 0
  176. cam = camList["Camera.003"]
  177. scene.active_camera = cam
  178. #print("turning replay off", own['playback'])
  179. if own['last_playback'] == False:
  180. #print("turning replay on", own['playback'])
  181. cont.activate(own.actuators['add_hud'])
  182. cont.activate(own.actuators['remove_stance'])
  183. own['objIndex'] = 0
  184. own['valueIndex'] = 3
  185. logic.setLogicTicRate(frame_rate*1)
  186. if dict['rtsBut'] == False and dict['last_rtsBut'] == True and own['playback'] == True:
  187. if 'pause' in scene_list:
  188. #cont.activate(own.actuators['remove_overlay'])
  189. cont.activate(own.actuators['add_hud'])
  190. else:
  191. #cont.activate(own.actuators['add_overlay']) #pause
  192. cont.activate(own.actuators['remove_hud']) #replay
  193. cont.activate(own.actuators['pause_replay_remove'])
  194. if pause_state == 1 and last_pause == 1 and own["playback"]:
  195. #print('pause_on')
  196. if 'pause_replay' not in scene_list:
  197. cont.activate(own.actuators['pause_replay_add'])
  198. #print('pause_on')
  199. if pause_state != 1 and own["playback"]:
  200. if 'pause_replay' in scene_list:
  201. cont.activate(own.actuators['pause_replay_remove'])
  202. if own['playback'] and 'pause' in scene_list:
  203. cont.activate(cube.actuators['remove_overlay'])
  204. ####
  205. if a_on == 1 and own['a_but'] == False and pause_state == 0:
  206. if own['loop_play'] == 1:
  207. own['loop_play'] = 0
  208. else:
  209. own['loop_play'] = 1
  210. if rLR > .05 and own["playback"]:
  211. act = cont.actuators["replayCam"]
  212. if rLR > .07:
  213. act.dLoc = [ .06, 0.0, 0.0]
  214. else:
  215. act.dLoc = [ .03, 0.0, 0.0]
  216. #cont.deactivate(own.actuators['Camera'])
  217. cont.activate(own.actuators['replayCam'])
  218. #print("move")
  219. elif rLR < -.05 and own["playback"]:
  220. act = cont.actuators["replayCam"]
  221. if rLR < -.07:
  222. act.dLoc = [ -.06, 0.0, 0.0]
  223. else:
  224. act.dLoc = [ -.03, 0.0, 0.0]
  225. #cont.deactivate(own.actuators['Camera'])
  226. #act.damping = 6
  227. cont.activate(own.actuators['replayCam'])
  228. #print("move")
  229. else:
  230. #pass
  231. cont.deactivate(own.actuators['replayCam'])
  232. #cont.activate(own.actuators['Camera'])
  233. #print("back state: ", own['back_state'], "last_back_but: ", own['last_back_but'], "back_but :", own['back_but'])
  234. #integer
  235. #
  236. #0 = +X axis
  237. #
  238. #1 = +Y axis
  239. #
  240. #2 = +Z axis
  241. #
  242. #3 = -X axis
  243. #
  244. #4 = -Y axis
  245. #
  246. #5 = -Z axis
  247. # if rLR > .05 and own["playback"]:
  248. # if own['last_rtsBut'] == True and rtsBut == False:
  249. # if replay_cam_axis == 0:
  250. # replay_cam_axis = 1
  251. # elif replay_cam_axis == 1:
  252. # replay_cam_axis = 3
  253. # elif replay_cam_axis == 3 :
  254. # replay_cam_axis = 4
  255. # elif replay_cam_axis == 4:
  256. # replay_cam_axis = 0
  257. # cam.axis = replay_cam_axis
  258. # cont.activate(cam)
  259. # print("set replay_cam_axis: ", replay_cam_axis)
  260. # own['replay_cam_axis'] = replay_cam_axis
  261. if own['last_ltsBut'] == True and ltsBut == False and own['playback']:
  262. # get camera named SecurityCam
  263. if own['camnum'] == 1:
  264. own['camnum'] = 2
  265. elif own['camnum'] == 0:
  266. own['camnum'] = 1
  267. elif own['camnum'] == 2:
  268. own['camnum'] = 0
  269. if own['last_rtsBut'] == True and rtsBut == False and own['playback']:
  270. # get camera named SecurityCam
  271. if "replay_HUD" in scene_list:
  272. cont.activate(own.actuators['remove_hud'])
  273. else:
  274. cont.activate(own.actuators['add_hud'])
  275. if own['camnum'] == 1 and own['playback']:
  276. scene.active_camera = followcam
  277. #################
  278. camspeed1 = .04 #.015
  279. camspeed2 = .1 #.055
  280. camrot1 = .02 #.005
  281. camrot2 = .04 #.02
  282. # perc = (lUD * 100 * (10 / 80)) *2
  283. # perc = round(perc,2)
  284. # print(perc)
  285. # perc = .025 * perc
  286. # newUD = (lUD * .1) * 5
  287. # if lUD > .0005 or lUD < -.0005:
  288. # camspeed1 = abs(perc)
  289. # camspeed2 = abs(perc)
  290. #up
  291. if lUD < -0.080:
  292. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  293. cont.activate(followcam.actuators["up"])
  294. print("fastup")
  295. else:
  296. cont.deactivate(followcam.actuators["up"])
  297. # #down
  298. if lUD > .080:
  299. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  300. cont.activate(followcam.actuators["down"])
  301. else:
  302. cont.deactivate(followcam.actuators["down"])
  303. # #left
  304. if lLR < -0.080:
  305. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  306. cont.activate(followcam.actuators["left"])
  307. else:
  308. cont.deactivate(followcam.actuators["left"])
  309. # #right
  310. if lLR > 0.080:
  311. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  312. cont.activate(followcam.actuators["right"])
  313. else:
  314. cont.deactivate(followcam.actuators["right"])
  315. #up
  316. if rUD < -0.080:
  317. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  318. cont.activate(followcam.actuators["rotup"])
  319. #print("uppppppppppppppppppppppppppp")
  320. else:
  321. cont.deactivate(followcam.actuators["rotup"])
  322. # #down
  323. if rUD > .080:
  324. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  325. cont.activate(followcam.actuators["rotdown"])
  326. else:
  327. cont.deactivate(followcam.actuators["rotdown"])
  328. # #left
  329. if rLR < -0.080:
  330. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  331. cont.activate(followcam.actuators["rotleft"])
  332. else:
  333. cont.deactivate(followcam.actuators["rotleft"])
  334. # #right
  335. if rLR > 0.080:
  336. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  337. cont.activate(followcam.actuators["rotright"])
  338. else:
  339. cont.deactivate(followcam.actuators["rotright"])
  340. #*********************************************
  341. if lUD > -0.080 and lUD < -0.030:
  342. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  343. cont.activate(followcam.actuators["up"])
  344. #print(lUD)
  345. else:
  346. cont.deactivate(followcam.actuators["up"])
  347. # #down
  348. if lUD < .080 and lUD > .03:
  349. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  350. cont.activate(followcam.actuators["down"])
  351. else:
  352. cont.deactivate(followcam.actuators["down"])
  353. # #left
  354. if lLR > -0.080 and lLR < -0.030:
  355. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  356. cont.activate(followcam.actuators["left"])
  357. else:
  358. cont.deactivate(followcam.actuators["left"])
  359. # #right
  360. if lLR < .080 and lLR > .03:
  361. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  362. cont.activate(followcam.actuators["right"])
  363. else:
  364. cont.deactivate(followcam.actuators["right"])
  365. #up
  366. if rUD > -0.080 and rUD < -0.030:
  367. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  368. cont.activate(followcam.actuators["rotup"])
  369. else:
  370. cont.deactivate(followcam.actuators["rotup"])
  371. # #down
  372. if rUD < .080 and rUD > .03:
  373. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  374. cont.activate(followcam.actuators["rotdown"])
  375. else:
  376. cont.deactivate(followcam.actuators["rotdown"])
  377. # #left
  378. if rLR > -0.080 and rLR < -0.030:
  379. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  380. cont.activate(followcam.actuators["rotleft"])
  381. else:
  382. cont.deactivate(followcam.actuators["rotleft"])
  383. # #right
  384. if rLR < .080 and rLR > .03:
  385. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  386. cont.activate(followcam.actuators["rotright"])
  387. else:
  388. cont.deactivate(followcam.actuators["rotright"])
  389. #################
  390. if own['camnum'] == 2 and own['playback']:
  391. scene.active_camera = freecam
  392. #act = freecam.actuators[
  393. camspeed1 = .015
  394. camspeed2 = .055
  395. camrot1 = .005
  396. camrot2 = .02
  397. #up
  398. if lUD < -0.080:
  399. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  400. cont.activate(freecam.actuators["up"])
  401. #print("fastup")
  402. else:
  403. cont.deactivate(freecam.actuators["up"])
  404. # #down
  405. if lUD > .080:
  406. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  407. cont.activate(freecam.actuators["down"])
  408. else:
  409. cont.deactivate(freecam.actuators["down"])
  410. # #left
  411. if lLR < -0.080:
  412. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  413. cont.activate(freecam.actuators["left"])
  414. else:
  415. cont.deactivate(freecam.actuators["left"])
  416. # #right
  417. if lLR > 0.080:
  418. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  419. cont.activate(freecam.actuators["right"])
  420. else:
  421. cont.deactivate(freecam.actuators["right"])
  422. #up
  423. if rUD < -0.080:
  424. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  425. cont.activate(freecam.actuators["rotup"])
  426. else:
  427. cont.deactivate(freecam.actuators["rotup"])
  428. # #down
  429. if rUD > .080:
  430. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  431. cont.activate(freecam.actuators["rotdown"])
  432. else:
  433. cont.deactivate(freecam.actuators["rotdown"])
  434. # #left
  435. if rLR < -0.080:
  436. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  437. cont.activate(freecam.actuators["rotleft"])
  438. else:
  439. cont.deactivate(freecam.actuators["rotleft"])
  440. # #right
  441. if rLR > 0.080:
  442. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  443. cont.activate(freecam.actuators["rotright"])
  444. else:
  445. cont.deactivate(freecam.actuators["rotright"])
  446. #*********************************************
  447. if lUD > -0.080 and lUD < -0.030:
  448. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  449. cont.activate(freecam.actuators["up"])
  450. #print(lUD)
  451. else:
  452. cont.deactivate(freecam.actuators["up"])
  453. # #down
  454. if lUD < .080 and lUD > .03:
  455. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  456. cont.activate(freecam.actuators["down"])
  457. else:
  458. cont.deactivate(freecam.actuators["down"])
  459. # #left
  460. if lLR > -0.080 and lLR < -0.030:
  461. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  462. cont.activate(freecam.actuators["left"])
  463. else:
  464. cont.deactivate(freecam.actuators["left"])
  465. # #right
  466. if lLR < .080 and lLR > .03:
  467. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  468. cont.activate(freecam.actuators["right"])
  469. else:
  470. cont.deactivate(freecam.actuators["right"])
  471. #up
  472. if rUD > -0.080 and rUD < -0.030:
  473. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  474. cont.activate(freecam.actuators["rotup"])
  475. else:
  476. cont.deactivate(freecam.actuators["rotup"])
  477. # #down
  478. if rUD < .080 and rUD > .03:
  479. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  480. cont.activate(freecam.actuators["rotdown"])
  481. else:
  482. cont.deactivate(freecam.actuators["rotdown"])
  483. # #left
  484. if rLR > -0.080 and rLR < -0.030:
  485. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  486. cont.activate(freecam.actuators["rotleft"])
  487. else:
  488. cont.deactivate(freecam.actuators["rotleft"])
  489. # #right
  490. if rLR < .080 and rLR > .03:
  491. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  492. cont.activate(freecam.actuators["rotright"])
  493. else:
  494. cont.deactivate(freecam.actuators["rotright"])
  495. #print('doing the keyframe stuff')
  496. anim_length = dict['replay_record_length']
  497. def clock(freecam, inc):
  498. pass
  499. def transLength(freecam, keyframes, id, kl):
  500. if id != 0:
  501. num = keyframes[id] - keyframes[(id-1)]
  502. else:
  503. tn = anim_length - keyframes[kl]
  504. num = tn + keyframes[0]
  505. freecam['last_position'] = kl
  506. return num
  507. def getProgress(freecam):
  508. if freecam['cur_key'] != freecam['last_key']:
  509. print('new key!')
  510. freecam['pg'] = 0
  511. else:
  512. freecam['pg'] += 1
  513. freecam['last_key'] = freecam['cur_key']
  514. keyframes = [190, 480,1050, 1800, 2500, 4000, 6000, 7000]
  515. positions = [mathutils.Vector([0,0,-1]), mathutils.Vector([-3,.5,-1]), mathutils.Vector([-4,1,-1]), mathutils.Vector([-5,2,-1]), mathutils.Vector([-5,-2,-1]), mathutils.Vector([-2,-2,-1]), mathutils.Vector([2,-2,-1]), mathutils.Vector([5,-3,-1])]
  516. kl = len(keyframes) - 1
  517. if 'inited' not in freecam:
  518. freecam['inited'] = True
  519. freecam['clock'] = 0
  520. freecam['cur_key'] = 0
  521. freecam['last_key'] = kl
  522. freecam['cur_length'] = 0
  523. freecam['pg'] = 0
  524. freecam['last_position'] = 0
  525. freecam['playback'] = True
  526. #clock(freecam)
  527. freecam['cur_length'] = transLength(freecam, keyframes, freecam['cur_key'], kl)
  528. getProgress(freecam)
  529. skip = False
  530. if own["objIndex"] > keyframes[kl]:
  531. skip = True
  532. if keyframes[freecam['cur_key']] > own["objIndex"]:
  533. pass
  534. else:
  535. if skip == False:
  536. try:
  537. freecam['last_position'] = freecam['cur_key']
  538. freecam['cur_key'] += 1
  539. temp = keyframes[freecam['cur_key']]
  540. freecam['pg'] = 0
  541. except:
  542. print('excepting')
  543. freecam['cur_key'] = 0
  544. freecam['last_position'] = kl
  545. freecam['pg'] = 0
  546. time = round(freecam['pg'] / freecam['cur_length'], 4) * 2
  547. #if own['playback'] == True:
  548. freecam.worldPosition = (positions[freecam['last_position']].lerp(positions[freecam['cur_key']], time))
  549. print('cur_key', freecam['cur_key'], freecam['last_position'], 'time: ', own["objIndex"], freecam['cur_length'], freecam['pg'], time)
  550. ########################################
  551. if own['camnum'] == 0:
  552. cam = camList["Camera.003"]
  553. scene.active_camera = cam
  554. valueIndex = own['valueIndex']
  555. n = (valueIndex / recording_cutoff) * 1000
  556. n = int(round(n))
  557. #n = 10
  558. #print("n: ", n, "--", valueIndex, recording_cutoff)
  559. #dict = logic.globalDict #Get the global dictionary
  560. dict['playhead'] = n
  561. own['last_back_but'] = own['back_but']
  562. own['back_but'] = back_on
  563. own['last_a_but'] = own['a_but']
  564. own['a_but'] = a_on
  565. own['last_ltsBut'] = ltsBut
  566. own['last_rtsBut'] = rtsBut
  567. own['last_playback'] = own['playback']
  568. dict['playback'] = own['playback']