Skip to content

Commit

Permalink
manis - improve spec for ZTUAC
Browse files Browse the repository at this point in the history
  • Loading branch information
HENDRIX-ZT2 committed Nov 7, 2023
1 parent 98e5b4f commit 6ddda5c
Show file tree
Hide file tree
Showing 15 changed files with 432 additions and 68 deletions.
7 changes: 5 additions & 2 deletions generated/formats/manis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import struct
import os
import numpy as np
np.set_printoptions(precision=4, suppress=True)

import root_path
from generated.formats.manis.bitfields.ManisDtype import ManisDtype
Expand All @@ -19,7 +20,7 @@
except:
logging.warning(f"bitarray module is not installed")

np.set_printoptions(suppress=True, precision=4)
# np.set_printoptions(suppress=True, precision=4)


def swap16(i):
Expand Down Expand Up @@ -642,7 +643,9 @@ def make_signed(self, x):
mani = ManisFile()
# acro stand_ide
target = "acrocanthosaurus@standidle01"
mani.load("C:/Users/arnfi/Desktop/Coding/Frontier/Warhammer/Annihilator/animation.maniset52a766ac.manis")
# mani.load("C:/Users/arnfi/Desktop/Coding/Frontier/Warhammer/Annihilator/animation.maniset52a766ac.manis")
mani.load("C:/Users/arnfi/Desktop/enrichment.maniset8a375fce.manis")
# mani.load("C:/Users/arnfi/Desktop/camerabone.maniset67b9ba24.manis")
print(mani)
# mani.load("C:/Users/arnfi/Desktop/acro/notmotionextracted.maniset53978456.manis")
# mani.load("C:/Users/arnfi/Desktop/animationmotionextractedlocomotion.maniset648a1a01.manis")
Expand Down
47 changes: 47 additions & 0 deletions generated/formats/manis/compounds/ChunkSizesZT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from generated.array import Array
from generated.base_struct import BaseStruct
from generated.formats.manis.imports import name_type_map


class ChunkSizesZT(BaseStruct):

"""
32 bytes
"""

