almost finish virtools exporing
This commit is contained in:
parent
3025fcf305
commit
70dd525315
@ -3,7 +3,7 @@ from bpy_extras.wm_utils.progress_report import ProgressReport
|
||||
import tempfile, os, typing
|
||||
from . import PROP_preferences, UTIL_ioport_shared
|
||||
from . import UTIL_virtools_types, UTIL_functions, UTIL_file_browser, UTIL_blender_mesh, UTIL_ballance_texture, UTIL_icons_manager
|
||||
from . import PROP_virtools_group, PROP_virtools_material, PROP_virtools_mesh
|
||||
from . import PROP_virtools_group, PROP_virtools_material, PROP_virtools_mesh, PROP_virtools_texture
|
||||
from .PyBMap import bmap_wrapper as bmap
|
||||
|
||||
class BBP_OT_export_virtools(bpy.types.Operator, UTIL_file_browser.ExportVirtoolsFile, UTIL_ioport_shared.ExportParams, UTIL_ioport_shared.VirtoolsParams):
|
||||
@ -390,12 +390,34 @@ def _export_virtools_textures(
|
||||
# start saving
|
||||
progress.enter_substeps(len(texture_crets), "Saving Textures")
|
||||
|
||||
for tex, vttexture in texture_crets:
|
||||
# set name
|
||||
vttexture.set_name(tex.name)
|
||||
# create another temp folder for non-ballance texture saving
|
||||
with tempfile.TemporaryDirectory() as nonballance_temp:
|
||||
print(f'Non-Ballance Texture Temp: {nonballance_temp}')
|
||||
|
||||
# step
|
||||
progress.step()
|
||||
for tex, vttexture in texture_crets:
|
||||
# set name
|
||||
vttexture.set_name(tex.name)
|
||||
|
||||
# set texture cfg
|
||||
rawtex: PROP_virtools_texture.RawVirtoolsTexture = PROP_virtools_texture.get_raw_virtools_texture(tex)
|
||||
vttexture.set_save_options(rawtex.mSaveOptions)
|
||||
vttexture.set_video_format(rawtex.mVideoFormat)
|
||||
|
||||
# save core texture
|
||||
# load ballance textures to vt engine from external ref path
|
||||
# load other textures to vt engine from temp folder.
|
||||
# no need to distinguish save options
|
||||
try_filepath: str | None = UTIL_ballance_texture.get_ballance_texture_filename(
|
||||
UTIL_ballance_texture.get_texture_filepath(tex))
|
||||
if try_filepath is None:
|
||||
# non-ballance file, save in temp and change file path to point to it.
|
||||
try_filepath = UTIL_ballance_texture.generate_other_texture_save_path(tex, nonballance_temp)
|
||||
UTIL_ballance_texture.save_other_texture(tex, try_filepath)
|
||||
# load into vt engine
|
||||
vttexture.load_image(try_filepath)
|
||||
|
||||
# step
|
||||
progress.step()
|
||||
|
||||
# leave progress and return
|
||||
progress.leave_substeps()
|
||||
|
@ -3,7 +3,7 @@ from bpy_extras.wm_utils.progress_report import ProgressReport
|
||||
import tempfile, os, typing
|
||||
from . import PROP_preferences, UTIL_ioport_shared
|
||||
from . import UTIL_virtools_types, UTIL_functions, UTIL_file_browser, UTIL_blender_mesh, UTIL_ballance_texture
|
||||
from . import PROP_virtools_group, PROP_virtools_material, PROP_virtools_mesh
|
||||
from . import PROP_virtools_group, PROP_virtools_material, PROP_virtools_mesh, PROP_virtools_texture
|
||||
from .PyBMap import bmap_wrapper as bmap
|
||||
|
||||
class BBP_OT_import_virtools(bpy.types.Operator, UTIL_file_browser.ImportVirtoolsFile, UTIL_ioport_shared.ImportParams, UTIL_ioport_shared.VirtoolsParams):
|
||||
@ -103,6 +103,12 @@ def _import_virtools_textures(
|
||||
# load as other textures
|
||||
tex = UTIL_ballance_texture.load_other_texture(texpath_to_load)
|
||||
|
||||
# set texture cfg
|
||||
rawtex: PROP_virtools_texture.RawVirtoolsTexture = PROP_virtools_texture.RawVirtoolsTexture()
|
||||
rawtex.mSaveOptions = vttexture.get_save_options()
|
||||
rawtex.mVideoFormat = vttexture.get_video_format()
|
||||
PROP_virtools_texture.set_raw_virtools_texture(tex, rawtex)
|
||||
|
||||
# rename and insert it to map
|
||||
tex.name = UTIL_virtools_types.virtools_name_regulator(vttexture.get_name())
|
||||
texture_cret_map[vttexture] = tex
|
||||
|
@ -15,9 +15,9 @@ from . import UTIL_virtools_types, UTIL_functions
|
||||
# # bmx loading example
|
||||
# bmx_texture = blabla()
|
||||
# if bmx_texture.is_external():
|
||||
# tex = PROP_virtools_texture.load_ballance_texture(bmx_texture.filename)
|
||||
# tex = UTIL_ballance_texture.load_ballance_texture(bmx_texture.filename)
|
||||
# else:
|
||||
# tex = PROP_virtools_texture.load_other_texture(os.path.join(tempfolder, 'Textures', bmx_texture.filename))
|
||||
# tex = UTIL_ballance_texture.load_other_texture(os.path.join(tempfolder, 'Textures', bmx_texture.filename))
|
||||
# texture_process(tex) # process loaded texture
|
||||
#
|
||||
# # nmo loading example
|
||||
@ -29,13 +29,13 @@ from . import UTIL_virtools_types, UTIL_functions
|
||||
# if vt_texture.is_original_file() or vt_texture.is_external():
|
||||
# place_to_load = vt_texture.filename
|
||||
#
|
||||
# try_filename = PROP_virtools_texture.get_ballance_texture_filename(place_to_load)
|
||||
# try_filename = UTIL_ballance_texture.get_ballance_texture_filename(place_to_load)
|
||||
# if try_filename:
|
||||
# # load as ballance texture
|
||||
# tex = PROP_virtools_texture.load_ballance_texture(try_filename)
|
||||
# tex = UTIL_ballance_texture.load_ballance_texture(try_filename)
|
||||
# else:
|
||||
# # load as other texture
|
||||
# tex = PROP_virtools_texture.load_other_texture(place_to_load)
|
||||
# tex = UTIL_ballance_texture.load_other_texture(place_to_load)
|
||||
# texture_process(tex) # process loaded texture
|
||||
#
|
||||
# ```
|
||||
@ -43,13 +43,13 @@ from . import UTIL_virtools_types, UTIL_functions
|
||||
# ```
|
||||
# # bmx saving example
|
||||
# tex: bpy.types.Image = texture_getter()
|
||||
# try_filename = PROP_virtools_texture.get_ballance_texture_filename(
|
||||
# PROP_virtools_texture.get_texture_filepath(tex))
|
||||
# try_filename = UTIL_ballance_texture.get_ballance_texture_filename(
|
||||
# UTIL_ballance_texture.get_texture_filepath(tex))
|
||||
# if try_filename:
|
||||
# write_external_filename(try_filename)
|
||||
# else:
|
||||
# realpath = PROP_virtools_texture.generate_other_texture_save_path(tex, tempfolder)
|
||||
# PROP_virtools_texture.save_other_texture(tex, realpath)
|
||||
# realpath = UTIL_ballance_texture.generate_other_texture_save_path(tex, tempfolder)
|
||||
# UTIL_ballance_texture.save_other_texture(tex, realpath)
|
||||
# write_filename(realpath)
|
||||
#
|
||||
# ```
|
||||
@ -285,7 +285,7 @@ def load_ballance_texture(texname: str) -> bpy.types.Image:
|
||||
"""
|
||||
|
||||
# try getting preset (also check texture name)
|
||||
tex_preset: PROP_virtools_texture.RawVirtoolsTexture = g_BallanceTexturePresets.get(texname, None)
|
||||
tex_preset: PROP_virtools_texture.RawVirtoolsTexture | None = g_BallanceTexturePresets.get(texname, None)
|
||||
if tex_preset is None:
|
||||
raise UTIL_functions.BBPException("Invalid Ballance texture file name.")
|
||||
|
||||
@ -350,6 +350,6 @@ def save_other_texture(tex: bpy.types.Image, filepath: str) -> None:
|
||||
@param tex[in] The saving texture
|
||||
@param filepath[in] The absolute path to saving file.
|
||||
"""
|
||||
tex.save(filepath)
|
||||
tex.save(filepath = filepath)
|
||||
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user