123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import bge
- from mathutils import Vector
-
- dict = bge.logic.globalDict
- dict['replay_record_length']
-
- bone_list = ["foot.ik.R", "foot.ik.L", "hips", "root", "spine", "spine-1", "chest", "chest-1", "clavicle.L", "clavicle.R", "deltoid.L", "deltoid.R", "upper_arm.fk.L", "upper_arm.fk.R", "forearm.fk.L", "forearm.fk.R", "hand.fk.L", "hand.fk.R", "neck", "head", "master"]
-
- def Record():
- scene = bge.logic.getCurrentScene()
- #own = cont.owner
- master = scene.objects['control_cube.002']
- cam = scene.objects['Camera.003']
- armature = scene.objects['Char4']
-
- if 'dataList' not in master:
- for x in bone_list:
- master['dataList'] = True
- master[str(x) + '-pos'] = []
- master[str(x) + '-rot'] = []
-
- for y in bone_list:
- x = armature.channels[y]
- #print('bone_name: ', x)
-
- #pos = (x.pose_head)+master.worldPosition
- pos = (x.pose_head)
- rot = Vector(x.channel_matrix.to_euler())
- #rot = x.rotation_euler
-
- if len(master[str(y) + '-pos']) > dict['replay_record_length']:
- master[str(y) + '-pos'].pop(0)
- master[str(y) + '-rot'].pop(0)
-
- master[str(y) + '-pos'].append(pos)
- master[str(y) + '-rot'].append(rot)
-
- def Playback(valueIndex):
- scene = bge.logic.getCurrentScene()
- #own = cont.owner
- master = scene.objects['control_cube.002']
- cam = scene.objects['Camera.003']
- armature = scene.objects['Char4']
- #armature.removeParent()
-
-
-
- #print(master['foot.ik.R-pos'], 'fooot rot')
-
-
-
- for y in bone_list:
- x = armature.channels[y]
- #x.location = [1,0,1]
-
-
- pl = master[str(y) + '-pos']
- rl = master[str(y) + '-rot']
- #print(valueIndex)
- #print(rl)
- #print(pl)
- #x.rotation_euler = rl[20]
- try:
- x.rotation_mode = 1
- x.location = pl[valueIndex]
- x.rotation_euler = rl[valueIndex]
-
- #x.rotation_euler = [1,1,1]
-
- print(x.rotation_mode, 'mode')
- except:
- print('index out of range')
-
- armature.update()
- #print('trying')
|