Skip to content

Commit

Permalink
release version 2.0.0
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Nozomi Miyamori committed Nov 24, 2024
1 parent 0073c53 commit f831936
Show file tree
Hide file tree
Showing 10 changed files with 1,275 additions and 970 deletions.
66 changes: 62 additions & 4 deletions src/ninja_gaiden_tmc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,76 @@
# NINJA GAIDEN SIGMA 2 TMC Importer by Nozomi Miyamori is under the public domain
# and also marked with CC0 1.0. This file is a part of NINJA GAIDEN SIGMA 2 TMC Importer.

from .tmc11 import ImportTMC11
from .importer import import_ngs2_tmc

from . import tcmlib

import bpy

from bpy_extras.io_utils import ImportHelper
from bpy.props import StringProperty
from bpy.types import Operator

import os
import mmap

def import_tmc_wrapper(context, tmc_path, tmcl_path):
tmc_m, tmcl_m = mmap_open(tmc_path), mmap_open(tmcl_path)
with tmc_m, tmcl_m:
with tcmlib.ngs2.TMCParser(tmc_m, tmcl_m) as tmc:
import_ngs2_tmc(context, tmc)

class SelectTMCLImportTMC(Operator, ImportHelper):
bl_idname = 'ninja_gaiden_tmc.select_tmcl_import_tmc'
bl_label = 'Select TMCL'
bl_options = {'REGISTER', 'UNDO'}

filter_glob: StringProperty(
default="*.tmcl;*.dat",
options={'SKIP_SAVE', 'HIDDEN'},
)

tmc_path: StringProperty()

def execute(self, context):
if not self.tmc_path:
return {'CANCELLED'}

try:
import_tmc_wrapper(context, self.tmc_path, self.filepath)
except tcmlib.ParserError as e:
self.report({'ERROR'}, "Failed to parse TMC: {e}")
return {'CANCELLED'}
return {'FINISHED'}

class ImportTMCEntry(Operator, ImportHelper):
'''Load a TMC file (NGS2)'''
bl_idname = 'ninja_gaiden_tmc.import_tmc_entry'
bl_label = 'Select TMC'

filter_glob: StringProperty(
default="*.tmc;*.dat",
options={'SKIP_SAVE', 'HIDDEN'},
)

def execute(self, context):
return bpy.ops.ninja_gaiden_tmc.select_tmcl_import_tmc('INVOKE_DEFAULT', tmc_path=self.filepath)

def mmap_open(path):
with open(path, 'rb') as f:
return mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)

def menu_func_import(self, context):
self.layout.operator(ImportTMC11.bl_idname, text="Ninja Gaiden Sigam 2 TMC (.tmc/.tmcl)")
self.layout.operator(ImportTMCEntry.bl_idname, text="Ninja Gaiden Sigam 2 TMC (.tmc/.tmcl)")

def register():
bpy.utils.register_class(ImportTMC11)
bpy.utils.register_class(SelectTMCLImportTMC)
bpy.utils.register_class(ImportTMCEntry)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)

def unregister():
bpy.utils.unregister_class(ImportTMC11)
bpy.utils.unregister_class(SelectTMCLImportTMC)
bpy.utils.unregister_class(ImportTMCEntry)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion src/ninja_gaiden_tmc/blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema_version = "1.0.0"

id = "ninja_gaiden_tmc"
version = "1.0.1"
version = "2.0.0"
name = "Ninja Gaiden Sigma 2 TMC Format"
tagline = "Import Ninja Gaiden Sigma 2 TMC"
maintainer = "Nozomi Miyamori"
Expand Down
Loading

0 comments on commit f831936

Please sign in to comment.