Browse Source

replay keyframe testing

shuvit 5 years ago
parent
commit
9f0c8b270d
1 changed files with 103 additions and 1 deletions
  1. 103
    1
      scripts/Manager.py

+ 103
- 1
scripts/Manager.py View File

@@ -1,3 +1,5 @@
1
+import mathutils
2
+
1 3
 def main():
2 4
 
3 5
     #"""
@@ -532,7 +534,107 @@ def main():
532 534
                 freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
533 535
                 cont.activate(freecam.actuators["rotright"])
534 536
             else:
535
-                cont.deactivate(freecam.actuators["rotright"])        
537
+                cont.deactivate(freecam.actuators["rotright"]) 
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+            #print('doing the keyframe stuff')            
547
+
548
+            anim_length = dict['replay_record_length']
549
+
550
+            def clock(freecam, inc):
551
+                pass
552
+                    
553
+            def transLength(freecam, keyframes, id, kl):
554
+                if id != 0:
555
+                    num = keyframes[id] - keyframes[(id-1)] 
556
+                else:          
557
+                    tn = anim_length - keyframes[kl]
558
+                    num = tn + keyframes[0]
559
+                    freecam['last_position'] = kl
560
+                return num      
561
+
562
+            def getProgress(freecam):
563
+                if freecam['cur_key'] != freecam['last_key']:
564
+                    print('new key!')
565
+                    freecam['pg'] = 0
566
+                else:
567
+                    freecam['pg'] += 1    
568
+                freecam['last_key'] = freecam['cur_key']    
569
+
570
+            
571
+            
572
+            keyframes = [190, 480,1050, 1800, 2500, 4000, 6000, 7000]
573
+            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])]
574
+            kl = len(keyframes) - 1
575
+            
576
+            if 'inited' not in freecam:
577
+                freecam['inited'] = True
578
+                freecam['clock'] = 0
579
+                freecam['cur_key'] = 0
580
+                freecam['last_key'] = kl
581
+                freecam['cur_length'] = 0
582
+                freecam['pg'] = 0
583
+                freecam['last_position'] = 0
584
+                freecam['playback'] = True
585
+            
586
+            #clock(freecam)
587
+            
588
+            freecam['cur_length'] = transLength(freecam, keyframes, freecam['cur_key'], kl)
589
+            getProgress(freecam)
590
+            skip = False
591
+            if own["objIndex"] > keyframes[kl]:
592
+                skip = True
593
+            if keyframes[freecam['cur_key']] > own["objIndex"]:
594
+                pass
595
+            else:
596
+                if skip == False:
597
+                    try:
598
+                        freecam['last_position'] = freecam['cur_key'] 
599
+                        freecam['cur_key'] += 1 
600
+                        temp = keyframes[freecam['cur_key']] 
601
+                        freecam['pg'] = 0
602
+                        
603
+                    except:
604
+                        print('excepting')
605
+                        freecam['cur_key'] = 0
606
+                        freecam['last_position'] = kl
607
+                        freecam['pg'] = 0
608
+
609
+            time = round(freecam['pg'] / freecam['cur_length'], 4) * 2
610
+
611
+            #if own['playback'] == True:
612
+            freecam.worldPosition = (positions[freecam['last_position']].lerp(positions[freecam['cur_key']], time))
613
+                
614
+                
615
+            print('cur_key', freecam['cur_key'], freecam['last_position'], 'time: ', own["objIndex"], freecam['cur_length'], freecam['pg'], time)
616
+            
617
+            
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
536 638
     ########################################                 
537 639
         if own['camnum'] == 0:
538 640
             cam = camList["Camera.003"]

Loading…
Cancel
Save