Skip to content

Commit

Permalink
Update import module
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier150 committed Jan 22, 2024
1 parent 1327b07 commit 8f4ee9e
Show file tree
Hide file tree
Showing 12 changed files with 1,072 additions and 539 deletions.
21 changes: 13 additions & 8 deletions blender-for-unrealengine/bfu_import_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,27 @@

import importlib

from . import bps
from . import import_module_utils
from . import import_module_unreal_utils
from . import asset_import
from . import sequencer_import

if "bps" in locals():
importlib.reload(bps)
if "import_module_utils" in locals():
importlib.reload(import_module_utils)
if "import_module_unreal_utils" in locals():
importlib.reload(import_module_unreal_utils)
if "asset_import" in locals():
importlib.reload(asset_import)
if "sequencer_import" in locals():
importlib.reload(sequencer_import)



print("Import module loaded.")

def run_asset_import(assets_data):
pass
asset_import.ImportAllAssets(assets_data)
if asset_import.ready_for_asset_import():
return asset_import.ImportAllAssets(assets_data)

def run_sequencer_import(sequence_data):
pass
sequencer_import.CreateSequencer(sequence_data)
if sequencer_import.ready_for_sequence_import():
return sequencer_import.CreateSequencer(sequence_data)
898 changes: 444 additions & 454 deletions blender-for-unrealengine/bfu_import_module/asset_import.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,11 @@ def RunImportScriptWithJsonData():

import_assets_data = JsonLoadFile(os.path.join(dir_path, json_data_file))

import_module_path = import_assets_data["info"]["import_modiule_path"] # Module to run
print("Module path to import:", import_module_path)

import_module_path = import_assets_data["info"]["import_modiule_path"] # Module to run
imported_module, module_name = load_module(import_module_path)

unload_module(module_name)
imported_module.run_asset_import(import_assets_data)

print("Start importing assets.")
RunImportScriptWithJsonData()
print("Importing assets finished.")
if __name__ == "__main__":
RunImportScriptWithJsonData()
39 changes: 39 additions & 0 deletions blender-for-unrealengine/bfu_import_module/bps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ====================== BEGIN GPL LICENSE BLOCK ============================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# All rights reserved.
#
# ======================= END GPL LICENSE BLOCK =============================

# ----------------------------------------------
# BPS -> BleuRaven Python Script
# BleuRaven.fr
# XavierLoux.com
# ----------------------------------------------

import importlib

from . import advprint
from . import utils
from . import math
from . import color_set

if "advprint" in locals():
importlib.reload(advprint)
if "utils" in locals():
importlib.reload(utils)
if "math" in locals():
importlib.reload(math)
if "math" in locals():
importlib.reload(color_set)
127 changes: 127 additions & 0 deletions blender-for-unrealengine/bfu_import_module/bps/advprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# ====================== BEGIN GPL LICENSE BLOCK ============================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# All rights reserved.
#
# ======================= END GPL LICENSE BLOCK =============================

# ----------------------------------------------
# BPS -> BleuRaven Python Script
# BleuRaven.fr
# XavierLoux.com
# ----------------------------------------------


import sys
import time


class ProgressionBarClass():

def _get_name(self):
return self.__name

def _set_name(self, value):
if not isinstance(value, str):
raise TypeError("name must be set to an String")
self.__name = value

name = property(_get_name, _set_name)

def _get_length(self):
return self.__length

def _set_length(self, value):
if not isinstance(value, int):
raise TypeError("length must be set to an Integer")
self.__length = value

length = property(_get_length, _set_length)

previous_step = 0.0

def _get_total_step(self):
return self.__total_step

def _set_total_step(self, value):
if not (isinstance(value, int) or isinstance(value, float)):
raise TypeError("total_step must be set to an Integer or Float")

self.__total_step = value

total_step = property(_get_total_step, _set_total_step)

# Visual
show_block = True
show_steps = True
show_percentage = True

def __init__(self):
self.__name = "My progression bar"
self.__length = 20 # modify this to change the length
self.__previous_step = 0.0
self.__total_step = 1.0 # from 0 to 1
self.__counter_start = time.perf_counter()

def update_progress(self, progress):
job_title = self.__name
length = self.__length
total_step = self.__total_step
self.__previous_step = progress # Update the previous step.

is_done = False
if progress >= total_step:
is_done = True

# Write message.
msg = "\r{0}:".format(job_title)

if self.show_block:
block = int(round(length*progress/total_step))
msg += " [{0}]".format("#"*block + "-"*(length-block))