__name__ = 'ChunkSizesZT'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.index_a = name_type_map['Ushort'](self.context, 0, None)
self.index_b = name_type_map['Ushort'](self.context, 0, None)
self.zero_0 = name_type_map['Ushort'](self.context, 0, None)
self.count_a = name_type_map['Ushort'](self.context, 0, None)
self.count_b = name_type_map['Ushort'](self.context, 0, None)
self.zero_1 = name_type_map['Ushort'](self.context, 0, None)
self.zeros = Array(self.context, 0, None, (0,), name_type_map['Uint'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'index_a', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'index_b', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'zero_0', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'count_a', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'count_b', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'zero_1', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'zeros', Array, (0, None, (5,), name_type_map['Uint']), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'index_a', name_type_map['Ushort'], (0, None), (False, None)
yield 'index_b', name_type_map['Ushort'], (0, None), (False, None)
yield 'zero_0', name_type_map['Ushort'], (0, None), (False, None)
yield 'count_a', name_type_map['Ushort'], (0, None), (False, None)
yield 'count_b', name_type_map['Ushort'], (0, None), (False, None)
yield 'zero_1', name_type_map['Ushort'], (0, None), (False, None)
yield 'zeros', Array, (0, None, (5,), name_type_map['Uint']), (False, None)
37 changes: 37 additions & 0 deletions generated/formats/manis/compounds/ElemZt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from generated.array import Array
from generated.base_struct import BaseStruct
from generated.formats.manis.imports import name_type_map


class ElemZt(BaseStruct):

__name__ = 'ElemZt'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.floats = Array(self.context, 0, None, (0,), name_type_map['Float'])
self.a = name_type_map['Ushort'](self.context, 0, None)
self.b = name_type_map['Ushort'](self.context, 0, None)
self.c = name_type_map['Ushort'](self.context, 0, None)
self.d = name_type_map['Ushort'](self.context, 0, None)
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'floats', Array, (0, None, (4,), name_type_map['Float']), (False, None), (None, None)
yield 'a', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'b', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'c', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'd', name_type_map['Ushort'], (0, None), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'floats', Array, (0, None, (4,), name_type_map['Float']), (False, None)
yield 'a', name_type_map['Ushort'], (0, None), (False, None)
yield 'b', name_type_map['Ushort'], (0, None), (False, None)
yield 'c', name_type_map['Ushort'], (0, None), (False, None)
yield 'd', name_type_map['Ushort'], (0, None), (False, None)
5 changes: 4 additions & 1 deletion generated/formats/manis/compounds/ManiBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, context, arg=0, template=None, set_default=True):
self.uncompressed_pad = name_type_map['PadAlign'](self.context, 16, self.ref)
self.extra_war = name_type_map['WarExtra'](self.context, self, None)
self.compressed = name_type_map['CompressedManiData'](self.context, self, None)
self.subchunks = name_type_map['UnkChunkList'](self.context, 0, None)
self.subchunks = name_type_map['UnkChunkListZT'](self.context, 0, None)
if set_default:
self.set_defaults()

Expand Down Expand Up @@ -58,6 +58,7 @@ def _get_attribute_list(cls):
yield 'extra_war', name_type_map['WarExtra'], (None, None), (False, None), (None, True)
yield 'compressed', name_type_map['CompressedManiData'], (None, None), (False, None), (None, True)
yield 'subchunks', name_type_map['UnkChunkList'], (0, None), (False, None), (None, True)
yield 'subchunks', name_type_map['UnkChunkListZT'], (0, None), (False, None), (lambda context: context.version <= 257, True)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
Expand Down Expand Up @@ -90,3 +91,5 @@ def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield 'compressed', name_type_map['CompressedManiData'], (instance, None), (False, None)
if instance.arg.dtype.has_list > 0:
yield 'subchunks', name_type_map['UnkChunkList'], (0, None), (False, None)
if instance.context.version <= 257 and instance.arg.dtype.compression > 8:
yield 'subchunks', name_type_map['UnkChunkListZT'], (0, None), (False, None)
13 changes: 6 additions & 7 deletions generated/formats/manis/compounds/ManiInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def __init__(self, context, arg=0, template=None, set_default=True):

# 224 bytes
self.zeros_2 = Array(self.context, 0, None, (0,), name_type_map['Uint64'])

# 12 bytes
self.extra_zeros_pc = Array(self.context, 0, None, (0,), name_type_map['Uint'])
self.extra_zeros_pc = Array(self.context, 0, None, (0,), name_type_map['Ushort'])
self.pos_bone_min = name_type_map['BoneIndex'](self.context, self.dtype, None)
self.pos_bone_max = name_type_map['BoneIndex'](self.context, self.dtype, None)
self.ori_bone_min = name_type_map['BoneIndex'](self.context, self.dtype, None)
Expand Down Expand Up @@ -92,7 +90,7 @@ def _get_attribute_list(cls):
yield 'target_bone_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'pad_1', name_type_map['PadAlign'], (16, None), (False, None), (None, None)
yield 'zeros_2', Array, (0, None, (28,), name_type_map['Uint64']), (False, None), (None, None)
yield 'extra_zeros_pc', Array, (0, None, (3,), name_type_map['Uint']), (False, None), (lambda context: context.version <= 257, None)
yield 'extra_zeros_pc', Array, (0, None, (4,), name_type_map['Ushort']), (False, None), (lambda context: context.version <= 257, None)
yield 'pos_bone_min', name_type_map['BoneIndex'], (None, None), (False, None), (None, None)
yield 'pos_bone_max', name_type_map['BoneIndex'], (None, None), (False, None), (None, None)
yield 'ori_bone_min', name_type_map['BoneIndex'], (None, None), (False, None), (None, None)
Expand All @@ -107,7 +105,7 @@ def _get_attribute_list(cls):
yield 'scl_bone_count_repeat', name_type_map['BoneIndex'], (None, None), (False, None), (lambda context: context.version >= 258, None)
yield 'zero_0_end', name_type_map['Ushort'], (0, None), (False, None), (lambda context: context.version >= 258, None)
yield 'zero_1_end', name_type_map['Ushort'], (0, None), (False, None), (None, None)
yield 'pad_2', name_type_map['PadAlign'], (16, None), (False, None), (None, None)
yield 'pad_2', name_type_map['PadAlign'], (16, None), (False, None), (lambda context: context.version >= 258, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
Expand Down Expand Up @@ -138,7 +136,7 @@ def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield 'pad_1', name_type_map['PadAlign'], (16, instance.ref), (False, None)
yield 'zeros_2', Array, (0, None, (28,), name_type_map['Uint64']), (False, None)
if instance.context.version <= 257:
yield 'extra_zeros_pc', Array, (0, None, (3,), name_type_map['Uint']), (False, None)
yield 'extra_zeros_pc', Array, (0, None, (4,), name_type_map['Ushort']), (False, None)
yield 'pos_bone_min', name_type_map['BoneIndex'], (instance.dtype, None), (False, None)
yield 'pos_bone_max', name_type_map['BoneIndex'], (instance.dtype, None), (False, None)
yield 'ori_bone_min', name_type_map['BoneIndex'], (instance.dtype, None), (False, None)
Expand All @@ -154,4 +152,5 @@ def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield 'scl_bone_count_repeat', name_type_map['BoneIndex'], (instance.dtype, None), (False, None)
yield 'zero_0_end', name_type_map['Ushort'], (0, None), (False, None)
yield 'zero_1_end', name_type_map['Ushort'], (0, None), (False, None)
yield 'pad_2', name_type_map['PadAlign'], (16, instance.ref), (False, None)
if instance.context.version >= 258:
yield 'pad_2', name_type_map['PadAlign'], (16, instance.ref), (False, None)
12 changes: 6 additions & 6 deletions generated/formats/manis/compounds/SubChunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)

# for subchunk_list[n] needs chunksize_list[n]'s counta for array length
self.weird_list_one = Array(self.context, 0, None, (0,), name_type_map['WeirdElementOne'])
self.list_one = Array(self.context, 0, None, (0,), name_type_map['WeirdElementOne'])

# needs sum of countb's from weird list one
self.weird_list_two = name_type_map['WeirdElementTwoReader'](self.context, self.weird_list_one, None)
self.list_two = name_type_map['WeirdElementTwoReader'](self.context, self.list_one, None)
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'weird_list_one', Array, (0, None, (None,), name_type_map['WeirdElementOne']), (False, None), (None, None)
yield 'weird_list_two', name_type_map['WeirdElementTwoReader'], (None, None), (False, None), (None, None)
yield 'list_one', Array, (0, None, (None,), name_type_map['WeirdElementOne']), (False, None), (None, None)
yield 'list_two', name_type_map['WeirdElementTwoReader'], (None, None), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'weird_list_one', Array, (0, None, (instance.arg.counta,), name_type_map['WeirdElementOne']), (False, None)
yield 'weird_list_two', name_type_map['WeirdElementTwoReader'], (instance.weird_list_one, None), (False, None)
yield 'list_one', Array, (0, None, (instance.arg.counta,), name_type_map['WeirdElementOne']), (False, None)
yield 'list_two', name_type_map['WeirdElementTwoReader'], (instance.list_one, None), (False, None)
56 changes: 56 additions & 0 deletions generated/formats/manis/compounds/SubChunkReaderZt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from generated.base_struct import BaseStruct
from generated.formats.base.compounds.PadAlign import get_padding_size, get_padding


from generated.formats.manis.compounds.SubChunkZt import SubChunkZt
from generated.base_struct import BaseStruct


class SubChunkReaderZt(BaseStruct):

__name__ = 'SubChunkReaderZt'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)

