Skip to content

Commit

Permalink
fix for module import
Browse files Browse the repository at this point in the history
  • Loading branch information
matyalatte committed Aug 28, 2022
1 parent b3af561 commit 850856b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
21 changes: 12 additions & 9 deletions addons/blender_uasset_addon/import_uasset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
from mathutils import Vector, Quaternion, Matrix
import numpy as np

from . import bpy_util, unreal, util
from . import bpy_util
from .unreal.uasset import Uasset
from .unreal.dds import DDS
from .util.io_util import make_temp_file
from .texconv.texconv import Texconv


Expand Down Expand Up @@ -113,7 +116,7 @@ def load_utexture(file, name, version, asset=None, invert_normals=False, no_err=
file (string): file path to .uasset file
name (string): texture name
version (string): UE version
asset (unreal.uasset.Uasset): loaded asset data
asset (Uasset): loaded asset data
invert_normals (bool): Flip y axis if the texture is normal map.
texconv (Texconv): Texture converter for dds.
Expand All @@ -125,15 +128,15 @@ def load_utexture(file, name, version, asset=None, invert_normals=False, no_err=
if asset is None, it will load .uasset file
if it's not None, it will get texture data from asset
"""
temp = util.io_util.make_temp_file(suffix='.dds')
temp = make_temp_file(suffix='.dds')
if texconv is None:
texconv = Texconv()
if asset is not None:
name = asset.name
file = name
try:
if asset is None:
asset = unreal.uasset.Uasset(file, version=version, asset_type='Texture')
asset = Uasset(file, version=version, asset_type='Texture')
utex = asset.uexp.texture
utex.remove_mipmaps()
if 'BC5' in utex.type:
Expand All @@ -142,7 +145,7 @@ def load_utexture(file, name, version, asset=None, invert_normals=False, no_err=
tex_type = 'GRAY'
else:
tex_type = 'COLOR'
dds = unreal.dds.DDS.asset_to_DDS(asset)
dds = DDS.asset_to_DDS(asset)
dds.save(temp)
tga_file = texconv.convert_to_tga(temp, utex.format_name, utex.uasset.asset_type,
out=os.path.dirname(temp), invert_normals=invert_normals)
Expand All @@ -169,7 +172,7 @@ def generate_materials(asset, version, load_textures=False,
"""Add materials and textures, and make shader nodes.
args:
asset (unreal.uasset.Uasset): mesh asset
asset (Uasset): mesh asset
version (string): UE version
load_textures (bool): if import texture files or not
invert_normal_maps (bool): if flip y axis for normal maps or not
Expand Down Expand Up @@ -276,7 +279,7 @@ def generate_mesh(amt, asset, materials, material_names, rescale=1.0,
Args:
amt (bpy.types.Armature): target armature
asset (unreal.uasset.Uasset): source asset
asset (Uasset): source asset
materials (list[bpy.types.Material]): material objects
material_names (list[string]): material names
rescale (float): rescale factor for vertex positions
Expand Down Expand Up @@ -450,7 +453,7 @@ def load_animation(anim, armature, ue_version, rescale=1.0, ignore_missing_bones
print(f'Skeleton asset NOT found ({path})')
if skel_path is None:
raise RuntimeError('Skeleton asset not found.')
bones = unreal.uasset.Uasset(skel_path, version=ue_version).uexp.skeleton.bones
bones = Uasset(skel_path, version=ue_version).uexp.skeleton.bones

if ue_version not in ['ff7r', 'kh3']:
raise RuntimeError(f'Animations are unsupported for this verison. ({ue_version})')
Expand Down Expand Up @@ -555,7 +558,7 @@ def load_uasset(file, rename_armature=True, keep_sections=False,
See property groups for the description of arguments
"""
# load .uasset
asset = unreal.uasset.Uasset(file, version=ue_version, verbose=verbose)
asset = Uasset(file, version=ue_version, verbose=verbose)
asset_type = asset.asset_type
print(f'Asset type: {asset_type}')

Expand Down
9 changes: 5 additions & 4 deletions addons/blender_uasset_addon/inject_to_uasset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from bpy.types import Operator, PropertyGroup
from mathutils import Vector, Quaternion, Euler

from . import bpy_util, unreal
from . import bpy_util
from .unreal.uasset import Uasset


def get_rescale_factor(rescale):
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_primitives(asset, armature, meshes, rescale=1.0, only_mesh=False):
"""Get mesh data as a dictionary.
Args:
asset (unreal.uasset.Uasset): traget asset
asset (Uasset): traget asset
armature (bpy.types.Armature): source armature
meshes (list[bpy.types.Mesh]): source meshes
rescale (float): rescale factor for objects
Expand Down Expand Up @@ -266,7 +267,7 @@ def inject_animation(asset, armature, ue_version, rescale=1.0):
print(f'Skeleton asset NOT found ({path})')
if skel_path is None:
raise RuntimeError('Skeleton asset not found.')
bones = unreal.uasset.Uasset(skel_path, version=ue_version).uexp.skeleton.bones
bones = Uasset(skel_path, version=ue_version).uexp.skeleton.bones

if ue_version != 'ff7r':
raise RuntimeError(f'Animations are unsupported for this verison. ({ue_version})')
Expand Down Expand Up @@ -355,7 +356,7 @@ def inject_uasset(source_file, directory, ue_version='4.18',
version = ue_version
if version not in ['ff7r', '4.18']:
raise RuntimeError(f'Injection is unsupported for {version}')
asset = unreal.uasset.Uasset(source_file, version=version)
asset = Uasset(source_file, version=version)
asset_type = asset.asset_type

# get selected objects
Expand Down

3 comments on commit 850856b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
addons\blender_uasset_addon_init_.py351557%18–30, 33, 58–60
addons\blender_uasset_addon\bpy_util.py41011871%11, 26, 38, 43–44, 49–51, 56–62, 67–70, 75–81, 86–87, 102–105, 129, 131, 140, 162, 166–167, 171, 319, 325, 354, 428, 510–513, 554, 558, 562, 642–672, 742–745, 766–810
addons\blender_uasset_addon\export_as_fbx.py1104559%31, 176, 180–208, 212, 216–242, 256–264
addons\blender_uasset_addon\get_new_release.py511669%17, 21–25, 48–57
addons\blender_uasset_addon\import_uasset.py54423657%153, 156–161, 199, 206, 222–224, 240, 246, 252–254, 257, 347–385, 392–409, 417–430, 440–539, 569, 571–581, 584, 586, 877–910, 914, 918–921, 925–978, 989–991, 996, 1009–1024, 1029
addons\blender_uasset_addon\inject_to_uasset.py36415458%120, 155–159, 166–167, 173–175, 210–212, 220, 251–346, 358, 366, 368, 370, 373, 375, 380, 398, 404, 468–483, 487–488, 492–517, 534–535, 539–540, 553–565
addons\blender_uasset_addon\open_urls.py24579%24–28
addons\blender_uasset_addon\texconv\texconv.py692564%13, 30–36, 40–42, 51, 58, 61, 71, 74, 77, 90–98
addons\blender_uasset_addon\translations\translation.py34391%49, 57–58
addons\blender_uasset_addon\unreal\acl.py38932417%67–70, 74–75, 79–96, 100, 104, 108, 112, 116, 120, 124, 141–144, 148–149, 153–159, 171–174, 179–205, 209–248, 252–270, 274–281, 285–286, 294–295, 300–307, 311–316, 321, 325–326, 330–331, 335–337, 345–348, 352–354, 358–360, 364–366, 370, 374, 378–381, 385–389, 393–404, 412–419, 425–523, 528–562, 566–570, 574–585, 589–596
addons\blender_uasset_addon\unreal\animation.py34129513%14–25, 30–48, 53–59, 66–69, 74–88, 92–99, 127–143, 151–210, 216–241, 245–253, 257–265, 269, 273, 277, 281, 285, 289, 293, 300–302, 307–313, 321, 329–330, 335–347, 352, 356–357, 365–367, 372–393, 398–476
addons\blender_uasset_addon\unreal\buffer.py4144789%45–46, 63–64, 132–136, 173–183, 264–267, 278, 282–284, 348–355, 464–468, 566–569, 574–575
addons\blender_uasset_addon\unreal\dds.py140497%30, 153, 185, 229
addons\blender_uasset_addon\unreal\lod.py4071696%196, 201, 241, 284, 308, 315, 318–320, 344, 350–351, 397, 405, 532–533
addons\blender_uasset_addon\unreal\lod_section.py2353286%9, 147–150, 162, 190–192, 207–208, 276, 308–320, 325–332
addons\blender_uasset_addon\unreal\material.py1232580%43, 56–58, 107, 116–119, 123–130, 138, 141, 148, 166–169, 171–173
addons\blender_uasset_addon\unreal\mesh.py25110359%26–28, 32–46, 65, 71, 77–82, 98–99, 109–143, 151–160, 254–257, 275–276, 280–286, 292–295, 298, 312–320, 324–326, 331, 336–345, 349–352
addons\blender_uasset_addon\unreal\mipmap.py69987%66, 74–75, 97–102
addons\blender_uasset_addon\unreal\skeleton.py2163882%77–79, 96, 113–120, 196, 233, 235, 259, 287–310, 314–317
addons\blender_uasset_addon\unreal\texture.py2785381%39, 51, 80, 100, 115, 128, 142, 160–165, 168–170, 175–177, 186, 192–198, 231, 290–292, 299–311, 358, 361, 364–365, 390, 399–400, 402, 406–408
addons\blender_uasset_addon\unreal\uasset.py2692591%59, 153–160, 265–267, 275–276, 278–279, 325, 327, 333–335, 359–361, 380
addons\blender_uasset_addon\unreal\uexp.py1112280%27, 29–30, 51, 70–71, 80, 108–111, 125, 127, 135–139, 143, 147–150
addons\blender_uasset_addon\util\io_util.py1994677%41–45, 80–81, 86–87, 105, 144, 154, 159–160, 165, 172, 176, 203–207, 254–255, 278, 298, 308, 313–314, 319, 344–347, 352–355, 374–382
TOTAL5152165668%
 

Tests Skipped Failures Errors Time
74 0 💤 0 ❌ 0 🔥 2.726s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
addons\blender_uasset_addon_init_.py351557%18–30, 33, 58–60
addons\blender_uasset_addon\bpy_util.py41011672%11, 26, 38, 43–44, 49–51, 56–62, 67–70, 75–81, 86–87, 102–105, 129, 131, 140, 162, 166–167, 171, 319, 325, 354, 428, 516–518, 554, 558, 562, 642–672, 742–745, 766–810
addons\blender_uasset_addon\export_as_fbx.py1104559%31, 176, 180–208, 212, 216–242, 256–264
addons\blender_uasset_addon\get_new_release.py511669%17, 21–25, 48–57
addons\blender_uasset_addon\import_uasset.py54423657%153, 156–161, 199, 206, 222–224, 240, 246, 252–254, 257, 347–385, 392–409, 417–430, 440–539, 569, 571–581, 584, 586, 877–910, 914, 918–921, 925–978, 989–991, 996, 1009–1024, 1029
addons\blender_uasset_addon\inject_to_uasset.py36415458%120, 155–159, 166–167, 173–175, 210–212, 220, 251–346, 358, 366, 368, 370, 373, 375, 380, 398, 404, 468–483, 487–488, 492–517, 534–535, 539–540, 553–565
addons\blender_uasset_addon\open_urls.py24579%24–28
addons\blender_uasset_addon\texconv\texconv.py692564%13, 30–36, 40–42, 51, 58, 61, 71, 74, 77, 90–98
addons\blender_uasset_addon\translations\translation.py34488%43, 49, 57–58
addons\blender_uasset_addon\unreal\acl.py38932417%67–70, 74–75, 79–96, 100, 104, 108, 112, 116, 120, 124, 141–144, 148–149, 153–159, 171–174, 179–205, 209–248, 252–270, 274–281, 285–286, 294–295, 300–307, 311–316, 321, 325–326, 330–331, 335–337, 345–348, 352–354, 358–360, 364–366, 370, 374, 378–381, 385–389, 393–404, 412–419, 425–523, 528–562, 566–570, 574–585, 589–596
addons\blender_uasset_addon\unreal\animation.py34029414%14–25, 30–48, 53–59, 66–69, 74–88, 92–99, 127–143, 151–210, 216–241, 245–253, 257–265, 269, 273, 277, 281, 285, 289, 293, 300–302, 307–313, 321, 329–330, 335–347, 352, 356–357, 365–367, 372–393, 398–476
addons\blender_uasset_addon\unreal\buffer.py4144789%45–46, 63–64, 132–136, 173–183, 264–267, 278, 282–284, 348–355, 464–468, 566–569, 574–575
addons\blender_uasset_addon\unreal\dds.py140497%30, 153, 185, 229
addons\blender_uasset_addon\unreal\lod.py4071696%196, 201, 241, 284, 308, 315, 318–320, 344, 350–351, 397, 405, 532–533
addons\blender_uasset_addon\unreal\lod_section.py2353286%9, 147–150, 162, 190–192, 207–208, 276, 308–320, 325–332
addons\blender_uasset_addon\unreal\material.py1232580%43, 56–58, 107, 116–119, 123–130, 138, 141, 148, 166–169, 171–173
addons\blender_uasset_addon\unreal\mesh.py25010359%26–28, 32–46, 65, 71, 77–82, 98–99, 109–143, 151–160, 254–257, 275–276, 280–286, 292–295, 298, 312–320, 324–326, 331, 336–345, 349–352
addons\blender_uasset_addon\unreal\mipmap.py69987%66, 74–75, 97–102
addons\blender_uasset_addon\unreal\skeleton.py2163882%77–79, 96, 113–120, 196, 233, 235, 259, 287–310, 314–317
addons\blender_uasset_addon\unreal\texture.py2785381%39, 51, 80, 100, 115, 128, 142, 160–165, 168–170, 175–177, 186, 192–198, 231, 290–292, 299–311, 358, 361, 364–365, 390, 399–400, 402, 406–408
addons\blender_uasset_addon\unreal\uasset.py2692591%59, 153–160, 265–267, 275–276, 278–279, 325, 327, 333–335, 359–361, 380
addons\blender_uasset_addon\unreal\uexp.py1112280%27, 29–30, 51, 70–71, 80, 108–111, 125, 127, 135–139, 143, 147–150
addons\blender_uasset_addon\util\io_util.py1994677%41–45, 80–81, 86–87, 105, 144, 154, 159–160, 165, 172, 176, 203–207, 254–255, 278, 298, 308, 313–314, 319, 344–347, 352–355, 374–382
TOTAL5150165468%
 

Tests Skipped Failures Errors Time
74 0 💤 0 ❌ 0 🔥 2.018s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
addons\blender_uasset_addon_init_.py351557%18–30, 33, 58–60
addons\blender_uasset_addon\bpy_util.py41011372%11, 26, 38, 43–44, 49–51, 56–62, 67–70, 75–81, 86–87, 102–105, 129, 131, 140, 162, 166–167, 171, 319, 325, 354, 428, 516–518, 554, 558, 562, 642–672, 747, 766–810
addons\blender_uasset_addon\export_as_fbx.py1094559%31, 176, 180–208, 212, 216–242, 256–264
addons\blender_uasset_addon\get_new_release.py511669%17, 21–25, 48–57
addons\blender_uasset_addon\import_uasset.py54323657%153, 156–161, 199, 206, 222–224, 240, 246, 252–254, 257, 347–385, 392–409, 417–430, 440–539, 569, 571–581, 584, 586, 877–910, 914, 918–921, 925–978, 989–991, 996, 1009–1024, 1029
addons\blender_uasset_addon\inject_to_uasset.py36415458%120, 155–159, 166–167, 173–175, 210–212, 220, 251–346, 358, 366, 368, 370, 373, 375, 380, 398, 404, 468–483, 487–488, 492–517, 534–535, 539–540, 553–565
addons\blender_uasset_addon\open_urls.py24579%24–28
addons\blender_uasset_addon\texconv\texconv.py692564%13, 30–36, 40–42, 51, 58, 61, 71, 74, 77, 90–98
addons\blender_uasset_addon\translations\translation.py34488%43, 49, 57–58
addons\blender_uasset_addon\unreal\acl.py38432416%67–70, 74–75, 79–96, 100, 104, 108, 112, 116, 120, 124, 141–144, 148–149, 153–159, 171–174, 179–205, 209–248, 252–270, 274–281, 285–286, 294–295, 300–307, 311–316, 321, 325–326, 330–331, 335–337, 345–348, 352–354, 358–360, 364–366, 370, 374, 378–381, 385–389, 393–404, 412–419, 425–523, 528–562, 566–570, 574–585, 589–596
addons\blender_uasset_addon\unreal\animation.py33729512%14–25, 30–48, 53–59, 66–69, 74–88, 92–99, 127–143, 151–210, 216–241, 245–253, 257–265, 269, 273, 277, 281, 285, 289, 293, 300–302, 307–313, 321, 329–330, 335–347, 352, 356–357, 365–367, 372–393, 398–476
addons\blender_uasset_addon\unreal\buffer.py4014788%45–46, 63–64, 132–136, 173–183, 264–267, 278, 282–284, 348–355, 464–468, 566–569, 574–575
addons\blender_uasset_addon\unreal\dds.py137497%30, 153, 185, 229
addons\blender_uasset_addon\unreal\lod.py4011696%196, 201, 241, 284, 308, 315, 318–320, 344, 350–351, 397, 405, 532–533
addons\blender_uasset_addon\unreal\lod_section.py2283286%9, 147–150, 162, 190–192, 207–208, 276, 308–320, 325–332
addons\blender_uasset_addon\unreal\material.py1192579%43, 56–58, 107, 116–119, 123–130, 138, 141, 148, 166–169, 171–173
addons\blender_uasset_addon\unreal\mesh.py24610358%26–28, 32–46, 65, 71, 77–82, 98–99, 109–143, 151–160, 254–257, 275–276, 280–286, 292–295, 298, 312–320, 324–326, 331, 336–345, 349–352
addons\blender_uasset_addon\unreal\mipmap.py68987%66, 74–75, 97–102
addons\blender_uasset_addon\unreal\skeleton.py2073882%77–79, 96, 113–120, 196, 233, 235, 259, 287–310, 314–317
addons\blender_uasset_addon\unreal\texture.py2785381%39, 51, 80, 100, 115, 128, 142, 160–165, 168–170, 175–177, 186, 192–198, 231, 290–292, 299–311, 358, 361, 364–365, 390, 399–400, 402, 406–408
addons\blender_uasset_addon\unreal\uasset.py2622590%59, 153–160, 265–267, 275–276, 278–279, 325, 327, 333–335, 359–361, 380
addons\blender_uasset_addon\unreal\uexp.py1112280%27, 29–30, 51, 70–71, 80, 108–111, 125, 127, 135–139, 143, 147–150
addons\blender_uasset_addon\util\io_util.py1994677%41–45, 80–81, 86–87, 105, 144, 154, 159–160, 165, 172, 176, 203–207, 254–255, 278, 298, 308, 313–314, 319, 344–347, 352–355, 374–382
TOTAL5086165268%
 

Tests Skipped Failures Errors Time
74 0 💤 0 ❌ 0 🔥 2.538s ⏱️

Please sign in to comment.