Skip to content

Commit f831936

Browse files
author
Nozomi Miyamori
committed
release version 2.0.0
* Support materials import, it gets more accurate look. * Import color variants of a model. * Colors of a model can be changed by setting the custom properties of a model. * Imporoved bones alignment. * TMC file dialog and TMCL file dialog are separated. and some other improvements.
1 parent 0073c53 commit f831936

File tree

10 files changed

+1275
-970
lines changed

10 files changed

+1275
-970
lines changed

src/ninja_gaiden_tmc/__init__.py

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,76 @@
11
# NINJA GAIDEN SIGMA 2 TMC Importer by Nozomi Miyamori is under the public domain
22
# and also marked with CC0 1.0. This file is a part of NINJA GAIDEN SIGMA 2 TMC Importer.
33

4-
from .tmc11 import ImportTMC11
4+
from .importer import import_ngs2_tmc
5+
6+
from . import tcmlib
7+
58
import bpy
69

10+
from bpy_extras.io_utils import ImportHelper
11+
from bpy.props import StringProperty
12+
from bpy.types import Operator
13+
14+
import os
15+
import mmap
16+
17+
def import_tmc_wrapper(context, tmc_path, tmcl_path):
18+
tmc_m, tmcl_m = mmap_open(tmc_path), mmap_open(tmcl_path)
19+
with tmc_m, tmcl_m:
20+
with tcmlib.ngs2.TMCParser(tmc_m, tmcl_m) as tmc:
21+
import_ngs2_tmc(context, tmc)
22+
23+
class SelectTMCLImportTMC(Operator, ImportHelper):
24+
bl_idname = 'ninja_gaiden_tmc.select_tmcl_import_tmc'
25+
bl_label = 'Select TMCL'
26+
bl_options = {'REGISTER', 'UNDO'}
27+
28+
filter_glob: StringProperty(
29+
default="*.tmcl;*.dat",
30+
options={'SKIP_SAVE', 'HIDDEN'},
31+
)
32+
33+
tmc_path: StringProperty()
34+
35+
def execute(self, context):
36+
if not self.tmc_path:
37+
return {'CANCELLED'}
38+
39+
try:
40+
import_tmc_wrapper(context, self.tmc_path, self.filepath)
41+
except tcmlib.ParserError as e:
42+
self.report({'ERROR'}, "Failed to parse TMC: {e}")
43+
return {'CANCELLED'}
44+
return {'FINISHED'}
45+
46+
class ImportTMCEntry(Operator, ImportHelper):
47+
'''Load a TMC file (NGS2)'''
48+
bl_idname = 'ninja_gaiden_tmc.import_tmc_entry'
49+
bl_label = 'Select TMC'
50+
51+
filter_glob: StringProperty(
52+
default="*.tmc;*.dat",
53+
options={'SKIP_SAVE', 'HIDDEN'},
54+
)
55+
56+
def execute(self, context):
57+
return bpy.ops.ninja_gaiden_tmc.select_tmcl_import_tmc('INVOKE_DEFAULT', tmc_path=self.filepath)
58+
59+
def mmap_open(path):
60+
with open(path, 'rb') as f:
61+
return mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
62+
763
def menu_func_import(self, context):
8-
self.layout.operator(ImportTMC11.bl_idname, text="Ninja Gaiden Sigam 2 TMC (.tmc/.tmcl)")
64+
self.layout.operator(ImportTMCEntry.bl_idname, text="Ninja Gaiden Sigam 2 TMC (.tmc/.tmcl)")
965

1066
def register():
11-
bpy.utils.register_class(ImportTMC11)
67+
bpy.utils.register_class(SelectTMCLImportTMC)
68+
bpy.utils.register_class(ImportTMCEntry)
1269
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
1370

1471
def unregister():
15-
bpy.utils.unregister_class(ImportTMC11)
72+
bpy.utils.unregister_class(SelectTMCLImportTMC)
73+
bpy.utils.unregister_class(ImportTMCEntry)
1674
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
1775

1876
if __name__ == "__main__":

src/ninja_gaiden_tmc/blender_manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version = "1.0.0"
22

33
id = "ninja_gaiden_tmc"
4-
version = "1.0.1"
4+
version = "2.0.0"
55
name = "Ninja Gaiden Sigma 2 TMC Format"
66
tagline = "Import Ninja Gaiden Sigma 2 TMC"
77
maintainer = "Nozomi Miyamori"

0 commit comments

Comments
 (0)