This repository has been archived by the owner on Feb 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path__init__.py
141 lines (109 loc) · 4.22 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
Copyright (c) 2018 iCyP
Released under the MIT license
https://opensource.org/licenses/mit-license.php
"""
import bpy
from bpy_extras.io_utils import ImportHelper,ExportHelper
from .importer import vrm_load,model_build
from .misc import VRM_HELPER
from .misc import glb_factory
import os
bl_info = {
"name":"VRM_IMPORTER",
"author": "based_on_iCyP",
"version": (0, 5),
"blender": (2, 79, 0),
"location": "File->Import",
"description": "VRM(less than spec0.0(uniVRM0.49)) Importer",
"warning": "THIS ADDON IS OUTDATED. NO SURPORT. In particular,there is no warranteis of safe, if you don't download this from https://github.com/iCyP/VRM_IMPORTER_for_Blender2_79, ",
"support": "TESTING",
"wiki_url": "",
"tracker_url": "https://github.com/iCyP/VRM_IMPORTER_for_Blender2_79",
"category": "Import-Export"
}
class ImportVRM(bpy.types.Operator,ImportHelper):
bl_idname = "import_scene.vrm"
bl_label = "import VRM"
bl_description = "import VRM"
bl_options = {'REGISTER', 'UNDO'}
filename_ext = '.vrm'
filter_glob = bpy.props.StringProperty(
default='*.vrm',
options={'HIDDEN'}
)
is_put_spring_bone_info = bpy.props.BoolProperty(name = "Put Collider Empty")
def execute(self,context):
fdir = self.filepath
model_build.Blend_model(vrm_load.read_vrm(fdir),self.is_put_spring_bone_info)
return {'FINISHED'}
def menu_import(self, context):
op = self.layout.operator(ImportVRM.bl_idname, text="VRM (.vrm)")
op.is_put_spring_bone_info = True
class ExportVRM(bpy.types.Operator,ExportHelper):
bl_idname = "export_scene.vrm"
bl_label = "export VRM"
bl_description = "export VRM"
bl_options = {'REGISTER', 'UNDO'}
filename_ext = '.vrm'
filter_glob = bpy.props.StringProperty(
default='*.vrm',
options={'HIDDEN'}
)
def execute(self,context):
fdir = self.filepath
bin = glb_factory.Glb_obj(bl_info["author"]).convert_bpy2glb()
with open(fdir,"wb") as f:
f.write(bin)
return {'FINISHED'}
def menu_export(self, context):
op = self.layout.operator(ExportVRM.bl_idname, text="VRM (.vrm)")
class VRM_IMPORTER_UI_controller(bpy.types.Panel):
bl_idname = "icyp_ui_controller"
bl_label = "vrm import helper"
#どこに置くかの定義
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "VRM HELPER"
@classmethod
def poll(self, context):
return True
def draw(self, context):
self.layout.label(text="if you select armature in object mode")
self.layout.label(text="armature renamer is shown")
self.layout.label(text="if you in MESH EDIT")
self.layout.label(text="symmetry button is shown")
self.layout.label(text="*symmetry is in default blender")
if context.mode == "OBJECT":
if context.active_object is not None:
self.layout.operator(VRM_HELPER.VRM_VALIDATOR.bl_idname)
if context.active_object.type == 'ARMATURE':
self.layout.label(icon ="ERROR" ,text="EXPERIMENTAL!!!")
self.layout.operator(VRM_HELPER.Bones_rename.bl_idname)
if context.active_object.type =="MESH":
self.layout.label(icon="ERROR",text="EXPERIMENTAL!お試し版。あてにしない")
self.layout.operator(VRM_HELPER.Vroid2VRC_ripsync_from_json_recipe.bl_idname)
if context.mode == "EDIT_MESH":
self.layout.operator(bpy.ops.mesh.symmetry_snap.idname_py())
classes = (
ImportVRM,
ExportVRM,
VRM_HELPER.Bones_rename,
VRM_HELPER.Vroid2VRC_ripsync_from_json_recipe,
VRM_HELPER.VRM_VALIDATOR,
VRM_IMPORTER_UI_controller
)
# アドオン有効化時の処理
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.INFO_MT_file_import.append(menu_import)
bpy.types.INFO_MT_file_export.append(menu_export)
# アドオン無効化時の処理
def unregister():
bpy.types.INFO_MT_file_export.remove(menu_export)
bpy.types.INFO_MT_file_import.remove(menu_import)
for cls in classes:
bpy.utils.unregister_class(cls)
if "__main__" == __name__:
register()