fix offsets

This commit is contained in:
Aaron Kimbre 2022-05-19 19:18:13 -05:00
parent c9d329b1a1
commit 7500be5d71

View File

@ -364,25 +364,29 @@ def split_ugc(path):
else: else:
raise Exception("WHY ARE THERE NO MODELS????") raise Exception("WHY ARE THERE NO MODELS????")
filename = 0
for xml in output_xmls: for xml in output_xmls:
rigidsystems = xml.findall('.//RigidSystem') rigidsystems = xml.findall('.//RigidSystem')
rigids_parts = {} rigids_parts = {}
i = 0 i = 0
for rigidsytem in rigidsystems: for rigidsytem in rigidsystems:
rigids = rigidsytem.findall('.//Rigid') rigids = rigidsytem.findall('.//Rigid')
for rigid in rigids: bricks = xml.findall('.//Bone')
bricks = rigid.attrib['boneRefs'].split(',') transformation = list(map(float, rigids[0].attrib['transformation'].split(',')))
transformation = list(map(float, rigid.attrib['transformation'].split(','))) print(f"x: {transformation[-3]}")
print(f"x: {transformation[-3]}") print(f"y: {transformation[-2]}")
print(f"y: {transformation[-2]}") print(f"z: {transformation[-1]}")
print(f"z: {transformation[-1]}") for brick in bricks:
for brickID in bricks: old_transform = list(map(float, brick.attrib['transformation'].split(',')))
brick = xml.find(f".//Bone[@refID='{brickID}']") old_transform[-1] = old_transform[-1] - transformation[-1]
old_transform = list(map(float, brick.attrib['transformation'].split(','))) old_transform[-2] = old_transform[-2] - transformation[-2]
old_transform[-1] = old_transform[-1] - transformation[-1] old_transform[-3] = old_transform[-3] - transformation[-3]
old_transform[-2] = old_transform[-2] - transformation[-2] new_transform = ','.join(map(str, old_transform))
old_transform[-3] = old_transform[-3] - transformation[-3] brick.set("transformation", new_transform)
new_transform = ','.join(map(str, old_transform)) # only do it once
brick.set("transformation", new_transform) break
f = open(f"{filename}.bin", "ab")
print(ET.tostring(xml)) out = ET.tostring(xml).replace(b"\n", b"").replace(b" ", b"")
f.write(zlib.compress(out))
f.close()
filename += 1