ok, it was a code that i was trying to copy it from someone called psycrow because i was trying to get it to work and i tried looking up some results on github, but there no results of him making a scooby doo mystery mayhem animation blender addon from the community an importer and exporter, because i was trying to get different scripts to make them work like my own scripts and someone else scripts turns like i couldn't get them working but i made a script my own script instead.
Code: Select all
from struct import unpack, pack
import bpy
def pAnim_read(f):
ob = bpy.context.object
filesize = unpack(">I", f.read(4))[0]
unknown1 = unpack(">H", f.read(2))[0]
unknown2 = unpack(">H", f.read(2))[0]
framerate = unpack(">f", f.read(4))[0]
bonecount = unpack("B", f.read(1))[0]
type1 = unpack("B", f.read(1))[0]
type2 = unpack("B", f.read(1))[0]
type3 = unpack("B", f.read(1))[0]
for pbone in ob.pose.bones:
unk_off = unpack(">H", f.read(2))[0] # 4096 on or off
if unk_off == 0:
bone_id = unpack(">H", f.read(2))[0] # increment bone count
keyframe_type = unpack(">H", f.read(2))[0] # not sure
size_off = unpack(">H", f.read(2))[0]
elif unk_off == 4096:
keyframe_id = unpack(">H", f.read(2))[0]
unk = unpack(">H", f.read(2))[0]
size_on = unpack(">H", f.read(2))[0]
if keyframe_id == 0:
pbone.keyframe_insert(data_path="scale", index=keyframe_id)
elif keyframe_id == 1:
pbone.keyframe_insert(data_path="scale", index=keyframe_id)
elif keyframe_id == 2:
pbone.keyframe_insert(data_path="scale", index=keyframe_id)
elif keyframe_id == 6:
pbone.keyframe_insert(data_path="rotation_euler", index=keyframe_id-6)
elif keyframe_id == 7:
pbone.keyframe_insert(data_path="rotation_euler", index=keyframe_id-6)
elif keyframe_id == 8:
pbone.keyframe_insert(data_path="rotation_euler", index=keyframe_id-6)
elif keyframe_id == 3:
pbone.keyframe_insert(data_path="location", index=keyframe_id-3)
elif keyframe_id == 4:
pbone.keyframe_insert(data_path="location", index=keyframe_id-3)
elif keyframe_id == 5:
pbone.keyframe_insert(data_path="location", index=keyframe_id-3)
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_current = 0
bpy.context.scene.frame_end = int(framerate*30)
def pAnim_write(f):
bone_id = 0
keynum = 0
ob = bpy.context.object
fcurves2 = bpy.context.active_object.animation_data.action.fcurves
f.write(pack(">I", 16+8*len(ob.pose.bones)))
f.write(pack(">H", 4096))
f.write(pack(">H", 0))
f.write(pack(">f", bpy.context.scene.frame_end/30.0))
f.write(pack("B", len(ob.pose.bones)))
f.write(pack("B", 0))
f.write(pack("B", 0))
f.write(pack("B", 0))
for pbone in ob.pose.bones:
f.write(pack(">H", 0))
f.write(pack(">H", bone_id))
f.write(pack(">H", 0))
f.write(pack(">H", 0))
bone_id +=1
def _read_pAnim(filepath):
with open(filepath, "rb") as f:
pAnim_read(f)
def _write_pAnim(filepath):
with open(filepath, "wb") as f:
pAnim_write(f)
i have done some debugging through this stuff and not all them are in floats some of them are in 1000000.0 that you have divide with the same number and some of them are in floats and this only works if you have the renderware model inside the gcr and p2r and xbr with the animations