-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dff580
commit c455f2b
Showing
17 changed files
with
369 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ htmlcov | |
*.so | ||
*.dylib | ||
*.exe | ||
*.zip | ||
|
||
# doc | ||
*.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
import bpy | ||
|
||
|
||
def dds_properties_exist(): | ||
return hasattr(bpy.types.Image, "dds_props") | ||
|
||
|
||
def get_addon_preferences(context, addon_name): | ||
preferences = context.preferences | ||
addon_prefs = preferences.addons[addon_name].preferences | ||
return addon_prefs | ||
|
||
|
||
def get_image_editor_space(context): | ||
area = context.area | ||
if area.type == 'IMAGE_EDITOR': | ||
space = area.spaces.active | ||
else: | ||
raise RuntimeError('Failed to get Image Editor. This is unexpected.') | ||
return space | ||
|
||
|
||
def load_texture(file, name, color_space='Non-Color'): | ||
"""Load a texture file. | ||
Args: | ||
file (string): file path for dds | ||
name (string): object name for the texture | ||
color_space (string): color space | ||
Returns: | ||
tex (bpy.types.Image): loaded texture | ||
""" | ||
tex = bpy.data.images.load(file) | ||
tex.colorspace_settings.name = color_space | ||
tex.name = name | ||
tex.pack() | ||
tex.filepath = os.path.join('//textures', tex.name + '.' + file.split('.')[-1]) | ||
tex.filepath_raw = tex.filepath | ||
return tex | ||
|
||
|
||
def save_texture(tex, file, fmt): | ||
"""Save a texture. | ||
Args: | ||
tex (bpy.types.Image): an image object | ||
file (string): file path | ||
fmt (string): file format | ||
""" | ||
file_format = tex.file_format | ||
filepath_raw = tex.filepath_raw | ||
|
||
try: | ||
tex.file_format = fmt | ||
tex.filepath_raw = file | ||
tex.save() | ||
|
||
tex.file_format = file_format | ||
tex.filepath_raw = filepath_raw | ||
|
||
except Exception as e: | ||
tex.file_format = file_format | ||
tex.filepath_raw = filepath_raw | ||
raise e |
Oops, something went wrong.