adapt to PyBMap binding
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import bpy
|
||||
import tempfile
|
||||
from . import PROP_preferences, UTIL_functions, UTIL_file_browser, UTIL_blender_mesh
|
||||
from .PyBMap import bmap_wrapper as bmap
|
||||
|
||||
class BBP_OT_import_virtools(bpy.types.Operator, UTIL_file_browser.ImportVirtoolsFile):
|
||||
"""Import Virtools File"""
|
||||
@ -7,17 +9,37 @@ class BBP_OT_import_virtools(bpy.types.Operator, UTIL_file_browser.ImportVirtool
|
||||
bl_label = "Import Virtools File"
|
||||
bl_options = {'PRESET', 'UNDO'}
|
||||
|
||||
vt_encodings: bpy.props.StringProperty(
|
||||
name = "Encodings",
|
||||
description = "The encoding list used by Virtools engine to resolve object name. Use `;` to split multiple encodings",
|
||||
default = "1252"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder()
|
||||
return (
|
||||
PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder()
|
||||
and bmap.is_bmap_available())
|
||||
|
||||
def execute(self, context):
|
||||
UTIL_functions.message_box((self.general_get_filename(), ), 'Import Virtools File Path', 'INFO')
|
||||
# get encoding, split it by `;` and strip blank chars.
|
||||
encodings: str = self.vt_encodings
|
||||
_import_virtools(
|
||||
self.general_get_filename(),
|
||||
tuple(map(lambda x: x.strip(), encodings.split(';')))
|
||||
)
|
||||
self.report({'INFO'}, "Virtools File Importing Finished.")
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
def _import_virtools(file_name_: str, encodings_: tuple[str]) -> None:
|
||||
# create temp folder
|
||||
with tempfile.TemporaryDirectory() as vt_temp_folder:
|
||||
# create virtools reader context
|
||||
with bmap.BMFileReader(
|
||||
file_name_, vt_temp_folder,
|
||||
PROP_preferences.get_raw_preferences().mBallanceTextureFolder,
|
||||
encodings_) as reader:
|
||||
pass
|
||||
|
||||
def register() -> None:
|
||||
bpy.utils.register_class(BBP_OT_import_virtools)
|
||||
|
Reference in New Issue
Block a user