-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTextureOp.py
63 lines (51 loc) · 1.8 KB
/
TextureOp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
from bl_ui.space_sequencer import selected_sequences_len
import bpy
if 'DEBUG_MODE' in sys.argv:
from Texture import Texture
else:
from . Texture import Texture
class ImportSettings:
lod = -1
mipmap = -1
norm_signed = True
def __init__(self):
self.lod = -1
self.mipmap = -1
self.norm_signed = True
class ImportTextureOp(bpy.types.Operator):
bl_idname = "import.infinitetexture"
bl_label = "Import Halo Infinite Bitmap"
bl_description = "import a halo infinite bitmap"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
mipmap: bpy.props.IntProperty(
name="Mipmap level",
description="Mipmap level of the textures to import.",
default=0
)
norm_signed: bpy.props.BoolProperty(
name="Signed Texture Range",
description="import texures with a signed format as signed",
default=False
)
def execute(self, context):
name = self.filepath.replace('\\','/').split('/')[-1].split('.')[0].split('{')[0] # get the file name and remove unneccesary stuff
settings = ImportSettings()
settings.mipmap = self.mipmap
settings.norm_signed = self.norm_signed
tex = Texture()
tex.readTexture(self.filepath,name,settings)
return {'FINISHED'}
def invoke(self,context,event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def menu_func(self,context):
self.layout.operator_context = 'INVOKE_DEFAULT'
self.layout.operator(ImportTextureOp.bl_idname,text="Halo Infinite Bitmap")
def register():
print("loaded")
bpy.utils.register_class(ImportTextureOp)
bpy.types.TOPBAR_MT_file_import.append(menu_func)
def unregister():
print("unloaded")
bpy.utils.unregister_class(ImportTextureOp)