1 Commits

4 changed files with 5 additions and 49 deletions

View File

@@ -1,7 +1,7 @@
bl_info = {
'name': 'SWBF .msh Import-Export',
'author': 'Will Snyder, SleepKiller',
"version": (1, 2, 1),
"version": (1, 0, 0),
'blender': (2, 80, 0),
'location': 'File > Import-Export',
'description': 'Export as SWBF .msh file',

View File

@@ -138,9 +138,6 @@ class Reader:
def how_much_left(self, pos):
return self.end_pos - pos
def bytes_remaining(self):
return self.end_pos - self.file.tell()
def skip_until(self, header):
while (self.could_have_child() and header not in self.peak_next_header()):
self.skip_bytes(1)

View File

@@ -39,20 +39,6 @@ class VertexWeight:
weight: float = 1.0
bone: int = 0
@dataclass
class ShadowGeometry:
""" Class representing 'SHDW' chunks. """
# Perhaps I could just use the positions list in the segment
# class, but I don't know if SHDW info can coexist with
# a normal geometry segment...
positions: List[Vector] = field(default_factory=list)
# The second two entries may not be necessary...
edges: List[Tuple[int,int,int,int]] = field(default_factory=list)
@dataclass
class GeometrySegment:
""" Class representing a 'SEGM' section in a .msh file. """
@@ -70,7 +56,6 @@ class GeometrySegment:
triangles: List[List[int]] = field(default_factory=list)
triangle_strips: List[List[int]] = None
shadow_geometry: ShadowGeometry = None
@dataclass
class CollisionPrimitive:

View File

@@ -165,23 +165,19 @@ def _read_matd(matd: Reader) -> Material:
elif next_header == "TX0D":
with matd.read_child() as tx0d:
if tx0d.bytes_remaining() > 0:
mat.texture0 = tx0d.read_string()
mat.texture0 = tx0d.read_string()
elif next_header == "TX1D":
with matd.read_child() as tx1d:
if tx1d.bytes_remaining() > 0:
mat.texture1 = tx1d.read_string()
mat.texture1 = tx1d.read_string()
elif next_header == "TX2D":
with matd.read_child() as tx2d:
if tx2d.bytes_remaining() > 0:
mat.texture2 = tx2d.read_string()
mat.texture2 = tx2d.read_string()
elif next_header == "TX3D":
with matd.read_child() as tx3d:
if tx3d.bytes_remaining() > 0:
mat.texture3 = tx3d.read_string()
mat.texture3 = tx3d.read_string()
else:
matd.skip_bytes(1)
@@ -387,29 +383,7 @@ def _read_segm(segm: Reader, materials_list: List[Material]) -> GeometrySegment:
# TODO: Dont know if/how to handle trailing 0 bug yet: https://schlechtwetterfront.github.io/ze_filetypes/msh.html#STRP
#if segm.read_u16 != 0:
# segm.skip_bytes(-2)
elif next_header == "SHDW":
shadow_geometry = ShadowGeometry()
with segm.read_child() as shdw:
#print("Found shadow chunk")
num_positions = shdw.read_u32()
#print(f" Num verts in shadow mesh: {num_positions}")
shadow_geometry.positions = [shdw.read_vec() for _ in range(num_positions)]
num_edges = shdw.read_u32()
#print(f" Num edges in shadow mesh: {num_edges}")
edges = []
for i in range(num_edges):
edges.append(tuple(shdw.read_u16(4)))
#print(" " + str(edges[-1]))
shadow_geometry.edges = edges
geometry_seg.shadow_geometry = shadow_geometry
elif next_header == "WGHT":
with segm.read_child() as wght: