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
|
import tempfile, os, typing
|
||||||
from . import PROP_preferences, UTIL_ioport_shared
|
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 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
|
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):
|
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
|
# start saving
|
||||||
progress.enter_substeps(len(texture_crets), "Saving Textures")
|
progress.enter_substeps(len(texture_crets), "Saving Textures")
|
||||||
|
|
||||||
for tex, vttexture in texture_crets:
|
# create another temp folder for non-ballance texture saving
|
||||||
# set name
|
with tempfile.TemporaryDirectory() as nonballance_temp:
|
||||||
vttexture.set_name(tex.name)
|
print(f'Non-Ballance Texture Temp: {nonballance_temp}')
|
||||||
|
|
||||||
# step
|
for tex, vttexture in texture_crets:
|
||||||
progress.step()
|
# 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
|
# leave progress and return
|
||||||
progress.leave_substeps()
|
progress.leave_substeps()
|
||||||
|
@ -3,7 +3,7 @@ from bpy_extras.wm_utils.progress_report import ProgressReport
|
|||||||
import tempfile, os, typing
|
import tempfile, os, typing
|
||||||
from . import PROP_preferences, UTIL_ioport_shared
|
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 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
|
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):
|
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
|
# load as other textures
|
||||||
tex = UTIL_ballance_texture.load_other_texture(texpath_to_load)
|
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
|
# rename and insert it to map
|
||||||
tex.name = UTIL_virtools_types.virtools_name_regulator(vttexture.get_name())
|
tex.name = UTIL_virtools_types.virtools_name_regulator(vttexture.get_name())
|
||||||
texture_cret_map[vttexture] = tex
|
texture_cret_map[vttexture] = tex
|
||||||
|
@ -15,9 +15,9 @@ from . import UTIL_virtools_types, UTIL_functions
|
|||||||
# # bmx loading example
|
# # bmx loading example
|
||||||
# bmx_texture = blabla()
|
# bmx_texture = blabla()
|
||||||
# if bmx_texture.is_external():
|
# 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:
|
# 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
|
# texture_process(tex) # process loaded texture
|
||||||
#
|
#
|
||||||
# # nmo loading example
|
# # 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():
|
# if vt_texture.is_original_file() or vt_texture.is_external():
|
||||||
# place_to_load = vt_texture.filename
|
# 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:
|
# if try_filename:
|
||||||
# # load as ballance texture
|
# # load as ballance texture
|
||||||
# tex = PROP_virtools_texture.load_ballance_texture(try_filename)
|
# tex = UTIL_ballance_texture.load_ballance_texture(try_filename)
|
||||||
# else:
|
# else:
|
||||||
# # load as other texture
|
# # 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
|
# texture_process(tex) # process loaded texture
|
||||||
#
|
#
|
||||||
# ```
|
# ```
|
||||||
@ -43,13 +43,13 @@ from . import UTIL_virtools_types, UTIL_functions
|
|||||||
# ```
|
# ```
|
||||||
# # bmx saving example
|
# # bmx saving example
|
||||||
# tex: bpy.types.Image = texture_getter()
|
# tex: bpy.types.Image = texture_getter()
|
||||||
# try_filename = PROP_virtools_texture.get_ballance_texture_filename(
|
# try_filename = UTIL_ballance_texture.get_ballance_texture_filename(
|
||||||
# PROP_virtools_texture.get_texture_filepath(tex))
|
# UTIL_ballance_texture.get_texture_filepath(tex))
|
||||||
# if try_filename:
|
# if try_filename:
|
||||||
# write_external_filename(try_filename)
|
# write_external_filename(try_filename)
|
||||||
# else:
|
# else:
|
||||||
# realpath = PROP_virtools_texture.generate_other_texture_save_path(tex, tempfolder)
|
# realpath = UTIL_ballance_texture.generate_other_texture_save_path(tex, tempfolder)
|
||||||
# PROP_virtools_texture.save_other_texture(tex, realpath)
|
# UTIL_ballance_texture.save_other_texture(tex, realpath)
|
||||||
# write_filename(realpath)
|
# write_filename(realpath)
|
||||||
#
|
#
|
||||||
# ```
|
# ```
|
||||||
@ -285,7 +285,7 @@ def load_ballance_texture(texname: str) -> bpy.types.Image:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# try getting preset (also check texture name)
|
# 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:
|
if tex_preset is None:
|
||||||
raise UTIL_functions.BBPException("Invalid Ballance texture file name.")
|
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 tex[in] The saving texture
|
||||||
@param filepath[in] The absolute path to saving file.
|
@param filepath[in] The absolute path to saving file.
|
||||||
"""
|
"""
|
||||||
tex.save(filepath)
|
tex.save(filepath = filepath)
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user