Compare commits
5 Commits
v1.2.1
...
d1d83d39af
Author | SHA1 | Date | |
---|---|---|---|
d1d83d39af | |||
1ec4332576 | |||
125ad2792c | |||
![]() |
f451be4d18 | ||
![]() |
613cb20678 |
@@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
'name': 'SWBF .msh Import-Export',
|
||||
'author': 'Will Snyder, SleepKiller',
|
||||
"version": (1, 0, 0),
|
||||
"version": (1, 2, 1),
|
||||
'blender': (2, 80, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Export as SWBF .msh file',
|
||||
@@ -162,14 +162,14 @@ def menu_func_export(self, context):
|
||||
|
||||
|
||||
class ImportMSH(Operator, ImportHelper):
|
||||
""" Import an SWBF .msh file. """
|
||||
""" Import SWBF .msh file(s). """
|
||||
|
||||
bl_idname = "swbf_msh.import"
|
||||
bl_label = "Import SWBF .msh File(s)"
|
||||
filename_ext = ".msh"
|
||||
|
||||
files: CollectionProperty(
|
||||
name="File Path",
|
||||
name="File Path(s)",
|
||||
type=bpy.types.OperatorFileListElement,
|
||||
)
|
||||
|
||||
@@ -181,7 +181,7 @@ class ImportMSH(Operator, ImportHelper):
|
||||
|
||||
animation_only: BoolProperty(
|
||||
name="Import Animation(s)",
|
||||
description="Import on or more animations from the selected files and append each as a new Action to currently selected Armature.",
|
||||
description="Import one or more animations from the selected files and append each as a new Action to currently selected Armature.",
|
||||
default=False
|
||||
)
|
||||
|
||||
|
@@ -138,6 +138,9 @@ 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)
|
||||
|
@@ -32,7 +32,6 @@ def extract_and_apply_anim(filename : str, scene : Scene):
|
||||
|
||||
if scene.animation is None:
|
||||
raise Exception("No animation found in msh file!")
|
||||
|
||||
else:
|
||||
head, tail = os.path.split(filename)
|
||||
anim_name = tail.split(".")[0]
|
||||
@@ -40,6 +39,10 @@ def extract_and_apply_anim(filename : str, scene : Scene):
|
||||
if anim_name in bpy.data.actions:
|
||||
bpy.data.actions.remove(bpy.data.actions[anim_name], do_unlink=True)
|
||||
|
||||
for nt in arma.animation_data.nla_tracks:
|
||||
if anim_name == nt.strips[0].name:
|
||||
arma.animation_data.nla_tracks.remove(nt)
|
||||
|
||||
action = bpy.data.actions.new(anim_name)
|
||||
action.use_fake_user = True
|
||||
|
||||
@@ -103,4 +106,5 @@ def extract_and_apply_anim(filename : str, scene : Scene):
|
||||
fcurve_loc_z.keyframe_points.insert(i,t.z)
|
||||
|
||||
arma.animation_data.action = action
|
||||
|
||||
track = arma.animation_data.nla_tracks.new()
|
||||
track.strips.new(action.name, action.frame_range[0], action)
|
||||
|
@@ -165,19 +165,23 @@ def _read_matd(matd: Reader) -> Material:
|
||||
|
||||
elif next_header == "TX0D":
|
||||
with matd.read_child() as tx0d:
|
||||
mat.texture0 = tx0d.read_string()
|
||||
if tx0d.bytes_remaining() > 0:
|
||||
mat.texture0 = tx0d.read_string()
|
||||
|
||||
elif next_header == "TX1D":
|
||||
with matd.read_child() as tx1d:
|
||||
mat.texture1 = tx1d.read_string()
|
||||
if tx1d.bytes_remaining() > 0:
|
||||
mat.texture1 = tx1d.read_string()
|
||||
|
||||
elif next_header == "TX2D":
|
||||
with matd.read_child() as tx2d:
|
||||
mat.texture2 = tx2d.read_string()
|
||||
if tx2d.bytes_remaining() > 0:
|
||||
mat.texture2 = tx2d.read_string()
|
||||
|
||||
elif next_header == "TX3D":
|
||||
with matd.read_child() as tx3d:
|
||||
mat.texture3 = tx3d.read_string()
|
||||
if tx3d.bytes_remaining() > 0:
|
||||
mat.texture3 = tx3d.read_string()
|
||||
|
||||
else:
|
||||
matd.skip_bytes(1)
|
||||
@@ -203,7 +207,9 @@ def _read_modl(modl: Reader, materials_list: List[Material]) -> Model:
|
||||
|
||||
global model_counter
|
||||
global mndx_remap
|
||||
mndx_remap[index] = model_counter
|
||||
|
||||
if index not in mndx_remap:
|
||||
mndx_remap[index] = model_counter
|
||||
|
||||
model_counter += 1
|
||||
|
||||
|
Reference in New Issue
Block a user