mirror of
https://github.com/fail0verflow/hbc.git
synced 2024-11-17 15:19:22 +01:00
Alameda fixes
This commit is contained in:
parent
cad274a7fb
commit
1536182957
@ -254,7 +254,7 @@ class TPL(object):
|
|||||||
inp += 1
|
inp += 1
|
||||||
|
|
||||||
ofs += x
|
ofs += x
|
||||||
inp += (8 - off) / 2
|
inp += (8 - off) // 2
|
||||||
outp += off
|
outp += off
|
||||||
outp += x * 7
|
outp += x * 7
|
||||||
|
|
||||||
@ -959,13 +959,18 @@ class Brlyt(object):
|
|||||||
self.Name = Struct.string(0x18, stripNulls=True)
|
self.Name = Struct.string(0x18, stripNulls=True)
|
||||||
self.Coords = Struct.float[10]
|
self.Coords = Struct.float[10]
|
||||||
|
|
||||||
class BrlytPIC1(BrlytPAN1):
|
class BrlytPIC1v1(BrlytPAN1):
|
||||||
FOURCC = "pic1"
|
FOURCC = "pic1"
|
||||||
def __format__(self):
|
def __format__(self):
|
||||||
Brlyt.BrlytPAN1.__format__(self)
|
Brlyt.BrlytPAN1.__format__(self)
|
||||||
self.unk = Struct.uint8[16]
|
self.unk = Struct.uint8[16]
|
||||||
self.Material = Struct.uint16
|
self.Material = Struct.uint16
|
||||||
self.Flags2 = Struct.uint16
|
self.Flags2 = Struct.uint16
|
||||||
|
|
||||||
|
class BrlytPIC1v2(BrlytPIC1v1):
|
||||||
|
FOURCC = "pic1"
|
||||||
|
def __format__(self):
|
||||||
|
Brlyt.BrlytPIC1v1.__format__(self)
|
||||||
self.MaterialCoords = Struct.float[8]
|
self.MaterialCoords = Struct.float[8]
|
||||||
|
|
||||||
def __init__(self, archive, data, renderer):
|
def __init__(self, archive, data, renderer):
|
||||||
@ -978,7 +983,7 @@ class Brlyt(object):
|
|||||||
self.Objects = {}
|
self.Objects = {}
|
||||||
self.PanePath = []
|
self.PanePath = []
|
||||||
self.PaneId = 0
|
self.PaneId = 0
|
||||||
self.Language = "ENG"
|
self.Language = b"ENG"
|
||||||
self.Renderer = renderer
|
self.Renderer = renderer
|
||||||
|
|
||||||
if data != None:
|
if data != None:
|
||||||
@ -1030,7 +1035,7 @@ class Brlyt(object):
|
|||||||
if isinstance(object,Pane):
|
if isinstance(object,Pane):
|
||||||
atoms += 1
|
atoms += 1
|
||||||
if isinstance(object,Picture):
|
if isinstance(object,Picture):
|
||||||
atom = Brlyt.BrlytPIC1()
|
atom = Brlyt.BrlytPIC1v2()
|
||||||
else:
|
else:
|
||||||
atom = Brlyt.BrlytPAN1()
|
atom = Brlyt.BrlytPAN1()
|
||||||
atom.Name = object.Name.encode("ascii") + b"\x00"*(0x18-len(object.Name))
|
atom.Name = object.Name.encode("ascii") + b"\x00"*(0x18-len(object.Name))
|
||||||
@ -1041,7 +1046,7 @@ class Brlyt(object):
|
|||||||
atom.Flags2 = object.Flags2
|
atom.Flags2 = object.Flags2
|
||||||
atom.Material = object.Material
|
atom.Material = object.Material
|
||||||
atom.unk = object.Unk
|
atom.unk = object.Unk
|
||||||
atom.MaterialCoords = sum(list(map(list,object.MaterialCoords)),[])
|
atom.MaterialCoords = sum(object.MaterialCoords,[])
|
||||||
data = atom.pack()
|
data = atom.pack()
|
||||||
|
|
||||||
if len(object.Children) > 0:
|
if len(object.Children) > 0:
|
||||||
@ -1163,13 +1168,20 @@ class Brlyt(object):
|
|||||||
|
|
||||||
def PIC1(self, data):
|
def PIC1(self, data):
|
||||||
wii.chexdump(data)
|
wii.chexdump(data)
|
||||||
pic = Brlyt.BrlytPIC1()
|
if len(data) == len(Brlyt.BrlytPIC1v1()):
|
||||||
|
pic = Brlyt.BrlytPIC1v1()
|
||||||
|
else:
|
||||||
|
pic = Brlyt.BrlytPIC1v2()
|
||||||
pic.unpack(data)
|
pic.unpack(data)
|
||||||
|
|
||||||
|
kw = {}
|
||||||
|
if not isinstance(pic, Brlyt.BrlytPIC1v1):
|
||||||
mc = []
|
mc = []
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
mc.append(pic.MaterialCoords[i*2:i*2+2])
|
mc.append(pic.MaterialCoords[i*2:i*2+2])
|
||||||
print(mc)
|
kw["matcoord"] = mc
|
||||||
p = Picture(pic.Name, pic.Flags, pic.Alpha/256.0, pic.Coords, pic.unk, pic.Material, pic.Flags2, mc)
|
|
||||||
|
p = Picture(pic.Name, pic.Flags, pic.Alpha/256.0, pic.Coords, pic.unk, pic.Material, pic.Flags2, *kw)
|
||||||
print(repr(p.Name))
|
print(repr(p.Name))
|
||||||
mat = self.Materials[pic.Material]
|
mat = self.Materials[pic.Material]
|
||||||
if mat is not None:
|
if mat is not None:
|
||||||
@ -1186,16 +1198,16 @@ class Brlyt(object):
|
|||||||
p = 0x1c
|
p = 0x1c
|
||||||
items = []
|
items = []
|
||||||
for i in range(nitems):
|
for i in range(nitems):
|
||||||
items.append(data[p:].split(b'\0', 1)[0])
|
items.append(data[p:p+0x10].split(b'\0', 1)[0].decode("ascii"))
|
||||||
p += 0x10
|
p += 0x10
|
||||||
for i in items:
|
for i in items:
|
||||||
try:
|
if i not in self.Objects:
|
||||||
|
print("Missing object:", i)
|
||||||
|
continue
|
||||||
if lang != self.Language:
|
if lang != self.Language:
|
||||||
self.Objects[i].Enabled = False
|
self.Objects[i].Enabled = False
|
||||||
else:
|
else:
|
||||||
self.Objects[i].Enabled = True
|
self.Objects[i].Enabled = True
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Brlan(object):
|
class Brlan(object):
|
||||||
A_COORD = "RLPA"
|
A_COORD = "RLPA"
|
||||||
@ -1541,6 +1553,9 @@ class Renderer(object):
|
|||||||
if isinstance(item, Picture):
|
if isinstance(item, Picture):
|
||||||
|
|
||||||
mat = self.Brlyt.Materials[item.Material]
|
mat = self.Brlyt.Materials[item.Material]
|
||||||
|
if not mat.Textures:
|
||||||
|
return
|
||||||
|
|
||||||
texture = self.Brlyt.Textures[mat.Textures[0][0]].GLTexture
|
texture = self.Brlyt.Textures[mat.Textures[0][0]].GLTexture
|
||||||
mtc = mat.TextureCoords[0]
|
mtc = mat.TextureCoords[0]
|
||||||
x, y, a, b, c, rot, xsc, ysc, xs, ys = item.Coords[:10]
|
x, y, a, b, c, rot, xsc, ysc, xs, ys = item.Coords[:10]
|
||||||
@ -1647,6 +1662,9 @@ class Renderer(object):
|
|||||||
for set in self.Brlan.Anim:
|
for set in self.Brlan.Anim:
|
||||||
for clss in set:
|
for clss in set:
|
||||||
for anim in clss:
|
for anim in clss:
|
||||||
|
if set.Name not in self.Brlyt.Objects:
|
||||||
|
print("Missing object for animation: %s (%s)" % (set.Name, clss.Type))
|
||||||
|
continue
|
||||||
#print(set.Name, clss.Type, anim.Type, anim.calc(frame), frame)
|
#print(set.Name, clss.Type, anim.Type, anim.calc(frame), frame)
|
||||||
if clss.Type == Brlan.A_COORD:
|
if clss.Type == Brlan.A_COORD:
|
||||||
self.Brlyt.Objects[set.Name].Coords[anim.Type] = anim.calc(frame)
|
self.Brlyt.Objects[set.Name].Coords[anim.Type] = anim.calc(frame)
|
||||||
@ -1657,6 +1675,7 @@ class Renderer(object):
|
|||||||
def MainLoop(self, loop):
|
def MainLoop(self, loop):
|
||||||
frame = 0
|
frame = 0
|
||||||
print("Starting mainloop: loop =",loop)
|
print("Starting mainloop: loop =",loop)
|
||||||
|
if self.Brlan:
|
||||||
print("Length in frames:",self.Brlan.Anim.FrameCount)
|
print("Length in frames:",self.Brlan.Anim.FrameCount)
|
||||||
while not self.Window.has_exit:
|
while not self.Window.has_exit:
|
||||||
self.Window.dispatch_events()
|
self.Window.dispatch_events()
|
||||||
@ -1732,11 +1751,18 @@ class Alameda(object):
|
|||||||
banner = U8(IMD5(root.Files['./meta/banner.bin']))
|
banner = U8(IMD5(root.Files['./meta/banner.bin']))
|
||||||
renderer.Brlyt = Brlyt(banner, banner.Files['./arc/blyt/banner.brlyt'], renderer)
|
renderer.Brlyt = Brlyt(banner, banner.Files['./arc/blyt/banner.brlyt'], renderer)
|
||||||
loop = './arc/anim/banner_start.brlan' not in banner.Files
|
loop = './arc/anim/banner_start.brlan' not in banner.Files
|
||||||
|
loop_anim = None
|
||||||
|
|
||||||
if not loop:
|
if not loop:
|
||||||
renderer.Brlan = Brlan(banner.Files['./arc/anim/banner_start.brlan'])
|
renderer.Brlan = Brlan(banner.Files['./arc/anim/banner_start.brlan'])
|
||||||
|
if './arc/anim/banner_loop.brlan' in banner.Files:
|
||||||
loop_anim = Brlan(banner.Files['./arc/anim/banner_loop.brlan'])
|
loop_anim = Brlan(banner.Files['./arc/anim/banner_loop.brlan'])
|
||||||
else:
|
else:
|
||||||
renderer.Brlan = Brlan(banner.Files['./arc/anim/banner.brlan'])
|
renderer.Brlan = Brlan(banner.Files['./arc/anim/banner.brlan'])
|
||||||
|
if './arc/anim/banner.brlan' in banner.Files:
|
||||||
|
renderer.Brlan = Brlan(banner.Files['./arc/anim/banner.brlan'])
|
||||||
|
else:
|
||||||
|
renderer.Brlan = None
|
||||||
|
|
||||||
if renderer.MainLoop(loop) and type == 'banner' and not loop:
|
if renderer.MainLoop(loop) and type == 'banner' and not loop:
|
||||||
renderer.Brlan = loop_anim
|
renderer.Brlan = loop_anim
|
||||||
|
Loading…
Reference in New Issue
Block a user