Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
iCyP committed Jan 26, 2019
1 parent ce988e5 commit dcd3dfc
Show file tree
Hide file tree
Showing 16 changed files with 2,765 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@

.vscode/.ropeproject/objectdb
.vscode/.ropeproject/config.py
.vscode/tasks.json
*.pyc
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 iCyP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions README.md
@@ -0,0 +1,34 @@
# MIT license 
# Draco圧縮 非 対 応 (Draco complessed data is unsupported)
# Blender2.80向けはこっち (for Blender2.8 is below)
https://github.com/iCyP/VRM_IMPORTER_for_Blender2_8
# 注意
## インポートボタン押したら固まったんだけど???
- インポートには数十秒程度かかります。しばらく待ってみてください。
## 雰囲気でインポートしたので、間違いがあります。
## 変更禁止(CC_ND)VRMは弾く" 仕様 "です悪しからず。
## attention! for comers from other addon's notice.
- This addon is independent project from other addons.
## インストール方法
- そこの右上の緑のボタンを押してZIP Download
ー blender->User preference->addon -> addon installで先に落としたZipを選ぶ
- おわり
## つかいかた
- menubar->File->import->VRM
- select relational object(armature,meshes) menubar->File->export->VRM
- export require setting text file in blender text editor, metas in custum propaty in armature object and humanbone custom propaties and, so on.
## 既知の不具合 
- マテリアルがおかしい->blender2.8が出たら本気だす(直すとは言ってない)


## 機能説明
### 出来ること
- VRMをそれっぽくBlenderにimportできる
- VRM内すべてのテクスチャを(インポートするうえで必要に迫られて)VRMと同じフォルダに書き出す。
- 同じフォルダ以外も要望があれば、個人的開発ポリシーに反しない範囲で実装可能
- ※すでに*同名のテクスチャがある場合、上書きしない*ようになっているので、注意してください。(不慮の上書き防止の仕様です)
### 出来ないこと
- VRMのマテリアルをカンペキにBlenderにimportする
- その他私の想定外なモデルのimport

- memo:実はExport、出来るとか出来ないとか、でもフルスクラッチからはかーーなり難しいんじゃないかな。
184 changes: 184 additions & 0 deletions V_Types.py
@@ -0,0 +1,184 @@
"""
Copyright (c) 2018 iCyP
Released under the MIT license
https://opensource.org/licenses/mit-license.php
"""
class VRM_pydata(object):
def __init__(
self,
filepath = None,json = None,decoded_binary = None,
image_propaties = None,meshes =None,materials = None,
nodes_dict = None,origine_nodes_dict = None,
skins_joints_list = None , skins_root_node_list = None
):
self.filepath = filepath
self.json = json
self.decoded_binary = decoded_binary

self.image_propaties = image_propaties if image_propaties is not None else []
self.meshes = meshes if meshes is not None else []
self.materials = materials if materials is not None else []
self.nodes_dict = nodes_dict if nodes_dict is not None else {}
self.origine_nodes_dict = origine_nodes_dict if origine_nodes_dict is not None else {}
self.skins_joints_list = skins_joints_list if skins_joints_list is not None else []
self.skins_root_node_list = skins_root_node_list if skins_root_node_list is not None else []


class Mesh(object):
def __init__(self):
self.name = ""
self.face_indices = []
self.skin_id = None
self.object_id = None



class Node(object):
def __init__(self):
self.name = ""
self.position = None
self.rotation = None
self.scale = None
self.children = None
self.blend_bone = None
self.mesh_id = None
self.skin_id = None



class Image_props(object):
def __init__(self,name,filepath,fileType):
self.name = name
self.filePath = filepath
self.fileType = fileType




class Material(object):
def __init__(self):
self.name = ""
self.shader_name = ""



class Material_GLTF(Material):
def __init__(self):
super().__init__()
self.color_texture_index = None
self.color_texcood_index = None
self.base_color = None
self.metallic_factor = None
self.roughnessFactor = None
self.emissiveFactor = None
self.metallic_roughness_texture_index = None
self.metallic_roughness_texture_texcood = None
self.normal_texture_index = None
self.normal_texture_texcoord_index = None
self.emissive_texture_index = None
self.emissive_texture_texcoord_index = None
self.occlusion_texture_index = None
self.occlusion_texture_texcood_index = None
self.double_sided = None
self.alphaMode = "OPAQUE"
self.shadeless = False


class Material_Transparent_Z_write(Material):
float_props = [
"_MainTex",
"_Cutoff",
"_BlendMode",
"_CullMode",
"_VColBlendMode",
"_SrcBlend",
"_DstBlend",
"_ZWrite",
]
texture_index_list = [
"_MainTex"
]
vector_props = [
"_Color"
]

def __init__(self):
super().__init__()
self.float_props_dic = {prop: None for prop in self.float_props}
self.vector_props_dic = {prop: None for prop in self.vector_props}
self.texture_index_dic = {tex:None for tex in self.texture_index_list}



class Material_MToon(Material):
float_props = [
"_Cutoff",
"_BumpScale",
"_ReceiveShadowRate",
"_ShadeShift",
"_ShadeToony",
"_ShadingGradeRate",
"_LightColorAttenuation",
"_IndirectLightIntensity",
"_OutlineWidth",
"_OutlineScaledMaxDistance",
"_OutlineLightingMix",
"_DebugMode",
"_BlendMode",
"_OutlineWidthMode",
"_OutlineColorMode",
"_CullMode",
"_OutlineCullMode",
"_SrcBlend",
"_DstBlend",
"_ZWrite",
"_IsFirstSetup"
]

texture_index_list = [
"_MainTex",#use in BI
"_ShadeTexture",#ignore in BI
"_BumpMap",#use in BI
"_ReceiveShadowTexture",#ignore in BI
"_ShadingGradeTexture",#ignore in BI
"_EmissionMap",#ignore in BI
"_SphereAdd",#use in BI
"_OutlineWidthTexture"#ignore in BI
]
vector_props = [
"_Color",
"_EmissionColor",
"_OutlineColor",
"_ShadeColor"
]
#texture offset and scaling props by texture
vector_props.extend(texture_index_list)

keyword_list = [
"_NORMALMAP",
"_ALPHATEST_ON",
"_ALPHABLEND_ON",
"_ALPHAPREMULTIPLY_ON",
"MTOON_OUTLINE_WIDTH_WORLD",
"MTOON_OUTLINE_WIDTH_SCREEN",
"MTOON_OUTLINE_COLOR_FIXED",
"MTOON_OUTLINE_COLOR_MIXED",
"MTOON_DEBUG_NORMAL",
"MTOON_DEBUG_LITSHADERATE"
]
tagmap_list = [
"RenderType"
]

def __init__(self):
super().__init__()
self.float_props_dic = {prop:None for prop in self.float_props}
self.vector_props_dic = {prop:None for prop in self.vector_props}
self.texture_index_dic = {prop: None for prop in self.texture_index_list}
self.keyword_dic = {kw:False for kw in self.keyword_list}
self.tag_dic = {tag:None for tag in self.tagmap_list}


if "__main__" == __name__:
pass
141 changes: 141 additions & 0 deletions __init__.py
@@ -0,0 +1,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": "iCyP",
"version": (0, 5),
"blender": (2, 79, 0),
"location": "File->Import",
"description": "VRM Importer",
"warning": "",
"support": "TESTING",
"wiki_url": "",
"tracker_url": "",
"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().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()

0 comments on commit dcd3dfc

Please sign in to comment.