@classmethod
def read_fields(cls, stream, instance):
instance.io_start = stream.tell()
# for chunk_sizes in instance.arg:
# chunk_sizes.keys = ()
for chunk_sizes in instance.arg:
chunk_sizes.keys = SubChunkZt.from_stream(stream, instance.context, chunk_sizes, None)
# print(f"SubChunkZt io_size {chunk_sizes.keys.io_size}")
pad_size = get_padding_size(chunk_sizes.keys.io_size, alignment=16)
chunk_sizes.padding = stream.read(pad_size)
assert chunk_sizes.padding == b"\x00" * pad_size
# print(f"{chunk_sizes.padding} padding ends at {stream.tell()}")
instance.io_size = stream.tell() - instance.io_start

@classmethod
def write_fields(cls, stream, instance):
instance.io_start = stream.tell()
for chunk_sizes in instance.arg:
SubChunkZt.to_stream(chunk_sizes.keys, stream, instance.context)
stream.write(get_padding(chunk_sizes.keys.io_size, alignment=8))
instance.io_size = stream.tell() - instance.io_start

@classmethod
def get_fields_str(cls, instance, indent=0):
s = ''
for chunk_sizes in instance.arg:
s += str(chunk_sizes.keys)
return s


32 changes: 32 additions & 0 deletions generated/formats/manis/compounds/SubChunkZt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from generated.array import Array
from generated.base_struct import BaseStruct
from generated.formats.manis.imports import name_type_map


class SubChunkZt(BaseStruct):

"""
arg is chunksizes
"""