if self.show_steps:
msg += " {0}/{1}".format(progress, total_step)

if is_done:
msg += " DONE IN {0}s\r\n".format(round(time.perf_counter()-self.__counter_start, 3))

else:
if self.show_percentage:
msg += " {0}%".format(round((progress*100)/total_step, 2))

sys.stdout.write(msg)
sys.stdout.flush()


def print_separation(number=60, char="-"):
"""
Prints a separation line consisting of '#' characters.
Args:
number (int, optional): The number of '#' characters in the line. Defaults to 60.
"""
print("# {0} #".format(char * number))


def print_title(text, number=60):
"""
Prints a title surrounded by a line of '#' characters.
Args:
text (str): The text of the title.
number (int, optional): The total number of characters in the line. Defaults to 60.
"""
remain_number = len(text) - number - 2
print("# {0} {1} {2} #".format("-" * remain_number, text, "-" * remain_number))
156 changes: 156 additions & 0 deletions blender-for-unrealengine/bfu_import_module/bps/color_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# ====================== BEGIN GPL LICENSE BLOCK ============================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# All rights reserved.
#
# ======================= END GPL LICENSE BLOCK =============================

# ----------------------------------------------
# BPS -> BleuRaven Python Script
# BleuRaven.fr
# XavierLoux.com
# ----------------------------------------------

# This use ANSI color codes.
# You can found it all here -> https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124
# This file use the code of rene-d -> https://gist.github.com/rene-d/9e584a7dd2935d0f461904b9f2950007



# SGR color constants
# rene-d 2018

class Colors:
""" ANSI color codes """

# Color
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BROWN = "\033[0;33m"
BLUE = "\033[0;34m"
PURPLE = "\033[0;35m"
CYAN = "\033[0;36m"
LIGHT_GRAY = "\033[0;37m"
DARK_GRAY = "\033[1;30m"
LIGHT_RED = "\033[1;31m"
LIGHT_GREEN = "\033[1;32m"
YELLOW = "\033[1;33m"
LIGHT_BLUE = "\033[1;34m"
LIGHT_PURPLE = "\033[1;35m"
LIGHT_CYAN = "\033[1;36m"
LIGHT_WHITE = "\033[1;37m"

#Style
BOLD = "\033[1m"
FAINT = "\033[2m"
ITALIC = "\033[3m"
UNDERLINE = "\033[4m"
BLINK = "\033[5m"
NEGATIVE = "\033[7m"
CROSSED = "\033[9m"
END = "\033[0m"


@staticmethod
def black(string):
return Colors.BLACK + string + Colors.END

@staticmethod
def red(string):
return Colors.RED + string + Colors.END

@staticmethod
def green(string):
return Colors.GREEN + string + Colors.END

@staticmethod
def brown(string):
return Colors.BROWN + string + Colors.END

@staticmethod
def blue(string):
return Colors.BLUE + string + Colors.END

@staticmethod
def purple(string):
return Colors.PURPLE + string + Colors.END

@staticmethod
def cyan(string):
return Colors.CYAN + string + Colors.END

@staticmethod
def light_gray(string):
return Colors.LIGHT_GRAY + string + Colors.END

@staticmethod
def dark_gray(string):
return Colors.DARK_GRAY + string + Colors.END

@staticmethod
def light_red(string):
return Colors.LIGHT_RED + string + Colors.END

@staticmethod
def light_green(string):
return Colors.LIGHT_GREEN + string + Colors.END

@staticmethod
def yellow(string):
return Colors.YELLOW + string + Colors.END

@staticmethod
def light_blue(string):
return Colors.LIGHT_BLUE + string + Colors.END

@staticmethod
def light_purple(string):
return Colors.LIGHT_PURPLE + string + Colors.END

@staticmethod
def light_cyan(string):
return Colors.LIGHT_CYAN + string + Colors.END

@staticmethod
def light_white(string):
return Colors.LIGHT_WHITE + string + Colors.END

@staticmethod
def bold(string):
return Colors.BOLD + string + Colors.END

@staticmethod
def faint(string):
return Colors.FAINT + string + Colors.END

@staticmethod
def italic(string):
return Colors.ITALIC + string + Colors.END

@staticmethod
def underline(string):
return Colors.UNDERLINE + string + Colors.END

@staticmethod
def blink(string):
return Colors.BLINK + string + Colors.END

@staticmethod
def negative(string):
return Colors.NEGATIVE + string + Colors.END

@staticmethod
def crossed(string):
return Colors.CROSSED + string + Colors.END
Loading

0 comments on commit 8f4ee9e

Please sign in to comment.