-
Notifications
You must be signed in to change notification settings - Fork 9
/
__init__.py
123 lines (106 loc) · 4.15 KB
/
__init__.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
bl_info = {
"name": "No Man's Sky Development Kit",
"author": "gregkwaste, monkeyman192",
"version": (0, 9, 26),
"blender": (4, 0, 0),
"location": "File > Export/Import",
"description": "Create NMS scene structures and export to NMS File format",
"warning": "",
"wiki_url": "https://monkeyman192.github.io/NMSDK/",
"tracker_url": "https://github.com/monkeyman192/NMSDK/issues",
"category": "Import-Export"}
import bpy
from bpy.utils import register_class, unregister_class
from bpy.props import PointerProperty
# Inject the directory this file is in into the sys.path so that the imports
# become significantly nicer...
import sys
import os.path as op
sys.path.append(op.dirname(__file__))
# External API operators
from .NMSDK import ImportSceneOperator, ImportMeshOperator, ExportSceneOperator
# Main IO operators
from .NMSDK import NMS_Export_Operator, NMS_Import_Operator
# NMSDK object node handling operators
from .NMSDK import CreateNMSDKScene
# Internal operators
from .NMSDK import (_FixOldFormat, _ToggleCollisionVisibility,
_SaveDefaultSettings, _FixActionNames, _GetPCBANKSFolder,
_RemovePCBANKSFolder, _GetMBINCompilerLocation,
_RemoveMBINCompilerLocation, _ImportReferencedScene)
# Settings
from .NMSDK import NMSDKSettings, NMSDKDefaultSettings
# Animation classes
from .NMSDK import (_ChangeAnimation, _PlayAnimation, _PauseAnimation,
_StopAnimation, _LoadAnimation, AnimProperties,
_RefreshAnimations)
from .ModelImporter.animation_handler import AnimationHandler
# extensions to blender UI
from .BlenderExtensions import (NMSNodes, NMSEntities, NMSPanels,
SettingsPanels, ContextMenus) # , NMSShaderNode)
# Note: The NMSShaderNode is broken for 2.8. This needs a lot of work anyway
# and isn't being used so we'll just not load it for now...
customNodes = NMSNodes()
# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
self.layout.operator(NMS_Export_Operator.bl_idname,
text="Export to NMS XML Format ")
def menu_func_import(self, context):
self.layout.operator(NMS_Import_Operator.bl_idname,
text="Import NMS SCENE")
classes = (NMS_Export_Operator,
NMS_Import_Operator,
NMSDKSettings,
NMSDKDefaultSettings,
ImportSceneOperator,
ImportMeshOperator,
ExportSceneOperator,
CreateNMSDKScene,
_FixOldFormat,
_FixActionNames,
_ImportReferencedScene,
_GetPCBANKSFolder,
_RemovePCBANKSFolder,
_GetMBINCompilerLocation,
_RemoveMBINCompilerLocation,
_ToggleCollisionVisibility,
_SaveDefaultSettings,
_ChangeAnimation,
_RefreshAnimations,
_LoadAnimation,
_PlayAnimation,
_PauseAnimation,
_StopAnimation,
AnimationHandler,
AnimProperties)
def register():
for cls in classes:
register_class(cls)
bpy.types.Scene.nmsdk_settings = PointerProperty(type=NMSDKSettings)
bpy.types.Scene.nmsdk_default_settings = PointerProperty(
type=NMSDKDefaultSettings)
bpy.types.Scene.nmsdk_anim_data = PointerProperty(type=AnimProperties)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
NMSPanels.register()
# NMSShaderNode.register()
customNodes.register()
NMSEntities.register()
SettingsPanels.register()
ContextMenus.register()
def unregister():
for cls in reversed(classes):
unregister_class(cls)
del bpy.types.Scene.nmsdk_settings
del bpy.types.Scene.nmsdk_default_settings
del bpy.types.Scene.nmsdk_anim_data
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
NMSPanels.unregister()
# NMSShaderNode.unregister()
customNodes.unregister()
NMSEntities.unregister()
SettingsPanels.unregister()
ContextMenus.unregister()
if __name__ == '__main__':
register()