__name__ = 'SubChunkZt'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.list_one = Array(self.context, 0, None, (0,), name_type_map['Float'])
self.list_two = Array(self.context, 0, None, (0,), name_type_map['ElemZt'])
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'list_one', Array, (0, None, (None, 6,), name_type_map['Float']), (False, None), (None, None)
yield 'list_two', Array, (0, None, (None,), name_type_map['ElemZt']), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'list_one', Array, (0, None, (instance.arg.count_b, 6,), name_type_map['Float']), (False, None)
yield 'list_two', Array, (0, None, (instance.arg.count_b,), name_type_map['ElemZt']), (False, None)
45 changes: 45 additions & 0 deletions generated/formats/manis/compounds/UnkChunkListZT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from generated.array import Array
from generated.base_struct import BaseStruct
from generated.formats.manis.imports import name_type_map


class UnkChunkListZT(BaseStruct):

__name__ = 'UnkChunkListZT'


def __init__(self, context, arg=0, template=None, set_default=True):
super().__init__(context, arg, template, set_default=False)
self.ref = name_type_map['Empty'](self.context, 0, None)
self.subchunk_count = name_type_map['Uint64'](self.context, 0, None)
self.pad_1 = name_type_map['Uint64'](self.context, 0, None)
self.chunksize_list = Array(self.context, 0, None, (0,), name_type_map['ChunkSizesZT'])
self.pad_2 = name_type_map['Uint64'](self.context, 0, None)
self.subchunk_list = name_type_map['SubChunkReaderZt'](self.context, self.chunksize_list, None)

# ?
self.pad = name_type_map['PadAlign'](self.context, 16, self.ref)
if set_default:
self.set_defaults()

@classmethod
def _get_attribute_list(cls):
yield from super()._get_attribute_list()
yield 'ref', name_type_map['Empty'], (0, None), (False, None), (None, None)
yield 'subchunk_count', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'pad_1', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'chunksize_list', Array, (0, None, (None,), name_type_map['ChunkSizesZT']), (False, None), (None, None)
yield 'pad_2', name_type_map['Uint64'], (0, None), (False, None), (None, None)
yield 'subchunk_list', name_type_map['SubChunkReaderZt'], (None, None), (False, None), (None, None)
yield 'pad', name_type_map['PadAlign'], (16, None), (False, None), (None, None)

@classmethod
def _get_filtered_attribute_list(cls, instance, include_abstract=True):
yield from super()._get_filtered_attribute_list(instance, include_abstract)
yield 'ref', name_type_map['Empty'], (0, None), (False, None)
yield 'subchunk_count', name_type_map['Uint64'], (0, None), (False, None)
yield 'pad_1', name_type_map['Uint64'], (0, None), (False, None)
yield 'chunksize_list', Array, (0, None, (instance.subchunk_count,), name_type_map['ChunkSizesZT']), (False, None)
yield 'pad_2', name_type_map['Uint64'], (0, None), (False, None)
yield 'subchunk_list', name_type_map['SubChunkReaderZt'], (instance.chunksize_list, None), (False, None)
yield 'pad', name_type_map['PadAlign'], (16, instance.ref), (False, None)
11 changes: 8 additions & 3 deletions generated/formats/manis/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@
'WarExtraPart': 'generated.formats.manis.compounds.WarExtraPart',
'WarExtra': 'generated.formats.manis.compounds.WarExtra',
'ChunkSizes': 'generated.formats.manis.compounds.ChunkSizes',
'ChunkSizesZT': 'generated.formats.manis.compounds.ChunkSizesZT',
'SubChunkReader': 'generated.formats.manis.compounds.SubChunkReader',
'UnkChunkList': 'generated.formats.manis.compounds.UnkChunkList',
'ManiBlock': 'generated.formats.manis.compounds.ManiBlock',
'SubChunkReaderZt': 'generated.formats.manis.compounds.SubChunkReaderZt',
'WeirdElementOne': 'generated.formats.manis.compounds.WeirdElementOne',
'WeirdElementTwo': 'generated.formats.manis.compounds.WeirdElementTwo',
'WeirdElementTwoReader': 'generated.formats.manis.compounds.WeirdElementTwoReader',
'SubChunk': 'generated.formats.manis.compounds.SubChunk',
'WeirdElementTwo': 'generated.formats.manis.compounds.WeirdElementTwo',
'ElemZt': 'generated.formats.manis.compounds.ElemZt',
'SubChunkZt': 'generated.formats.manis.compounds.SubChunkZt',
'UnkChunkListZT': 'generated.formats.manis.compounds.UnkChunkListZT',
'UnkChunkList': 'generated.formats.manis.compounds.UnkChunkList',
'ManiBlock': 'generated.formats.manis.compounds.ManiBlock',
}

name_type_map = {}
Expand Down
Loading

0 comments on commit 6ddda5c

Please sign in to comment.